Do I need to really give the full pathname of the file and store in the
$file.
What does this line means
my $file = shift;

Regards
Irf.


-----Original Message-----
From: Andrew Curry [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 20, 2008 7:06 PM
To: Irfan J Sayed (isayed); beginners@perl.org
Subject: RE: doubt

Im going with empty string or null. 

-----Original Message-----
From: Irfan J Sayed (isayed) [mailto:[EMAIL PROTECTED]
Sent: 20 August 2008 14:34
To: beginners@perl.org
Subject: doubt

Hi All,

Can you please tell me what is the value of $file. When i execute this
script . it says "Can't open : No such file or directory"

Please suggect.

Regards

Irf.

#!/usr/bin/perl

# file: count_lines.pl

# Figure 1.4: Count the lines of a file

use strict;

use IO::File;

my $file = shift;

my $counter = 0;

my $fh = IO::File->new($file) or die "Can't open $file: $!\n";

while ( defined (my $line = $fh->getline) ) {

$counter++;

}

STDOUT->print("Counted $counter lines\n");


This e-mail is from the PA Group.  For more information, see
www.thepagroup.com.
This e-mail may contain confidential information.  
Only the addressee is permitted to read, copy, distribute or otherwise
use this email or any attachments.  
If you have received it in error, please contact the sender immediately.

Any opinion expressed in this e-mail is personal to the sender and may
not reflect the opinion of the PA Group.
Any e-mail reply to this address may be subject to interception or
monitoring for operational reasons or for lawful business practices.


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


Reply via email to