in reply to Paste comments in a document

Like this?
#!/usr/bin/perl my $EDO; while (<DATA>) { ($EDO) = $_ =~ /=*EDO=(\w+)=*/ if /^=/; print; print "\nComment $EDO\n" if ( /^UNIX/ ); } __DATA__ =====EDO=FED00123===== XXXXX XXXXX XXXXX XXXXX XXXXX UNIX Page: XX =====EDO=FED00124===== XXXXX XXXXX XXXXX XXXXX XXXXX XXXXX UNIX Page: XX

Replies are listed 'Best First'.
Re^2: Paste comments in a document
by siffland (Novice) on Apr 06, 2010 at 22:16 UTC

    This worked great and i was able to tag the results from the database, although i hit one snag one of the results is 2009-A-2341 (instead of FEDXXXXX, those are the only 2 formats i checked). With the following code i can make it work.

    ($EDO) = $_ =~ /=*EDO=(\w+[-]\w+[-]\w+)=*/ if /^=/;

    But i need:

    ($EDO) = $_ =~ /=*EDO=(\w+)=*/ if /^=/;
    To make it all work. Is there a quick way to make it match anything between the EDO= and the next = sign. Thanks again you guys are the best. Sean

      make it match anything between the EDO= and the next = sign
      ($EDO) = /=EDO=([^=]+)=/ if /^=/;

      (the character class [^=] matches anything but a = sign)