Hi,
By assuming that the last name comes after the }, I have written the code here, which sorts based on the last name.
use strict; use warnings; use Data::Dumper; my @lines; while (<DATA>) { chomp; $_ =~/}(\w+)/; push @lines, [$1,$_]; } @lines = sort { $a->[0] cmp $b->[0] } @lines; print Dumper \@lines; __DATA__ '\bibitem{all99}Allison P.D.' '\bibitem{al200}Vinoth B.D.' '\bibitem{al200}Ana A.D.'
In reply to Re: Sorting file with regex
by vinoth.ree
in thread Sorting file with regex
by postindustrial_hamst
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |