Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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
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: (11)
As of 2015-07-06 10:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (71 votes), past polls