Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Find a file with same name but different extension

by toolic (Bishop)
on Sep 24, 2013 at 14:06 UTC ( #1055501=note: print w/ replies, xml ) Need Help??


in reply to Find a file with same name but different extension

With lots of assumptions...

use warnings; use strict; use File::Basename qw(fileparse); use File::Slurp qw(slurp); for my $fin (glob '*.in') { my $fout = (fileparse($fin, qr/\.in/))[0] . '.out'; my @ins = slurp($fin); my @outs = slurp($fout); my $id_in = (split /\s+/, $ins [3])[5]; my $id_out = (split /\s+/, $outs[1])[4] . '0'; if ($id_in eq $id_out) { print "match\n"; } else { print "no match\n"; } }


Comment on Re: Find a file with same name but different extension
Download Code
Replies are listed 'Best First'.
Re^2: Find a file with same name but different extension
by Lotus1 (Chaplain) on Sep 24, 2013 at 19:54 UTC

    This seems like a good place to use Tie::File instead of File::Slurp since you only need the first few lines of the files.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2015-08-28 12:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (336 votes), past polls