Heya monks. I'm writing a script to rcp a file from one machine to another and then check the sums after the rcp.
I cant use any modules but the default ones as it takes an act of god/congress/both to get a module installed here. The problem is comparing the files. Here's how i'm doing it now:
#this is hp-ux btw...
my $local_compare="/usr/bin/chksum $file";
my $remote_compare="rexec $host -l $user \"/usr/bin/chksum $file\"";

my $g=`$local_compare`;
my $h=`$remote_compare`;

# output of cksum on hockey-pux looks like
# [num] [num] [filename]
my @gg = split( ' ', $g );
my @hh = split( ' ', $h );
if ( $gg[ 0 ] != @hh[ 0 ] ) { 
die( "files do not match.\n" );
}
I'm sure that there is a better way to do this. Any suggestions?

Also as a side note, I have found myself lately using ? : profusely. I haven't seen this too much in other peoples code lately but mine is littered with them. An example:

my $a = some_func();
$a ? do_something() : do_somethingelse();
This isn't like goto in C is it? I like it because it is compact and looks pretty cool compared to if()/else. Just want to make sure that it's not one of those "That's a really bad idea" things.

Thanks in advance for any and all criticism/tips/crap/etc.


In reply to Comparing checksums of local/remote files. by hydo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.