open(FILE, 'data.txt') or die $!;
while (<FILE>)
{ if (/^#/) { print 'This is line number ', $. ,
"n" } }
close FILE;
ÔÚ2007-04-10£¬"Mirza Abdullah Jan"
<jan576pkyahoo.com> дµÀ£º
Following is the scenario
A text fie name "data.txt" and contains data like
# hello phone
# tango mango
# bus truck
12 23
34 43
32 34
#
#
I write a program to counts how many line with # is preent
in array . My code is as follow
my $datafile;
;
my $u;
my $tsize;
$datafile = "data.txt";
open(FILEHANDLE,"$datafile");
my fdata=<FILEHANDLE>;
$tsize = (fdata);
for($u=0;$u<$tsize;$u++)
{
if($fdata[$u] eq ' # ' )
{ printf "This is line number ".$u; }
}
But when i executes the files is doen't show the desired
result.
Regards
Abullah
---------------------------------
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
Check it out.
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
Unsubscribing info is here: h
ttp://help.yahoo.com/help/us/groups/groups-32.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://g
roups.yahoo.com/group/perl-beginner/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http
://groups.yahoo.com/group/perl-beginner/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:perl-beginner-digest@yahoogroups.com
mailto:perl-beginner-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
perl-beginner-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
Re: HELP REQUIRED
Philippines
1969-12-31 18:00:00
Hi,
try this
open IN, 'e:/test.txt' || die "cannot open the input file $!";
undef $/;
$name=<IN>; grep=$name=~/^#.*$/mg;
print scalar(grep);
regards,
yuvanbala
Huangj < redspid%40163.com">redspid163.com> wrote:
open(FILE, 'data.txt') or die $!;
while ()
{ if (/^#/) { print 'This is line number ', $. , "n" } }
close FILE;
ÔÚ2007-04-10£¬"Mirza Abdullah Jan" дµÀ£º
Following is the scenario
A text fie name "data.txt" and contains data like
# hello phone
# tango mango
# bus truck
12 23
34 43
32 34
#
#
I write a program to counts how many line with # is preent in array . My code is as follow
my $datafile;
;
my $u;
my $tsize;
$datafile = "data.txt";
open(FILEHANDLE,"$datafile");
my fdata=;
$tsize = (fdata); for($u=0;$u<$tsize;$u++)
{
if($fdata[$u] eq ' # ' )
{ printf "This is line number ".$u; }
}
But when i executes the files is doen't show the desired result.
Regards
Abullah
---------------------------------
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]
Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html
Yahoo! Groups Links
---------------------------------
Here’s a new way to find what you're looking for - Yahoo! Answers
[Non-text portions of this message have been removed]