tags:

views:

107

answers:

1

On my Linux platform with 64bits recompiled perl and SSHing Mac terminal (I guess UTF-8). I am giving all this information just in case it might be relevant.

# perl -e 'use Digest::MD5 qw/md5_hex/; print(md5_hex("alex@vi\n") ."\n");'
756e98065cb8cbf603a3dbef2afe9261

# perl -e 'use Digest::MD5 qw/md5_hex/; print(md5_hex("alex@visi\n") ."\n");'
756e98065cb8cbf603a3dbef2afe9261

# perl -e 'use Digest::MD5 qw/md5_hex/; print(md5_hex("alex@vision\n") ."\n");'
756e98065cb8cbf603a3dbef2afe9261

# perl -e 'use Digest::MD5 qw/md5_hex/; print(md5_hex("alex@visionten\n") ."\n");'
756e98065cb8cbf603a3dbef2afe9261

# perl -e 'use Digest::MD5 qw/md5_hex/; print(md5_hex("alex@visionten.\n") ."\n");'
d32e04de6906b3f284c6834b4d1d77c1

# perl -e 'use Digest::MD5 qw/md5_hex/; print(md5_hex("alex@\n") ."\n");'
264eca1047ccc6272ac2e338c695379e
+15  A: 

You are using @ inside a double-quoted string. All of the @vision and @visionten things are evaluating to the same thing.

Kinopiko
Correct. Perl is interpolating the embedded @vision and @visionten as arrays which are empty, resulting in nothing being output. Printing the md5_hex() parameter strings will show most of the strings end up evaluating to "alex\n"
Greg
`use strict` please :)
hobbs
@hobbs: For one-liners that is a bit more difficult.
Kinopiko
No more difficult than in any other context, @Kinopiko.
Rob Kennedy
@Kinopiko `-mstrict` is even shorter than `use strict` :)
hobbs
OH! right !! i feel stupid now !
@alex: everybody who uses Perl has made the same mistake at least once.
Kinopiko