in reply to Regex Tagging (newbie)

I'm not sure what you mean by 'tagging', but here goes it:
$log_start =~ s/^\w+\s+(\w+\s+\d{1,2}\s+\d{1,2}:\d{1,2}:\d{1,2})\s+\d{ +4}$/$1/i; print $log_start, "\n";
The reason it wasn't working, was because your \w will only match 1 character, and no more. Not only that, you try to match the date which - if it were successful - it would save into $1, which you don't seem to be assigning to anything.

I don't think
Use of uninitialized value in concatenation (.) at.....
has anything to do with the code you posted above, since there no actual concatenations taking place. At least, running the snippet with -w doesn't yield me any warnings.

update modified regex slightly (added +'s). it works now.

ar0n ]

Replies are listed 'Best First'.
Re: (ar0n) Re: Regex Tagging (newbie)
by cajun (Chaplain) on May 05, 2001 at 16:15 UTC

    Thanks ar0n. I see your point about the \w.

    I've also tried printing $1.

    So the regex isn't matching. I replaced mine with yours.

    my $now = time; $log_start=scalar localtime $now -1 * 86400; print "Log start = $log_start\n"; $log_start=~ s/^\w+\s+(\w+\s\d{1,2}\s\d{1,2}:\d{1,2}:\d{1,2})\s\d{4}$/ +$1/i; print "Modified Log start = $1\n";
    update

    Thanks to ar0n in CB, the correct regex is:

    $log_start=~ s/^\w+\s+(\w+\s+\d{1,2}\s\d{1,2}:\d{1,2}:\d{1,2})\s\d{4}$ +/$1/i;