in reply to Grave accent/Backtick/`` caveats

Just FYI: I can't replicate the problem. I get fb723667fcd81966afcd60ec6b9d6eab364e0a31 in both cases ($hash1 and $hash2).

Replies are listed 'Best First'.
Re^2: Grave accent caveats
by deepakg (Novice) on Jan 19, 2009 at 17:25 UTC
    Thanks for checking!

    I get:

    98bed27374f41bdef95f4dbc6cb3ff3728721837 and
    fb723667fcd81966afcd60ec6b9d6eab364e0a31

    I am on Mac OS X with perl v5.8.8, now I am beginning to wonder if it is caused by the Mac environment. I just fired a test on a Linux VM, and I get identical results for $hash1 and $hash2 too! Any perl users on Mac here?

      Try bypassing the backtick operator and use IPC::Open2

      #!/usr/bin/perl use Digest::SHA1; use IPC::Open2; use strict; use warnings; my $text = "deepak.gulati"; my $hash1 = do_openssl( $text ); my $hash2 = Digest::SHA1::sha1_hex( $text ); print $hash1, "\n"; print $hash2, "\n"; sub do_openssl { my $text = shift; open2( my $rfh, my $wfh, 'openssl dgst -sha1' ) || die "cannot open: + $!\n"; print $wfh $text; close( $wfh ); my $value = <$rfh>; close( $rfh ); chomp( $value ); return $value; }

      -derby
        Thanks a ton! This gave identical result for $hash1 and $hash2. Any idea why backticks are problematic here?