I am trying to open a log file, store all the lines to an array, and then be able to print each line in the array. the problem is with the foreach. I was reading about it and I thought that I used it correctly but apparently not. I have never seen it before either so is this a real thing I can use or just a cruel joke .
#!usr/local/bin/perl
open (USRLOG, "<usrlog.txt") or die "could not open log file";
@usrlist = <USRLOG>;
close USRLOG;
foreach $username (@usrlist) {
Print "$username";
}
------------------------------------------------------------
......and why not?
#!usr/local/bin/perl
open (USRLOG, "<usrlog.txt") or die "could not open log file";
@usrlist = <USRLOG>;
close USRLOG;
foreach $username (@usrlist) {
Print "$username";
}
------------------------------------------------------------
......and why not?