Irfan J Sayed schreef:
> #!/usr/local/bin/perl
>
> use warnings;
> use strict;
Good!
> my $file = "c:\backup.pl";
Use
my $file = 'c:\backup.pl';
or rather
my $file = 'c:/backup.pl';
> open(FH,$file) || die " can't open a file";
Make that:
open my $fh, '<', $file or die "Error opening '$file': $!" ;
> my $pattern = '\w\s\w';
my $pattern = qr/\w\s\w/ ;
> my $input = <>;
> print "yes got the match " if $input =~ /$pattern/;
Try this:
while ( <$fh> ) {
/$pattern/ and printf "match in line %s\n", $. ;
}
> but i am getting following error
>
> Name "main::FH" used only once: possible typo at C:\irfan\search.pl
close $fh or die "Error closing '$file': $!" ;
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>