Hi Irfan,
On 6/1/06, Irfan J Sayed <[EMAIL PROTECTED]> wrote:
Hi ,

I am using following code

#!/usr/local/bin/perl

 # Main program

 use warnings;
 use strict;

 my $file = "c:\backup.pl";
 open(FH,$file) || die " can't open a file";
 my $pattern = '\w\s\w';
 my $input = <>;
 print "yes got the match " if $input =~ /$pattern/;

but  i am getting following error

Name "main::FH" used only once: possible typo at C:\irfan\search.pl line
9.
 can't open a file at C:\irfan\search.pl line 9.

can anybody plz help me out
As far as I can tell, you need to escape the '\' in the string you're
assigning to $file:
my $file = "c:\\backup.pl";

You also need to either escape the slashes for the pattern you're
using, or use the qr// form:
my $pattern = qr/\w\s\w/; # or  my $pattern = '\\w\\s\\w';

HTH,
David

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to