GRBs retractions - Param or value?

Alasdair Allan aa at astro.ex.ac.uk
Tue Aug 8 09:06:04 PDT 2006


Alasdair Allan wrote:
> #!/usr/bin/perl
>
> die "$!" unless open( FILE, "<$ARGV[0]" );
> while ( <FILE> ) {
>    my $val = $1 if m/.*"(\D?\d+)".*"INT_\d+".*/;
>    push @bytes, $val if defined $val;
> }
> close(FILE);
>
> die "$!" unless open( FILE, ">$ARGV[0].out");
> map { print FILE pack( "N", $_ ) } @bytes;
> close(FILE);

Oh, for anyone that thinks that's ugly, I asked my postgrad, who  
likes that sort of thing, and he came up with the following which is  
functionally equivalent, but a lot shorter...

open $i, $ARGV[0];local $/;$d = <$i>;@b = $d =~ m/"(\D?\d+)".*"INT_\d 
+"/g;open $o, ">$ARGV[0].out";map { print $o pack "N", $_ } @b;

My version is almost maintainable compared to that!

Cheers,
Al.



More information about the voevent mailing list