Command line args in Perl
-
Here here at X10 we pride ourselves on top notch coding. (snicker) So I thought I would make sure that you all understood the most effective way of parsing command line arguments in Perl (per a previous perl developer)...
#Cycle through the command line arguments
@ARGV = ('-') unless @ARGV;
while ( $ARGV = shift )
{
push @data, $ARGV;
}
#Get the data from the command line
foreach $item (@data)
{
chomp $item;
if($file eq "")
{
if($item =~ /settings.dat/)
{
$file = $item;
}
}
elsif($search_key eq "")
{
$search_key = $item;
}
elsif($deal eq "")
{
$deal = $item;
}
}
#Make sure we have the data before we continue
if(($file eq "")||($search_key eq "")||($deal eq ""))
{
exit(0);
}
-
that is amazingly shitty.
-
Isn't GetOpt::Long a standard module? Sheesh.
-
I wonder what is the first loop for.