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.
In reply to Re: Pattern finding and printing with regex
by toolic
in thread Pattern finding and printing with regex
by kernelpanic@thedisco
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |