I’m new to Perl and was experimenting around a bit. I have this code:
use Digest::MD5 'md5';
use Data::Dumper::Perltidy;
my $data = "x";
my $digest = md5($data);
# print first 6 elements
print Dumper map(ord, split(//, $digest))[0..5];
But that fails with a syntax error. I remember that PHP had similar problems whereby they planned to fix this in future releases. Does Perl still have this issue or is it just the wrong way to do this? How would be the correct way?
You are trying to apply a subscript to the map function, not it’s values.
Will do what you expect. Note the use of the
+sign in order to resolve ambiguity.