First of all, why do I need to use defined(<MYFILE>) here is my code:
#!/usr/bin/perl -w
#
open(MYFILE,'test2.txt');
$lNum = 1;
while (my $line = <MYFILE>){
chomp($line);
next if $line =~ ((/^\*+/) or (/^\s*$/));
@splitLine = split(/:\s/,$line);
print "$lNum\: \"$splitLine[0]\" And \"$splitLine[1]\"\n";
$lNum++;
};
this doesn't work for me . . .
thanks,
tim
____________________________________________________
Timothy B Booher, Lt USAF, AFRL/MNAC
101 West Eglin Blvd, Suite 339
Eglin AFB FL 32542-6810
Phone: 850-882-8302 Ext. 3360 (DSN 872-)
FAX: 850-882-2201
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 02, 2002 4:54 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: find blank line
That's right. But let me add my 5cents to it. If you decide to use the
construct "while ( <MYFILE> )..." then it better be
while( defined(<MYFILE>) ) {
//...
}
[sathish]
-----Original Message-----
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 02, 2002 2:44 PM
To: Booher Timothy B 1stLt AFRL/MNAC
Cc: Hanson, Robert; [EMAIL PROTECTED]
Subject: RE: find blank line
On Jan 2, Booher Timothy B 1stLt AFRL/MNAC said:
>Thanks so much - only one problem: when I try to use while (my $line =
><MYFILE>) { etc } I get a bunch of errors similar to this one:
>
>Use of uninitialized value at JustForTest.pl line 13, <MYFILE> chunk 5.
>
>Do you know what I am doing wrong?
The code given you has an error. You read the line into $line, but the
regex is being tested on $_. Either do:
while (<MYFILE>) {
next if /^\s*$/;
# ...
}
or
while (my $line = <MYFILE>) {
next if $line =~ /^\s*$/;
# ...
}
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]