in reply to Take last instance of a string
#!/usr/bin/perl use warnings; use strict; open my $FH, '<', shift or die $!; my $pos; while (<$FH>) { $pos = tell $FH if -1 != index $_, 'Significant Accounting Policie +s'; } if (defined $pos) { seek $FH, $pos, 0; print while <$FH>; }
Update: simplified, as you don't want to print the line containing the string.
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
|---|