For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > February 2005 > Challenge (for me, at least)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Challenge (for me, at least)
Tyson Sommer

2005-02-18, 8:55 pm

Is there any way to squeeze the following into one line? (assume using
CGI.pm and that my $q = new CGI;):

$device = $q->param( "device_name" );
$device = $ARGV[0] if ! $device;
$device = "default_device" if ! $device;


i.e., first see if we're being used with a CGI form, if not -- see if we
have something from the command line, otherwise use a default value.


Or better yet, how about squeezing this into one line:

$device = $q->param( "device_name" );
$device = $ARGV[0] if ! $device;
chomp ( $device = <STDIN> ) if ! $device;

Not a critical question (the code works), but I am facinated with Perl
shortcuts...


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com