R
rxl124
Hi, room
Beginner of learning perl here!!
I have question to all,
I have below file name datebook.master which contains only 2 lines
Mike wolf:12/3/44:144 park ave, paramus: 44000
Sarah kim: 3/2/67:255 lomel ave, fort lee: 33000
Now, I am testing out below scripts and working fine.
-------------------- scripts 1------------------------------------------
#!/usr/bin/perl -w
open(FILE, "datebook.bak") || die "CAn't open $!\n";
while(<FILE>) {
@line=split(":");
print "$line[0] $line[2]\n";
}
close(FILE)
------------------------------------------------------------------------
And, I get desired results.
However, if I do a script w/ below, it does not work.
-------------------- scripts 2------------------------------------------
#!/usr/bin/perl -w
open(FILE, "datebook.bak") || die "CAn't open $!\n";
@lines=(<FILE>);
while(<@lines>) {
@line=split(":");
print "$line[0] $line[2]\n";
}
close(FILE)
------------------------------------------------------------------------
Can someone tell me why this is happening?
I want script 2 since I need to call this array again in the later parts of
the scripts(in the longer version).
Can someone kindly respond?
Big thanks in advance.
Beginner of learning perl here!!
I have question to all,
I have below file name datebook.master which contains only 2 lines
Mike wolf:12/3/44:144 park ave, paramus: 44000
Sarah kim: 3/2/67:255 lomel ave, fort lee: 33000
Now, I am testing out below scripts and working fine.
-------------------- scripts 1------------------------------------------
#!/usr/bin/perl -w
open(FILE, "datebook.bak") || die "CAn't open $!\n";
while(<FILE>) {
@line=split(":");
print "$line[0] $line[2]\n";
}
close(FILE)
------------------------------------------------------------------------
And, I get desired results.
However, if I do a script w/ below, it does not work.
-------------------- scripts 2------------------------------------------
#!/usr/bin/perl -w
open(FILE, "datebook.bak") || die "CAn't open $!\n";
@lines=(<FILE>);
while(<@lines>) {
@line=split(":");
print "$line[0] $line[2]\n";
}
close(FILE)
------------------------------------------------------------------------
Can someone tell me why this is happening?
I want script 2 since I need to call this array again in the later parts of
the scripts(in the longer version).
Can someone kindly respond?
Big thanks in advance.