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
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
->{'unitprice'} += $item->{'optionprice'} if ($item->{'optionprice'});
Given the following values:
$item->{'unitprice'} = '12.16';
$item->{'optionprice'} = '';
the 2nd statement returns an "Argumen
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
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
-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 (
} += $item->{'optionprice'} if ($item->{'optionprice'});
Given the following values:
$item->{'unitprice'} = '12.16';
$item->{'optionprice'} = '';
the 2nd statement returns an "Argument '' isn
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
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
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
>
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
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
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
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
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
15 matches
Mail list logo