Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Perl script

by madtoperl (Hermit)
on Feb 07, 2017 at 10:34 UTC ( #1181275=note: print w/replies, xml ) Need Help??

in reply to Perl script

since your output is already in two xml files, let's say File 1 is one.xml and File 2 is two.xml.
You can do the below. Also there are other ways also available eg. using File::Stat module as well.
#!/usr/bin/perl use strict; use warnings; my $filesize1 = 0; my $filesize2 = 0; if (-e 'one.xml'){ $filesize1 = -s 'one.xml'; } if ( -e 'two.xml'){ $filesize2 = -s 'two.xml'; } if ( $filesize1 == $filesize2) { print "File sizes are equal\n"; }else{ print "File sizes are not equal\n"; }

Replies are listed 'Best First'.
Re^2: Perl script
by marto (Cardinal) on Feb 07, 2017 at 10:41 UTC

    OP is not trying to compare the size of two XML files, but the value of dataSize within two XML files. While it doesn't address this problem your example should also check that the files exist before allocating a size to them, e.g. my $filesize2 = 0;.

Re^2: Perl script
by Anonymous Monk on Feb 07, 2017 at 16:16 UTC

    Checking -e first is a bad idea, as it leads to race conditions (the file might be deleted between the -e and -s). Just call -s. If it gives undef, the file doesn't exist.

    The OP is so vague that I'm not sure whether "datasize" is a field in the XML or the length of some part of the XML.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1181275]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2023-11-30 06:51 GMT
Find Nodes?
    Voting Booth?

    No recent polls found