P Lerenard wrote:
>
> Hi,
Hello,
> @array = qx{egrep -n '\{' file);
> foreach $el (@array)
> {
> ($num,@other} = split(/\:/,$el);
> $thenum{$num} = $num;
> }
>
> foreach $ele (sort keys %thenum)
> {
> print"$ele\n";
> }
> except this one sort by string and not by integer, so 100 is before 99
> Do you have an idea to sort that by interger and not by string, 99 before
> 100?
>
> I tried to rebuild the key and even using the function int() but i'm stuck.
#!/usr/bin/perl -w
use strict;
my $file = 'file';
my %thenum;
open FILE, $file or die "Cannot open $file: $!";
while ( <FILE> ) {
$thenum{$.} = $. if /{/;
}
for my $ele ( sort { $a <=> $b } keys %thenum ) {
print "$ele\n";
}
__END__
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]