Jeff 'Japhy' Pinyan wrote:
>
> On Nov 4, Raghu Murthy said:
>
> >#!/usr/bin/perl
> >
> >use strict;
> >use warnings;
> >
> >my $result;
> >$result = system("cksum foo.c | cut -d ' ' -f2");
> >chomp $ckresult;
> >print "$ckresult\n";
>
> I doubt you did that; $result and $ckresult aren't the same.
>
> >Cksum returns an exit status of 0 if successful. This script gives out the
> >exit status. How can I remove the exit status from the script.
>
> The system() function executes a program, and returns the EXIT STATUS. It
> does NOT return the output. If you want the output to be returned to a
> variable, use backticks or then open() function:
>
> my $result = `cksum foo.c | cut -d ' ' -f2`;
>
> >Is there an alternate way to do it using unpack. Any help would be
> >appreciated.
>
> Yes. Read 'perldoc -f unpack', and you'll see there's code for computing
> a checksum:
>
> while (<>) {
> $checksum += unpack("%32C*", $_);
> }
> $checksum %= 65535;
Thanks Jeff.
/R
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]