Irfan J Sayed wrote:
> Hi ,

Hello,

> I am using following code 
> 
> #!/usr/local/bin/perl
> 
>  # Main program
>  
>  use warnings;
>  use strict;
> 
>  my $file = "c:\backup.pl";

The escape sequence "\b" represents the backspace character.  You probably want:

my $file = 'c:/backup.pl';

>  open(FH,$file) || die " can't open a file";

You should include the $file variable and the $! variable in the error message:

open(FH,$file) || die " can't open '$file' $!";

>  my $pattern = '\w\s\w';
>  my $input = <>;

You probably want to get your input from the FH filehandle:

my $input = <FH>;

>  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.

You are only using the FH filehandle once, in the open function.

>  can't open a file at C:\irfan\search.pl line 9.

You probably don't have a file name with a backspace character in it.



John
-- 
use Perl;
program
fulfillment

-- 
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