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

Re^2: Looking up elements of an array in another array!

by better (Acolyte)
on Mar 14, 2013 at 23:38 UTC ( #1023580=note: print w/ replies, xml ) Need Help??


in reply to Re: Looking up elements of an array in another array!
in thread Looking up elements of an array in another array!

Hello Kenosis,

thanks a lot for your help. Unfortunately it doesn't help. The last entry (>outFile) causes an error. But if I skip that, nothing happens. (But the Ids given in indexDS.txt are matching filenames of the scanned directory) Any suggestions?

better


Comment on Re^2: Looking up elements of an array in another array!
Re^3: Looking up elements of an array in another array!
by kielstirling (Scribe) on Mar 15, 2013 at 00:18 UTC
    replace the [>outFile] with >outFile ... this is redirecting stdout to the file outFile in the current directory.
Re^3: Looking up elements of an array in another array!
by Kenosis (Priest) on Mar 15, 2013 at 02:06 UTC

    kielstirling ++ is right on target, and my apologies for not explaining the [>fileOut] parameter. This designates an optional argument that's used to direct output to a file, instead of the screen. So, for example, you could do the following on the command line:

    perl script.pl '/the/dir/to/scan' indexDS.txt >results.txt

    Thus, instead of printing to the screen, output's directed to a file. Omitting the last parameter will just print the results to the screen.

      Thanks again, Kenosis. Yes, indeed. Entering the third option without brackets, does create a text file, but without any results(?) The files, I am looking for, however do exist in the directory. So they should be found.

      Hmm.. If I get the two arrays (@ds and @dirFile) in my script listed, I can see that grep /$line/ should find the matching elements in the second array. But @results keeps beeing empty. The funny thing is: if I define @ds writing some of the wanted IDs directly into the script

       @ds = ("I C 7702", "I C 7710");

      the script works perfectly. But I want the array filled by reading a long list of IDs from a text file. Any idea what is going wrong?

        Hi better,

        The files, I am looking for, however do exist in the directory. So they should be found.

        To start with Kenosis' script should work. I tried it, using your description of the problem you posted and I have outputs, though similar filenames which were not included in the "indexDS.txt" were also printed.

        Secondly, how are you using the script, maybe you have some other code over-writing the variable "@result"
        Hope this helps.

        If you tell me, I'll forget.
        If you show me, I'll remember.
        if you involve me, I'll understand.
        --- Author unknown to me

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (14)
As of 2014-09-22 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (192 votes), past polls