Re: FW: Optional Variables

2001-07-05 Thread Chas Owens
on. > What if my Default value is a sql statement? Can I just include the name > of the file handle between the brackets? > > > > -Original Message- > From: Brett W. McCoy [mailto:[EMAIL PROTECTED]] > Sent: Friday, June 29, 2001 6:40 PM > To: M.W. Koskamp

Re: FW: Optional Variables

2001-07-05 Thread Brett W. McCoy
On Thu, 5 Jul 2001, Kim Green wrote: > I don't know how or where to put & how to use this $option. > What if my Default value is a sql statement? Can I just include the name > of the file handle between the brackets? You can do something like my $option = @ARGV ? shift : 'SELECT * FROM my_table

FW: Optional Variables

2001-07-05 Thread Kim Green
:40 PM To: M.W. Koskamp Cc: Evgeny Goldin (aka Genie); [EMAIL PROTECTED] Subject: Re: Optional Variables On Fri, 29 Jun 2001, M.W. Koskamp wrote: > > my $option = @ARGV ? shift : ; > > Above option only works for 1 parameter tho (and commandline arguments). > For function ca

Re: Optional Variables

2001-06-29 Thread Brett W. McCoy
On Fri, 29 Jun 2001, M.W. Koskamp wrote: > > my $option = @ARGV ? shift : ; > > Above option only works for 1 parameter tho (and commandline arguments). > For function calls i like to use 'named parameters' by accepting a hash of > options. Well, yeah, but the topic *was* command-line arguments

Re: Optional Variables

2001-06-29 Thread M.W. Koskamp
> > my $option = defined $ARGV[0] ? $ARGV[0] : "default"; > > Didn't we already go through all of this a few hours ago? Randal (of > course) came up with the most succint solution: > > my $option = @ARGV ? shift : ; > Sorry for trying to be helpful. Mailing list arent represented in threads in ou

Re: Optional Variables

2001-06-29 Thread Brett W. McCoy
On Fri, 29 Jun 2001, M.W. Koskamp wrote: > > > my $option = $ARGV[0] || 1; > > > > And what if $ARGV[0] equal to 0 ? Ops .. > > > > Remember what evaluates to FALSE : > > * "0" > > * 0 > > * empty string > > * undef > > my $option = defined $ARGV[0] ? $ARGV[0] : "default"; Didn't we already go t

Re: Optional Variables

2001-06-29 Thread M.W. Koskamp
- Original Message - From: Evgeny Goldin (aka Genie) <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: Brett W. McCoy <[EMAIL PROTECTED]> Sent: Friday, June 29, 2001 11:34 PM Subject: Re: Optional Variables > > > my $option = $ARGV[0] || 1; > > And

Re: Optional Variables

2001-06-29 Thread Evgeny Goldin (aka Genie)
> my $option = $ARGV[0] || 1; And what if $ARGV[0] equal to 0 ? Ops .. Remember what evaluates to FALSE : * "0" * 0 * empty string * undef

Re: FW: Optional Variables

2001-06-29 Thread Chas Owens
On 29 Jun 2001 09:00:50 -0700, Randal L. Schwartz wrote: > > "Chas" == Chas Owens <[EMAIL PROTECTED]> writes: > > Chas> my $query = " > Chas> SELECT a.filename, a.size, a.date, b.owner, c.group > Chas> FROM filesystem a, outer owner b, outer group c > Chas>

Re: FW: Optional Variables

2001-06-29 Thread Chas Owens
On 29 Jun 2001 10:46:39 -0400, Kim Green wrote: > > Brett and Chas, > > I did create two file handles and alter my conditional statements, one to > work when there is a variable, and one for when there's no variable. The > first SQL statement should return everything for a given filename; the o

FW: Optional Variables

2001-06-29 Thread Kim Green
my $node_name = $data[3]; #print " $servicename $filename $service_type_name $node_name\n"; $each_file = "$servicename $filename $service_type_name $node_name"; open (FILE,">>$outputfile");

Re: Optional Variables

2001-06-29 Thread Randal L. Schwartz
> "Chas" == Chas Owens <[EMAIL PROTECTED]> writes: Chas> In cases where you expect 0 to be a valid value it may be better to use Chas> this construct: Chas> $var = defined($ARGV[0]) ? $ARGV[0] : DEFAULT; I prefer the sensible: $var = @ARGV ? shift : DEFAULT; Why test defined when you know

Re: Optional Variables

2001-06-29 Thread Brett W. McCoy
On 29 Jun 2001, Chas Owens wrote: > In cases where you expect 0 to be a valid value it may be better to use > this construct: > > $var = defined($ARGV[0]) ? $ARGV[0] : DEFAULT; Thanks for pointing that out. That is a more robust way of doing that. -- Brett ht

Re: Optional Variables

2001-06-29 Thread Chas Owens
On 29 Jun 2001 09:26:55 -0400, Kim Green wrote: > What's the proper syntax to indicate that a variable is optional? The script > that I have created works great when I pass in a variable, but the script > need to execute the SQL even if I don't pass in a variable. > > Thanks, > Kim > > you migh

Re: Optional Variables

2001-06-29 Thread Brett W. McCoy
On Fri, 29 Jun 2001, Kim Green wrote: > What's the proper syntax to indicate that a variable is optional? The script > that I have created works great when I pass in a variable, but the script > need to execute the SQL even if I don't pass in a variable. You can set a sane default for the variab

RE: Optional Variables

2001-06-29 Thread John Edwards
ass\n"; -Original Message- From: Kim Green [mailto:[EMAIL PROTECTED]] Sent: 29 June 2001 14:27 To: '[EMAIL PROTECTED]' Subject: Optional Variables What's the proper syntax to indicate that a variable is optional? The script that I have created works great when I pas

Optional Variables

2001-06-29 Thread Kim Green
What's the proper syntax to indicate that a variable is optional? The script that I have created works great when I pass in a variable, but the script need to execute the SQL even if I don't pass in a variable. Thanks, Kim

Re: Optional Variables

2001-06-28 Thread Me
> My question pertains to using command line variables in Perl. > I created a script that uses SQL and runs from an application, and the only > parameter is optional. This script works well when the parameter is > required or not used at all. > I have altered the SQL script so that it can accept

Optional Variables

2001-06-28 Thread Kim Green
My question pertains to using command line variables in Perl. I created a script that uses SQL and runs from an application, and the only parameter is optional. This script works well when the parameter is required or not used at all. I have altered the SQL script so that it can accept a variabl