Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

need urgent help for

by Anonymous Monk
on Jan 14, 2013 at 12:21 UTC ( #1013203=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear All perl monks i am very new to perl i need help in creating a file name based on values from a file lets say column3 will be my file name which will again appear in another file

file1 adb xyz pqr adl ads pqr ert wer pqr output file name : pqr & data: adb xyz pqr adl ads pqr ert wer pqr

Comment on need urgent help for
Download Code
Re: need urgent help for
by Anonymous Monk on Jan 14, 2013 at 12:28 UTC
Re: need urgent help for
by Corion (Pope) on Jan 14, 2013 at 12:30 UTC
Re: need urgent help for
by parv (Priest) on Jan 14, 2013 at 12:40 UTC

    1. open file ("file1") to read;
    2. read a line;
    3. split it in 3 parts on white space;
    4. save results in an array;
      1. open the file name given by last array element ("pqr");
      2. write the array content to the file;
      3. close the file.
    5. repeat 2 until whole file is read;
    6. close the file.

    Alternatively, if the last element of the lines being does not ever change, you would need to split the line only once and could open and close the file handle being written to outside of the loop, and read & write in consecutive statements.

    Another variation could be is to save the file being read in a variable and write the value of that variable after everything has been read.

      OK -- now we're getting somewhere. What Perl code have you written to implement that algorithm?

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

        parv isn't the OP. :P

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1013203]
Approved by davido
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: (9)
As of 2014-10-02 18:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (69 votes), past polls