in reply to Re^4: Multi-line regex help needed
in thread Multi-line regex help needed

vxp,
You can disagree all you want, but the data you posted is different than the code you ran against. See the following as proof:
#!/usr/bin/perl use strict; use warnings; { local $/ = ""; while (<DATA>) { print "================BLAH================\n$_\n"; } } __DATA__ abc1-wl-wlc2.domain.com$ $ Successful downloads: 0$ Failed downloads: 1$ Warnings: 0$ $ Detailed Log Info$ $ General Expect Errors: 1$ Text Dump Failure: 1$ Binary Transfer Successful: 1$ Attempts to get Text Dump: 1$ Attempts to use TFTP: 1$ Attempted binary transfers: 1$ $ Textual log of the file transfer:$ Processing abc1-wl-wlc2.domain.com Performing [/usr/bin/ssh -2 -a -o " +StrictHostKeyChecking no" abc1-wl-wlc2.domain.com] Exception: 3:Child + PID 20855 exited with status 256 at /usr/SD/perl-5.6.1/lib/site_perl +/ EMAN/Config/DeviceConfig/WLC.pm line 288, line 58. ExpectLog: Sorry, t +elnet is not allowed on this port!Connection to abc1-wl-wlc2.domain.c +om closed. Performing TFTP using SNMP: DestHost [x.x.x.x] Commu nity [tasMANia] agentTransferUploadServerIP [x.x.x.x] agentTransferUpl +oadFilename [x.x.x.x.UCFM.18441] Exception: 3:Child PID 20855 exited +with status 256 at /usr/SD/perl-5.6.1/lib/site_perl/EMA N/Config/DeviceConfig/WLC.pm line 288, line 58. Updating CVS$ $ apl02-wl-wlc1.domain.com$ $ Successful downloads: 0$ Failed downloads: 1$ Warnings: 0$ $ Detailed Log Info$ $ Failed Binary transfers: 1$ General Expect Errors: 1$ Text Dump Failure: 1$ TFTP failures due to SNMP set error: 1$ Attempts to get Text Dump: 1$ Attempts to use TFTP: 1$ Attempted binary transfers: 1$ $ Textual log of the file transfer:$ Processing apl02-wl-wlc1.cisco.com Performing [/usr/bin/ssh -2 -a -o " +StrictHostKeyChecking no" apl02-wl-wlc1.cisco.com] Exception: 3:Child + PID 20683 exited with status 256 at /usr/SD/perl-5.6.1/lib/site_perl +/EMAN/Config/DeviceConfig/WLC.pm line 288, line 56. ExpectLog: Sorry, + telnet is not allowed on this port!Connection to apl02-wl-wlc1.cisco +.com closed. Performing TFTP using SNMP: DestHost [64.101.206.133] Co +mmunity [private] agentTransferUploadServerIP [171.70.168.173] agentT +ransferUploadFilename [64.101.206.133.UCFM.18436] Exception: Could no +t initialise SNMP [Timeout] at /usr/SD/perl-5.6.1/lib/site_perl/EMAN/ +Config/DeviceConfig/WLC.pm line 450, line 56. Exception: 3:Child PID +20683 exited with status 256 at /usr/SD/perl-5.6.1/lib/site_perl/EMAN +/Config/DeviceConfig/WLC.pm line 288, line 56. Could not initialise S +NMP [Timeout] at /usr/SD/perl-5.6.1/lib/site_perl/EMAN/Config/DeviceC +onfig/WLC.pm line 450, line 56. at /usr/SD/perl/lib/site_perl/EMAN/Co +nfig/Download.pl line 888 at /usr/SD/perl/lib/site_perl/EMAN/Config/D +ownload.pl line 888$ $
Again, I believe it is because the $ you pasted in your root node aren't really there in your real data. When I look at the data you linked against, I can see that the $ are in fact not there. I am not trying to be a pain, I am just explaining why the code I wrote for the data you provided isn't working against the data you need it to (they aren't the same).

I did provide other suggestions by the way. Have you looked into those?

Cheers - L~R

Replies are listed 'Best First'.
Re^6: Multi-line regex help needed
by vxp (Pilgrim) on Jun 18, 2009 at 17:32 UTC

    Of course the $ isn't there - I said in the very first post that this is cat -vue's output :)

    cat -vue shows you all characters, including special characters (like the end of line $) - I thought it might be useful to see for regex crafting

      vxp,
      Of course the $ isn't there - I said in the very first post that this is cat -vue's output

      Well, I have two things to say to that. First, you get what you ask for if you make assumptions about the knowledge of the people helping you. Second, the first time I mentioned $ not really being there should have been an indication to you that I didn't know what I was talking about. In any event, here is a working proof of concept since you have had to suffer through my ignorance.

      #!/usr/bin/perl use strict; use warnings; my $file = $ARGV[0] || 'foo.txt'; open(my $fh, '<', $file) or die "Unable to open '$file' for reading: $ +!"; my $buffer = ''; while (<$fh>) { if (/^\S+domain\.com$/) { process_buffer($buffer); $buffer = $_; next; } $buffer .= $_; } sub process_buffer { my ($section) = @_; print "================BLAH================\n$section\n"; }

      Cheers - L~R

        I highly appreciate the help, thanks a lot! I apologize for making assumptions, I'll be clearer (is that a word?) next time :)