Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: difference between two files

by kcott (Archbishop)
on Dec 20, 2013 at 06:44 UTC ( [id://1067921]=note: print w/replies, xml ) Need Help??


in reply to Re: difference between two files
in thread difference between two files

While not a bad solution (I gave it an upvote), here's a couple of points to consider:

  • You've added two blank lines between the __DATA1__ and __DATA2__ blocks. As a result, you've needed the "$#file1 - 1" calculation.
  • I think using splice here is overkill: a simple array slice would suffice.

Putting those two points into effect:

#!/usr/bin/env perl use strict; use warnings; use Inline::Files; my @file1 = <DATA1>; my @file2 = <DATA2>; print for @file2[@file1 .. $#file2]; __DATA1__ hi 1 hw r u hi 2 hw r u __DATA2__ hi 1 hw r u hi 2 hw r u hi 3 hw r u

Output:

hi 3 hw r u

-- Ken

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-03-28 22:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found