in reply to What is causing sha1 system call to fail to redirect?
For future reference (as you already have the answer from roboticus), here's a basic debugging technique which can open your eyes to the effects that unexpected data can have on your code: Display what you have, not what you think you have.
Example: Your approach to displaying the information:
print "Preforming sha1 on $file"; system( "sha1sum $file > data" );
Produces:
Preforming sha1 on test1.dat
This is fine for human user display, but for programmer debugging display, you've left yourself open to a number of "dirty screen tricks". Instead:
my $systemCommand = "sha1sum $file > data"; print "\$systemCommand = [$systemCommand]\n"; system( $systemCommand );
Produces:
$systemCommand = [sha1sum test.dat > data]
Notice how the newline jumps out at you when displayed this way.
I would be remiss to not note that there are two modules folks love to use which might also reveal these problems and more -- Data::Dumpand Data::Dumper. I've seen the effectiveness at these modules helping Monks zero in on a user's issues as if they were painted with red Xs. I highly recommend their use whenever you want to peek at your data in more depth.
|
|---|