On Fri, 18 Dec 2009 02:39:07 -0500, Steve Bertrand wrote:
>> Note that there is or at least used to be also a side effect in perl
>> that would cause that warning if there was an assignment "nearby" a
>> conditional, even if not where you'd think it ought to be to complain.
>> I forget the details
Peter Scott wrote:
> Although it turned out not to be what was going on here, just to address
> your subject line' it's not just Perlcritic that will complain about
> assignment in a conditional, but also warnings:
>
> % perl -wle 'print 42 if $x = 0'
> Found = in conditional, should be == at -e
Although it turned out not to be what was going on here, just to address
your subject line' it's not just Perlcritic that will complain about
assignment in a conditional, but also warnings:
% perl -wle 'print 42 if $x = 0'
Found = in conditional, should be == at -e line 1.
And of course you sho
On Dec 15, 5:17 pm, shawnhco...@gmail.com (Shawn H Corey) wrote:
> Uri Guttman wrote:
> >> "SHC" == Shawn H Corey writes:
> > SHC> Try:
> > SHC> my $month = '';
> > SHC> $month = $ARGV[0] if $ARGV[0];
>
> > or just use ||:
>
> > my $month = $ARGV[0] || '' ;
>
> $ cat myscript.pl
> #!/
Steve Bertrand wrote:
John W. Krahn wrote:
Steve Bertrand wrote:
if ( $month !~ m{ \A \d{4}-\d{2} \z }xms ) {
print "\nInvalid date parameter. Must be supplied as '-MM'\n\n";
exit;
You exit the program if $month is not equal to a seven character string.
ehhh.. *scratching head w
> "SB" == Steve Bertrand writes:
>> I was just thinking, but didn't get a chance to test what would happen
>> if I declared $var = '', and then performed a regex check on it.
SB> This tells me that pre-declaring a var with '' makes my original logic
fail:
that isn't 'predeclaring' bu
Steve Bertrand wrote:
> John W. Krahn wrote:
>> perldoc perlsyn
>> [ SNIP ]
>> NOTE: The behaviour of a "my" statement modified with a statement
>> modifier conditional or loop construct (e.g. "my $x if ...") is
>> undefined. The value of the "my" variable may be "undef", any
>> p
John W. Krahn wrote:
> Steve Bertrand wrote:
>> Hi everyone,
>
> Hello,
>
>> I'm reviewing a script I wrote that I use against one of my modules. The
>> script takes an optional param at the command line.
>>
>> Although I am seriously reviewing my options for better and smarter ways
>> to utilize
Steve,
You need to declare $month in a separate line. The variable may not
exist if the statement evaluate to false. I think that's what it is
complaining about.
-venkat
On 12/15/09, Steve Bertrand wrote:
> Hi everyone,
>
> I'm reviewing a script I wrote that I use against one of my modules.
On 12/15/09 Tue Dec 15, 2009 4:49 PM, "Shawn H Corey"
scribbled:
> Steve Bertrand wrote:
>> my $month = $ARGV[0] if $ARGV[0];
>
> $ cat myscript.pl
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my $month = $ARGV[0] if $ARGV[0];
> print "$month\n";
> $ ./myscript.pl
> Use of uninitial
Steve Bertrand wrote:
Hi everyone,
Hello,
I'm reviewing a script I wrote that I use against one of my modules. The
script takes an optional param at the command line.
Although I am seriously reviewing my options for better and smarter ways
to utilize command line args, I'm curious as to why
Steve Bertrand wrote:
> Uri Guttman wrote:
>>> "SHC" == Shawn H Corey writes:
>> SHC> Steve Bertrand wrote:
>> >> my $month = $ARGV[0] if $ARGV[0];
>>
>> that is similar to the broken my $foo = 1 if 0 used to make static vars
>> inside a sub. the assignment won't even happen unless you hav
Uri Guttman wrote:
>> "SHC" == Shawn H Corey writes:
> SHC> Try:
> SHC> my $month = '';
> SHC> $month = $ARGV[0] if $ARGV[0];
>
> or just use ||:
>
> my $month = $ARGV[0] || '' ;
$ cat myscript.pl
#!/usr/bin/perl
use strict;
use warnings;
my $month = $ARGV[0] || '';
print "mon
Uri Guttman wrote:
>> "SHC" == Shawn H Corey writes:
>
> SHC> Steve Bertrand wrote:
> >> my $month = $ARGV[0] if $ARGV[0];
>
> that is similar to the broken my $foo = 1 if 0 used to make static vars
> inside a sub. the assignment won't even happen unless you have a true value.
>
> SHC
> "SHC" == Shawn H Corey writes:
SHC> Steve Bertrand wrote:
>> my $month = $ARGV[0] if $ARGV[0];
that is similar to the broken my $foo = 1 if 0 used to make static vars
inside a sub. the assignment won't even happen unless you have a true value.
SHC> Try:
SHC> my $month = '';
SHC>
Shawn H Corey wrote:
> Steve Bertrand wrote:
>> my $month = $ARGV[0] if $ARGV[0];
>
> $ cat myscript.pl
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my $month = $ARGV[0] if $ARGV[0];
> print "$month\n";
> $ ./myscript.pl
> Use of uninitialized value $month in concatenation (.) or string
Steve Bertrand wrote:
> my $month = $ARGV[0] if $ARGV[0];
$ cat myscript.pl
#!/usr/bin/perl
use strict;
use warnings;
my $month = $ARGV[0] if $ARGV[0];
print "$month\n";
$ ./myscript.pl
Use of uninitialized value $month in concatenation (.) or string at
./myscript.pl line 7.
Try:
my $month =
Hi everyone,
I'm reviewing a script I wrote that I use against one of my modules. The
script takes an optional param at the command line.
Although I am seriously reviewing my options for better and smarter ways
to utilize command line args, I'm curious as to why perlcritic complains
to me, and (i
18 matches
Mail list logo