bigshooter
Platinum Member
here's some quick perl code that I wrote, and I'm wondering why it's giving me errors.
I want to exit the program and output a mesage if there are no command line arguments to this program so i just use
if (!@argv)
{
print "useage $0: command line args;
exit (1);
}
and yes i know i could use die instead, but i'm too used to c++. my problem is when I add this to my code, it gives me this
Global symbol "@argv" requires explicit package name at prog11.pl line 21.
Execution of prog11.pl aborted due to compilation errors (#1)
Uncaught exception from user code:
Global symbol "@argv" requires explicit package name at prog11.pl line 21.
Execution of prog11.pl aborted due to compilation errors.
i'm just curious why you can access elements of @argv, or do something like $temp = shift ...which uses @argv as default,
but you can't say if argv is empty kill the prog. Anyone that is a little more advanced with perl than I am know this answer? Also, any other better ways to check for arguments?
Thanks.
I want to exit the program and output a mesage if there are no command line arguments to this program so i just use
if (!@argv)
{
print "useage $0: command line args;
exit (1);
}
and yes i know i could use die instead, but i'm too used to c++. my problem is when I add this to my code, it gives me this
Global symbol "@argv" requires explicit package name at prog11.pl line 21.
Execution of prog11.pl aborted due to compilation errors (#1)
Uncaught exception from user code:
Global symbol "@argv" requires explicit package name at prog11.pl line 21.
Execution of prog11.pl aborted due to compilation errors.
i'm just curious why you can access elements of @argv, or do something like $temp = shift ...which uses @argv as default,
but you can't say if argv is empty kill the prog. Anyone that is a little more advanced with perl than I am know this answer? Also, any other better ways to check for arguments?
Thanks.