Re: Argument isn't numeric warning in if statement

2014-09-18 Thread Rob Dixon
On 18/09/2014 00:34, SSC_perl wrote: On Sep 17, 2014, at 3:32 PM, Rob Dixon wrote: As you have presented them, those code fragments are identical in meaning. That was my understanding as well, but the inline 'if' gave an error while the block didn't. Running the code by itself in TextWrangler

Re: Argument isn't numeric warning in if statement

2014-09-17 Thread SSC_perl
On Sep 17, 2014, at 3:32 PM, Rob Dixon wrote: > As you have presented them, those code fragments are identical in meaning. That was my understanding as well, but the inline 'if' gave an error while the block didn't. Running the code by itself in TextWrangler does not produce the warning

Re: Argument isn't numeric warning in if statement

2014-09-17 Thread Rob Dixon
->{'unitprice'} += $item->{'optionprice'} if ($item->{'optionprice'}); Given the following values: $item->{'unitprice'} = '12.16'; $item->{'optionprice'} = ''; the 2nd statement returns an "Argumen

Re: Argument isn't numeric warning in if statement

2014-09-17 Thread Lawrence Statton
On 09/17/2014 12:46 PM, SSC_perl wrote: > On Sep 16, 2014, at 6:58 PM, > wrote: >> Are you sure you've quoted the code (that's producing the warning) correctly? > > Yes, I did. I double-checked it just to be certain. However, I ran > the code by itself and it doesn't produce that warni

Re: Argument isn't numeric warning in if statement

2014-09-17 Thread SSC_perl
On Sep 16, 2014, at 6:58 PM, wrote: > Are you sure you've quoted the code (that's producing the warning) correctly? Yes, I did. I double-checked it just to be certain. However, I ran the code by itself and it doesn't produce that warning, so it must be something upstream that's caus

Re: Argument isn't numeric warning in if statement

2014-09-16 Thread sisyphus1
-Original Message- From: SSC_perl Sent: Wednesday, September 17, 2014 10:37 AM To: Perl Beginners Subject: Argument isn't numeric warning in if statement I just ran across something puzzling. Why are these two statements not equivalent when it comes to warnings? if (

Argument isn't numeric warning in if statement

2014-09-16 Thread SSC_perl
} += $item->{'optionprice'} if ($item->{'optionprice'}); Given the following values: $item->{'unitprice'} = '12.16'; $item->{'optionprice'} = ''; the 2nd statement returns an "Argument '' isn

Re: ERROR: Argument isn't numeric

2012-06-12 Thread Andy Bach
foreach $i (@dir) { my @title = split /\./, $dir[$i]; $i is your file name so split that not the @dir entry. You're sort of trying the same thing twice. foreach gets each array element, one at a time - you're split usage implies you're expecting the array's index (also the var. name $i so for

Re: ERROR: Argument isn't numeric

2012-06-11 Thread timothy adigun
ly to use just the first index of the array as name like so: $name = $title[0]; > > print FH " TARGET=\"_blank\">$name\n"; > } > > > Interestingly, the program executes with the error but only considers the > first file it finds in the directory. If there are N files, it will print N > links, but all using the first file name. > I think you should also see comments posted by John W. in your previous post titled "Argument isn't numeric" Hope this helps -- Tim

Re: ERROR: Argument isn't numeric

2012-06-11 Thread Zheng Du
Hi John Refer to the comments foreach $i (@dir) { *#$i here refers to each content of your array @dir, which are file names* my @title = split /\./, $dir[$i]; *#$i here refers to the array index, which should be number* $name = $title[0]; print FH "$name\n"; } Zheng 2012/6/10 John M Rathbun >

ERROR: Argument isn't numeric

2012-06-11 Thread John M Rathbun
Hello and thanks for volunteering your time! I'm returning to PERL after about a year and am struggling to remaster some syntax: #!/usr/local/bin/perl use warnings; use strict; use diagnostics; # Converts current directory to a list of links my @dir; my $name; my $i = 0; opendir DH, "." or

Re: Argument isn't numeric

2012-06-10 Thread John W. Krahn
jmrhide-p...@yahoo.com wrote: Hello and thanks for volunteering your time! Hello. (And it's Perl, not PERL. :-) I'm returning to PERL after about a year and am struggling to remaster some syntax: #!/usr/local/bin/perl use warnings; use strict; use diagnostics; # Converts current direct

Argument isn't numeric

2012-06-10 Thread jmrhide-perl
Hello and thanks for volunteering your time! I'm returning to PERL after about a year and am struggling to remaster some syntax: #!/usr/local/bin/perl use warnings; use strict; use diagnostics; # Converts current directory to a list of links my @dir; my $name; my $i = 0; opendir

Re: 'argument isn't numeric' error in CGI script

2002-02-15 Thread John W. Krahn
Jim Witte wrote: > > Hi, > >I'm running Apache on a MacOS X (10.1.2) box in IP-loopback mode, and > I'm experiementing with a CGI script that acts like a state-machine. I > cooked up the example at the bottom of the page. If I run it as is, it > runs fine. But if I comment out line 48, wh

'argument isn't numeric' error in CGI script

2002-02-15 Thread Jim Witte
Hi, I'm running Apache on a MacOS X (10.1.2) box in IP-loopback mode, and I'm experiementing with a CGI script that acts like a state-machine. I cooked up the example at the bottom of the page. If I run it as is, it runs fine. But if I comment out line 48, which tells &action1 to exit w