Hi,
I am trying to understand Filehandles properly. I don't really want to know an easier/alternative way of doing this. Instead, I'd like to know why this isn't working. The name of the script file is test_filehandle.
I get the error:
SERVER:~$ test_filehandle
syntax error at ./test_filehandle line 5, near "while <ISDNLOG>"
Execution of ./test_filehandle aborted due to compilation errors.
This is the script:
I thought it would work as follows: Open the file, and call it ISDNLOG. For each line in ISDNLOG, if the line begins with a word-character, print the line. Close ISDNLOG.
Help appreciated!
I am trying to understand Filehandles properly. I don't really want to know an easier/alternative way of doing this. Instead, I'd like to know why this isn't working. The name of the script file is test_filehandle.
I get the error:
SERVER:~$ test_filehandle
syntax error at ./test_filehandle line 5, near "while <ISDNLOG>"
Execution of ./test_filehandle aborted due to compilation errors.
This is the script:
Code:
SERVER:~$ cat test_filehandle
#!/usr/bin/perl -w
open (ISDNLOG, '/home/cnew/detail_short.20010805') or die "Unable to open ISDNLOG\n\n"; #[open log file]
while <ISDNLOG>
{
if (/\w/)
{
print $_;
}
}
close ISDNLOG;
I thought it would work as follows: Open the file, and call it ISDNLOG. For each line in ISDNLOG, if the line begins with a word-character, print the line. Close ISDNLOG.
Help appreciated!