digger has asked for the wisdom of the Perl Monks concerning the following question:
sub kill_media { my $line = shift; my $media; if ($line =~ m!^%%DocumentMedia:!){ $media_killed=1; print OUT $line; while ($line = <IN>){ foreach $media (@_) { if ($line =~ m!$media!){ $line = ""; print "Killed media type: $media\n"; } elsif ($line !~ m!^%%+!){ return $line; } } print OUT $line; } } ----SAMPLE DATA----- %XRXbegin: 001.014 %XRXtitle: JOB P04063001.X0026 - Wps %XRXsenderName: CompuSet %XRXdisposition: PRINT %XRXcopyCount: 1 %XRXrequirements: duplex %XRXsignature: False %XRXorientation: Portrait %XRXxImageShift: 0 %XRXyImageShift: 0 %XRXend %!PS-Adobe-3.0 %%DocumentMedia: anything 612 792 0 white () %%+ anything 612 792 0 blue () %%+ anything 612 792 0 green () %%+ anything 612 792 0 pinky () %%+ anything 612 792 0 UNIVERSALID () %%Creator: CompuSet Version 8.0.0 %%CreationDate: 3/03/2004 16:04:28 %KDKHost: Binder %%BoundingBox: 0 0 612 792 %%Pages: 182
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simple regex gone wierd
by Roy Johnson (Monsignor) on Apr 19, 2004 at 15:08 UTC |