in reply to Re: MD 5 hash comparison/checker
in thread MD 5 hash comparison/checker

Hi, yeah it's used to compare the hashes.

I tryed your code, but it wont let me specify which files I'd like compared.

Also, I've noticed when I run code in perl, at the end of the code it automatically shuts down so I can't read the results, how do I stop this?

It doesn't happen if I run from CMD, but if I just click the .pl file it shuts down at the end.

Replies are listed 'Best First'.
Re^3: MD 5 hash comparison/checker
by graff (Chancellor) on May 07, 2010 at 03:24 UTC
    but if I just click the .pl file it shuts down at the end.

    Ah. That explains a great deal. If you really want/expect the script to work when it gets launched by clicking on the file's icon in a file browser, consider the following idiom:

    #!/usr/bin/perl # (use a unix/linux style shebang line, # because someday you will want to use a unix/linux system) use strict; my $reqd_param_count = 2; # (e.g. two file names) if ( ! @ARGV ) { # prompt for interactive input of required parameter(s) ... } elsif ( @ARGV == $reqd_param_count ) { # invoked from an interactive shell: required params are in @ARGV ... } else { die "Usage: $0 arg1 ...\n"; }
    But seriously, there ought to be a sensible way to set things up so that a user can easily invoke a perl script with args (that will go into @ARGV). If not, just please switch to some sort of GUI approach (Tk, wx, etc), or else get cozy with using a CLI shell ("bash" is available for windows, and is the best, IMHO).
      How would I go about implementing that code?
Re^3: MD 5 hash comparison/checker
by ikegami (Patriarch) on May 07, 2010 at 04:00 UTC
    Command line tools are more useful when they accept file names from the command line.
    perl compare.pl file1 file2

    But if you prefer to prompt the user, feel free to adjust at will.