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
Hello,
We are in the process of setting up a checkout page using Paypal and Google's
Checkout, using the Google Checkout HTML API. This is simple setup with 3
different single items that can be ordered using Paypal or Google Checkout. Now
setting up the Paypal API no problems there. But I have
> "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
Xiao Lan (小兰) wrote:
eval "$x=12/0";
if ($@) { print "0 div error" }'
0 div error
Don't rely on testing $@, simply because it is
a global variable that can get changed everywhere.
Instead, test the return value of the eval itself.
(Don't forget to let it return "1" for success,
just like wit
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
> "T" == Troy writes:
T> also look at 'perl -i ' . you can modify original file directly
please don't email me privately. there is no reason not to post that to
the list. i cc'ed the list where my reply belongs.
and please don't top post.
finally, i am one of the experts on the list so
> "A" == A4r0N writes:
A> I need to add "new lines" of text with special characters, to specific
A> lines in the file. There are 3 modifications needed. Been testing 2
A> here without success.
A> #!/usr/bin/perl
A> use FileHandle;
that module is unneeded for such simple use. and
On 12/15/09 Tue Dec 15, 2009 7:42 AM, "A4r0N"
scribbled:
> I need to add "new lines" of text with special characters, to specific
> lines in the file. There are 3 modifications needed. Been testing 2
> here without success.
>
> #!/usr/bin/perl
>
> use FileHandle;
> $file=FileHandle->new;
> $F
On Tue, Dec 15, 2009 at 10:42 AM, A4r0N wrote:
> I need to add "new lines" of text with special characters, to specific
> lines in the file. There are 3 modifications needed. Been testing 2
> here without success.
>
What error are you getting? What modifications are needed? I know
what this scri
I need to add "new lines" of text with special characters, to specific
lines in the file. There are 3 modifications needed. Been testing 2
here without success.
#!/usr/bin/perl
use FileHandle;
$file=FileHandle->new;
$FILENAME="/opt/etc/usr/file.txt";
$file->open ("<$FILENAME") or die ("Error: $!\
2009/12/15 Shawn H Corey :
> Philip Potter wrote:
>> 1. Is there a "set" type which holds aggregate data and doesn't care
>> about order, which I could use to compare these results for equality?
>
> You can use a hash as a set or a bag.
Yeah I thought about this -- while I can see how it works wit
Philip Potter wrote:
> 1. Is there a "set" type which holds aggregate data and doesn't care
> about order, which I could use to compare these results for equality?
You can use a hash as a set or a bag.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
# Make Data::Dumper pretty
$Data
Hi all,
I have a method which returns two arrayrefs: one is an array of
hashes, and the other an array of arrays. I'm writing a test harness
for this method, so I put together some testcases and expected
results. I don't care what order the arrays are in; I only care that
the arrayrefs returned by
From: Bob McConnell
> Just to avoid re-inventing a pair of wheels, does anyone
> have a script that will accept any and all SMTP connections
> and messages, but dumps them into a file instead of trying
> to forward them?
To close the loop on this question, even though I didn't receive any
respon
2009/12/15 Shlomi Fish :
> On Tuesday 15 Dec 2009 15:53:28 Philip Potter wrote:
>> How can "Illegal division by zero" be a compile-time error? It seems
>> clear to me that it's a run-time error, which the optimizer has
>> (wrongly) decided to raise at compile-time.
>>
>
> Well, the Perl compiler te
Shameem Ahamed wrote:
> Hi All,
>
> I ran in to a problem.
>
> My program was working very fine till last week. When i checked it today, i
> found that the child process in not updating the log files.
>
> I have a daemon process in which a common log file is opened in the parent
> process, a
Hi All,
I ran in to a problem.
My program was working very fine till last week. When i checked it today, i
found that the child process in not updating the log files.
I have a daemon process in which a common log file is opened in the parent
process, and after forking a child parent will exi
On Tuesday 15 Dec 2009 15:53:28 Philip Potter wrote:
> 2009/12/15 Shlomi Fish :
> > On Tuesday 15 Dec 2009 14:25:28 Xiao Lan (小兰) wrote:
> >> On Tue, Dec 15, 2009 at 7:50 PM, Xiao Lan (小兰)
> >
> > wrote:
> >> > I did have tried that, but this will get a runtime error.
> >>
> >> Sorry this is exact
2009/12/15 Shlomi Fish :
> On Tuesday 15 Dec 2009 14:25:28 Xiao Lan (小兰) wrote:
>> On Tue, Dec 15, 2009 at 7:50 PM, Xiao Lan (小兰)
> wrote:
>> > I did have tried that, but this will get a runtime error.
>>
>> Sorry this is exactly a compile-time error.
>>
>> # cat except.pl
>>
>> eval { $x=12/0 };
On Tuesday 15 Dec 2009 14:25:28 Xiao Lan (小兰) wrote:
> On Tue, Dec 15, 2009 at 7:50 PM, Xiao Lan (小兰)
wrote:
> > I did have tried that, but this will get a runtime error.
>
> Sorry this is exactly a compile-time error.
>
> # cat except.pl
>
> eval { $x=12/0 };
> print "0 div error" if $@;
>
>
On Tue, Dec 15, 2009 at 7:50 PM, Xiao Lan (小兰) wrote:
>
>
>
> I did have tried that, but this will get a runtime error.
>
Sorry this is exactly a compile-time error.
# cat except.pl
eval { $x=12/0 };
print "0 div error" if $@;
# perl -c except.pl
Illegal division by zero at except.pl line 2.
2009/12/15 Xiao Lan (小兰) :
> On Tue, Dec 15, 2009 at 6:34 PM, Shlomi Fish wrote:
>> You can use block eval {} instead of string eval "":
> I did have tried that, but this will get a runtime error.
>
> # perl -e '
> eval { $x = 12/0 };
> if ($@) { print "0 div error" }'
>
> Illegal division by zero
On Tue, Dec 15, 2009 at 6:34 PM, Shlomi Fish wrote:
>
> You can use block eval {} instead of string eval "":
>
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my $x;
>
> eval
> {
> $x=12/0;
> };
>
> if ($@)
> {
> print "0 div error\n";
> }
I did have tried that, b
On Tuesday 15 Dec 2009 09:50:27 Xiao Lan (小兰) wrote:
> Hello,
>
> It seems in ruby and python we have a good exception capturing way.
> The ruby's:
>
> irb(main):042:0> begin
> irb(main):043:1* x=12/0
> irb(main):044:1> rescue
> irb(main):045:1> puts "0 div error"
> irb(main):046:1> end
> 0 d
35 matches
Mail list logo