Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Array Manipulation

by Jalcock501 (Sexton)
on Oct 08, 2013 at 08:41 UTC ( [id://1057377]=note: print w/replies, xml ) Need Help??


in reply to Re: Array Manipulation
in thread Array Manipulation

Hi Kcott

There's not a lot to do to be fair, I need to remove the extension because I have files with the same name but different extensions. I'm trying to read them in and compare the different files. So I thought if I remove the extension in the array I can do something like this

#! /usr/bin/perl -w my @files= <*.in> for (@files) { remove extension } for my $file (@files) { open (IN, "<", "$file.fo") || die ("cannot open $file.fo"); open (OUT,"<", "$file.bo") || die ("cannot open $file.bo"); undef $/; my $in = <IN>; my $out = <OUT>; my @in = split /\n/, $in; my @out = split /\n/, $out; my @final; for $a (@in) { my @result = grep/^\Q$a\E$/, @out; push (@final , @result); } print "Search string that matches against general data:\t@final"; }
I hope this makes a little more sense.

Replies are listed 'Best First'.
Re^3: Array Manipulation
by kcott (Archbishop) on Oct 08, 2013 at 09:07 UTC
    "There's not a lot to do to be fair, ..."

    My comment, "That's very little to go on.", was written before you updated your OP and added code. I updated my initial response after you added code to your OP.

    Based on the limited information you initially provided, by first response involved a certain amount of guesswork. Once you had provided some code, I was able to provide a much better answer: including pointers to where you went wrong and references to supporting documentation.

    So, had you provided your code initially, you wouldn't have needed to update your post or respond to my post (except, perhaps, to say thankyou). Similarly, I would only have needed to post once, instead of three times.

    There are distinct benefits to following the guidelines in "How do I post a question effectively?". Hopefully, this exercise has highlighted that.

    -- Ken

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-19 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found