From: robic0 on
I get some weird concat warnings on print if enabled so its commented.
Post any you have (or make some up).
Here's mine ..

use strict;
#use warnings;

my @dates = ('2/30/5-7/2005', '2/5', '-3/29.2000', '4-12/05',
'-12/01-1/03', '10/2002,8/31/2005', '1/2-asdvf');

for (@dates) {
my $date = $_;
print '-'x40,"\n$date\n";
$date =~ /.*/;
$date =~
/^(?:\/*)([0-9]+)?(?:\/*)([0-9]+)?(?:\/*)([0-9]+)?(?:\/*)([,-]*)(?:\/*)([0-9]+)?(?:\/*)([0-9]+)?(?:\/*)([0-9]+)?(?:\/*)$/;
print "date = ($1)($2)($3)($4)($5)($6)($7)\n";
}

__DATA__

----------------------------------------
2/30/5-7/2005
date = (2)(30)(5)(-)(7)(2005)()
----------------------------------------
2/5
date = (2)(5)()()()()()
----------------------------------------
-3/29.2000
date = ()()()()()()()
----------------------------------------
4-12/05
date = (4)()()(-)(12)(05)()
----------------------------------------
-12/01-1/03
date = ()()()()()()()
----------------------------------------
10/2002,8/31/2005
date = (10)(2002)()(,)(8)(31)(2005)
----------------------------------------
1/2-asdvf
date = ()()()()()()()

From: usenet on
robic0(a)yahoo.com wrote:
> Post any you have (or make some up).

I don't have to make anything up. I just

use Date::Manip;

From: Matt Garrish on

<robic0(a)yahoo.com> wrote in message
news:t72ul1htar3krqf6aiflt9mr96ive71kbn(a)4ax.com...
>I get some weird concat warnings on print if enabled so its commented.

They aren't weird errors. You don't check if your match succeeds, so you
wind up using numbered variables that aren't intialized.

> Post any you have (or make some up).
> Here's mine ..
>
> use strict;
> #use warnings;

Always a bad idea...

>
> my @dates = ('2/30/5-7/2005', '2/5', '-3/29.2000', '4-12/05',
> '-12/01-1/03', '10/2002,8/31/2005', '1/2-asdvf');
>
> for (@dates) {
> my $date = $_;

Why?

foreach my $date (@dates)

> print '-'x40,"\n$date\n";
> $date =~ /.*/;
> $date =~
> /^(?:\/*)([0-9]+)?(?:\/*)([0-9]+)?(?:\/*)([0-9]+)?(?:\/*)([,-]*)(?:\/*)([0-9]+)?(?:\/*)([0-9]+)?(?:\/*)
> ([0-9]+)?(?:\/*)$/;
> print "date = ($1)($2)($3)($4)($5)($6)($7)\n";

This is you problem. If you look at your output you'll notice that you're
getting an equal number of unintiliazed warnings as empty value within
parentheses. This is not a coincidence. Most people will, at a minimum, test
if their regular expression even succeeded:

if ($date =~ /longregex/) {
# do something
}

else {
print "Invalid date\n";
}

> }
>
> __DATA__
>

The above is misleading. __DATA__ signifies that the data that follows is
used by your program (e.g., somewhere in your code is "while (my $line =
<__DATA__>)"). What follows, however, is your output.

Matt


From: Matt Garrish on

"Matt Garrish" <matthew.garrish(a)sympatico.ca> wrote in message
news:Io38f.7243$ki7.483571(a)news20.bellglobal.com...
>
> <robic0(a)yahoo.com> wrote in message
> news:t72ul1htar3krqf6aiflt9mr96ive71kbn(a)4ax.com...
>>I get some weird concat warnings on print if enabled so its commented.
>
> They aren't weird errors. You don't check if your match succeeds, so you
> wind up using numbered variables that aren't intialized.
>

That's a little misleading, on second look (since you manufactured your
dates to work). You don't require content in all your captures, so you wind
up with the unintialized warnings. It's still bad practice not to check, and
feed data that doesn't match your pattern and you will get the messages for
the above reason.

Matt


From: robic0 on
On Thu, 27 Oct 2005 08:06:05 -0400, "Matt Garrish"
<matthew.garrish(a)sympatico.ca> wrote:

>
><robic0(a)yahoo.com> wrote in message
>news:t72ul1htar3krqf6aiflt9mr96ive71kbn(a)4ax.com...
>>I get some weird concat warnings on print if enabled so its commented.
>
>They aren't weird errors. You don't check if your match succeeds, so you
>wind up using numbered variables that aren't intialized.
>
>> Post any you have (or make some up).
>> Here's mine ..
>>
>> use strict;
>> #use warnings;
>
>Always a bad idea...
>
>>
>> my @dates = ('2/30/5-7/2005', '2/5', '-3/29.2000', '4-12/05',
>> '-12/01-1/03', '10/2002,8/31/2005', '1/2-asdvf');
>>
>> for (@dates) {
>> my $date = $_;
>
>Why?
>
>foreach my $date (@dates)
>
>> print '-'x40,"\n$date\n";
>> $date =~ /.*/;
>> $date =~
>> /^(?:\/*)([0-9]+)?(?:\/*)([0-9]+)?(?:\/*)([0-9]+)?(?:\/*)([,-]*)(?:\/*)([0-9]+)?(?:\/*)([0-9]+)?(?:\/*)
>> ([0-9]+)?(?:\/*)$/;
>> print "date = ($1)($2)($3)($4)($5)($6)($7)\n";
>
>This is you problem. If you look at your output you'll notice that you're
>getting an equal number of unintiliazed warnings as empty value within
>parentheses. This is not a coincidence. Most people will, at a minimum, test
>if their regular expression even succeeded:
>
>if ($date =~ /longregex/) {
> # do something
>}
>
>else {
> print "Invalid date\n";
>}
>
>> }
>>
>> __DATA__
>>
>
>The above is misleading. __DATA__ signifies that the data that follows is
>used by your program (e.g., somewhere in your code is "while (my $line =
><__DATA__>)"). What follows, however, is your output.
>
>Matt
>
About the __DATA__ thing, I thought it was a flag to ignore below as
comments, but thats where I put the output. Whats the right way
to do it?
Thx
 |  Next  |  Last
Pages: 1 2 3
Prev: apache logs
Next: Perl gethostbyname