Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

coding error...

Status
Not open for further replies.

vivendi

Programmer
May 12, 2005
34
Hello, im not really a perl programmer, but i found a usefull script that i need. I tried to compile this, but i get an error at this line of code

$HOST =~ s/(

And this is the error:

Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE http:/ at C:\test.pl li
ne 42.


I have no idea how to fix it, can anyone help me out with this...?
 
( and ) and / are special characters in regular expressions. Precede each with a backslash:
[tt]
$HOST =~ s/\(http:\/\/\)//;
[/tt]
 
Thanks, that did fix it. Im at the end of the code and there's still one error i cant fix.
This is the piece of code:

Code:
while ($odp = <$get1>) 
{ 
if ($odp =~ /<b>Warning</b>: main(): Unable to access ./$ARGV[2] in <b>/ ) { 
printf "\n\nFile ".$ARGV[2]." doesn't exists or something goes wrong.\r\n\r\n"; 

exit; 
} 

printf $odp;

And this is the error i get:

Bareword found where operator expected at C:\test.pl line 67, near "/<b>Warning<
/b"
(Missing operator before b?)
syntax error at C:\test.pl line 67, near "/<b>Warning</b"
syntax error at C:\test.pl line 74, near "}"
Execution of C:\test.pl aborted due to compilation errors.

Any idea how to fix this one??
 
Same thing again. You have unescaped slashes and brackets and dots in your regex.
 
I've tried to escape everything i thought that needed to be escaped, but im doing something terrible wrong cause i ended up with more errors :$

Could you please tell me where i have to escape the characters...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top