Harry Putnam wrote:
Is there something beyond style that makes those methods better than
what appears to be a simpler format
Yes. The greatest issue is code injection. This is especially true for
the abbreviated form of the two argument open:
open my $fh, $file or die "could not open $file: $!\n";
What if the user gave this as $file?
rm -fr ~
This should be avoid, especially in server code like CGIs.
Secondarily, the three argument open allows you to skip using binmode.
open my $fh, '<:encoding(utf8)', $file or die "could not open $file:
$!\";
Or
use GD;
my $img = GD::Image->new( 1800, 1200 );
# draw the picture
open my $png, '>:raw', 'image.png' or die "could not open image.png:
$!\n";
print $png $img->png() or die "could not print to image.png: $!\n";
close $png or die "could not close image.png: $!\n";
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
I like Perl; it's the only language where you can bless your
thingy.
Eliminate software piracy: use only FLOSS.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/