The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 06-05-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Or, finally, with Perl:

Code:
if ($line =~ m/'(\d+)\)/) { $Var1=$1 }
The reason you were getting syntax errors is that backticks in Perl will undergo what the documentation calls "double-quotish" expansion. Basically, this means that if you want a backslash to be passed to the shell, you will need to double it, because Perl already parses one level of backslashes. Also, the value of $line is being interpolated by Perl, so the shell sees the literal value echo USING (FILE '/TEST1/FILENAME'5000) without any quoting, and complains about the opening parenthesis. You can get around this with proper quoting; but of course, for trivial string manipulations, Perl itself is actually much better suited than the shell.