Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^5: Match 2 strings in same line

by kennethk (Abbot)
on Nov 25, 2013 at 17:29 UTC ( #1064260=note: print w/replies, xml ) Need Help??

in reply to Re^4: Match 2 strings in same line
in thread Match 2 strings in same line

The result of `date +"%b %d %H"` has a trailing newline, which is not present in your string. You need to remove that, perhaps with chomp:
chomp(my $logsIncDate = `date +"%b %d %H"`);

Also, why are you chomping your input, only to re-append a newline on storage? Seems like you could avoid unnecessary operations (and more opportunities for confusion and bugs) with

while (my $line = <SwitchLogs>) { if($line =~ m/$logsIncDate/ && $line =~ m/SW_MATM-4-MACFLAP_NOTIF/ +){ push(@eigrp, $line); $sendemail = 1; } }

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^6: Match 2 strings in same line
by hmb104 (Sexton) on Nov 25, 2013 at 17:33 UTC

    Thanks much. I was just missing the newline after my date formatting. Good catch.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1064260]
[jedikaiti]: Doing OK, but a little achy this AM - I think the cats were using me as a wrestling mat and mattress while I was asleep last night.
[marto]: I can relate to that somewhat, I'm a light sleeper and frequently get woken up by kids doing much the same as your cats
[jedikaiti]: Yea, the kids (& the cats) are good at that

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (12)
As of 2017-07-25 15:10 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (374 votes). Check out past polls.