in reply to Pattern finding and printing with regex
use warnings; use strict; my $i = 0; my $pattern; while (my $line = <DATA>) { chomp $line; $pattern = '>'; if ($line =~ s/^$pattern//) { $i++; print "$i: $line \n"; } } __DATA__ >foo
Now it's up to you to figure out how you explain to your professor that someone on the internet did your homework for you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pattern finding and printing with regex
by AppleFritter (Vicar) on Oct 21, 2015 at 20:04 UTC | |
|
Re^2: Pattern finding and printing with regex
by kernelpanic@thedisco (Initiate) on Oct 21, 2015 at 18:40 UTC |