>         Trying to make a subject line change for a number of scripts, but having no 
> luck.  The original code will have something like:
>     $MySubject = sprintf "%-s%-s%-s [descriptive Subject] for %-s\n",
>                                 $GlblInfo{subjectprefix},
>                                 $GlblInfo{subjectseparator},
>                                 $GlblInfo{runtype},
>                                 $GlblInfo{asofdate};
> 
>     What I am trying to do is:
> 
>     $MySubject = sprintf "%-s%-s[descriptive Subject] for %-s  %-s \n",              
>                    $GlblInfo{subjectprefix},
>                                 $GlblInfo{subjectseparator},
>                                 $GlblInfo{asofdate},
>                                           $GlblInfo{runtype};
> 
>         Seems minor, but there may be 1, 2 or x fields between runtype and last 
> print field. It may or may not be asofdate, just something before the ;

So if I'm understanding correctly, you want to move the runtype to the
end of sprintf's arg list? How about this:

#!perl
use strict;
use warnings;

my @hits = ();
for (<DATA>) {
  if (/^\s*\$mysubject = /i .. /\};\s*$/) {
    if (not @hits or $hits[$#hits] =~ /\};\s*$/) {
      push @hits, $_;
    } else {
      $hits[$#hits] .= $_;
    }
  }
}

for my $hit (@hits) {
  $hit =~ s/^([^\r\n]*?\{runtype\}),\s*[\r\n]+(.*);\s*$/$2,\n$1;/sm;
  print "$hit\n-----\n";
}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to