Hi, I am new to Perl, learning how to parse a linux log file. So, I grep sth from the log, serving as input to m parse script and print the result to a proper format.
[linux host] $ grep "Something" sample.log | perl myParser.pl my $line; foreach $line (<>) { ... }
This works fine, but I would like to supply more parameter to my perl script to determine the format style, eg.
will print the result vertically,$ grep "Something" sample.log | perl myParser.pl VERTICAL
will print the result in columnized format.$ grep "Something" sample.log | perl myParser.pl COLUMN
I tried to capture it by $ARGV[0], $ARGV1, but still failed. Please kindly help
More, i did a simple test
#!/usr/bin/perl use strict; my $param0 = $ARGV[0]; my $line; print "\nFirst Arguement is : $param0"; foreach $line (<>) { ... }
$ grep "Name=" sample.log | perl SimpleTest.pl VERTICAL
Can't open VERTICAL: No such file or directory at SimpleTest.pl line 1 +1. First Arguement is : VERTICAL
Then , it just stopped and not execute the foreach loop
In reply to More Arguments by joaming
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |