Re: quick scripting question - finding occurrence in many lines
On Tue, Nov 07, 2006 at 08:08:12AM -0800, Andrew Sackville-West wrote:
> On Wed, Nov 08, 2006 at 02:51:20AM +1100, John O'Hagan wrote:
> > ...
> >
> > Have we done this to death yet? :)
>
> there must be more. I haven't seen any perl junkies provide us with
> some permutation of ($*&#^&*%^^@@Processor%^&^$%^%#$&^$%*&^% that
> spits the answer right out. ^^^^----- that's not perl code BTW, just
> random shifted number-row. but it looks like perl eh? hehe
Well, I posted a perl regex a day or so ago,
m/(\d+)\s+P[\n-]*r[\n-]*o[\n-]*c[\n-]*e[\n-]*s[\n-]*s[\n-]*o[\n-]*r/msg
but here's a working version (indented), with some test data included:
#!/usr/bin/perl -w
use strict;
my $source = join '', <DATA>;
my $t = '[\n-]';
print "$1\n" while
$source =~ m/(\d+)\s+P$t*r$t*o$t*c$t*e$t*s$t*s$t*o$t*r/msg;
__END__
junk info 18 Pro
cessor
junk info 5 Proces-
sor
junk info 6 Proc-
essor
junk info 7 Processor
junk info 8 Processor
junk info 9 Pro-
cessor
junk info 10 P
rocessor
Ken
--
Ken Irving, fnkci@uaf.edu
Reply to: