Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^6: Compare three columns of one file with three columns of another file in perl

by anonym (Acolyte)
on May 26, 2015 at 05:04 UTC ( [id://1127764]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Compare three columns of one file with three columns of another file in perl
in thread Compare three columns of one file with three columns of another file in perl

Hey thanks.The code i sent works with the other pair of input files. I guess there is no line common between file1.txt and file2.txt that is why it does not print anything.

  • Comment on Re^6: Compare three columns of one file with three columns of another file in perl

Replies are listed 'Best First'.
Re^7: Compare three columns of one file with three columns of another file in perl
by aaron_baugher (Curate) on May 26, 2015 at 17:19 UTC

    You're welcome, you did a good job of turning my pseudo-code into working code!

    One suggestion: don't create variables outside a loop if they're only used within the loop. So your @array1 can be instantiated inside your first loop, like this:

    my @array1 = split (" ", $_);

    Same thing with @array2, $str, and $string. The way you're doing it will work, but it may introduce bugs in more complicated code, because those variables will continue to exist after those loops are finished, and could conflict with other uses elsewhere. It's best to keep variables inside as small a context as possible, so only create them outside a loop if you need them to continue to exist after the loop is finished.

    Aaron B.
    Available for small or large Perl jobs and *nix system administration; see my home node.

      Thanks Aaron for your suggestions and help. Thanks so much.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-24 21:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found