Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl -w
    use strict;
    
  2. or download this
    use warnings;
    
  3. or download this
    my $data = get_file($jpg);
    my @res  = sizeJPG($data);
    print "$jpg width $res[0] height $res[1]\n";
    
  4. or download this
    my $data = get_file($jpg);
    my ($h,$v)  = sizeJPG($data);
    print "$jpg width $h height $v\n";
    
  5. or download this
    sub sizeJPG {
        return unless $_[0];
        my ( $width, $height );
    ...
       unpack( "nn", $1 ) if $_[0] =~ /\xFF\xC0...(....)/;
        return ( $width, $height );
    }
    
  6. or download this
    local $_=shift;
    
  7. or download this
    my ($width,$height)=unpack "nn", (/\xFF\xC0...(....)/)[0];
    
  8. or download this
    my ($width,$height)=unpack "nn", /\xFF\xC0...(....)/ ? $1 : '';
    # or "\0" x 4, maybe?
    
  9. or download this
    sub get_file {
        open FILE, $_[0] or die $!;
        binmode FILE;
    ...
        close FILE;
        return $data;
    }
    
  10. or download this
    sub get_file {
        local $/;
        open my $fh, '<:raw', shift or die $!;
        <$fh>;
    }