Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2023-12-10 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (38 votes). Check out past polls.

    Notices?