Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Same is different?

by BooK (Curate)
on May 29, 2001 at 00:58 UTC ( [id://83788]=perlmeditation: print w/replies, xml ) Need Help??

In CGI will be with you, always, I used the content of CGI.pm to extract all four letter bits from it. I took care of line endings using chomp. Still, on different platforms, with the same version of CGI.pm, I get different results.

Why is it that the same version of CGI.pm is different on different platforms? For further checking:

$CGI::VERSIONPerl -varchOS Platform/versionMD5 hash
2.425.005_02aixAIX/4.2.1be77c9224712d83138b6f6d020ce8101
2.465.005_03i386-freebsdFreeBSD/4.1.1-RELEASE342fae436d4d6a746a20bbbc1f2fceae
2.465.005_03i386-linuxLinux/2.2.19342fae436d4d6a746a20bbbc1f2fceae
2.465.005_03MSWin32-x86-object (ActiveState 522)MS-Windows/4.10.1998,P903d4ad8e2d17990437c999eef9490c3
2.495.005_02i386-freebsdFreeBSD/2.2.7-RELEASE557ca05ecd1f419f54b91018974adcff
2.565.6.0i386-linuxLinux Mandrake/2.2.14-15mdk94ecf90cf567e9435a3db89ef50a72b7
2.565.6.0i386-openbsdOpenBSD/2.719c66694aa19632c51c8802782076cb5
2.745.6.0 MSWin32-x86-multi-thread (ActiveState 620)MS-Windows/4.10.1998,P355fc673032bedeb3cc0cb042738af22

Naturally, this calculus has problems, since line endings do vary between Win32 and Unix... But still, there are differences. Why?

Update: So I am stupid. tye suggested to use diff, which showed me the differences: some hardcoded globals, like $TempFile::TMPDIRECTORY do change between OSes...

Tool used: perl -p0777MDigest::MD5=md5_hex -e '$_=md5_hex$_'

Replies are listed 'Best First'.
Re: Same is different?
by DrZaius (Monk) on May 29, 2001 at 19:26 UTC
    Does this mean that CGI isn't always with you if you are trying to build a portable system?

    This is complete theory, but merlyn suggested in a previous node that in the worst case you can include the contents of CGI in a BEGIN block.

    If there are platform specific variables, this means you have to change your code for different platforms.

    Same deal with use lib.

      I think this mostly means I am a stupid wheening moron... :-S

      In my obfuscated code, I assumed that the same version of CGI.pm would be identical (except for line-endings) on every platform Perl runs on. This is false. But the differences are in fact very tiny (a few lines), and mostly regard configuration parameters, which actually and naturally change between platforms and installs.

      I think the Perl core (and CGI is part of the standard distribution) is you best bet at portable code. This doesn't include Obfuscation, that's all... :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://83788]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-04-18 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found