This parses the data, I read it from the script for ease, you can uncomment your lines to read from the file again. If you have many folders it is probably better to make an array @folder to store the values for each one.

Printing out to a file should be easy enough, open the file to write (> to start afresh, >> to append) and just print to the filehandle.

I assume the strings will be an exact match here, if case or spacing vary you may be better of with a regex in the tests, for instance if ($what=~/Main\s+folder\s+name/i) will allow variable spacing and case.

#!/usr/bin/perl use warnings; use strict; my ($log_file, $folder_1, $folder_2, $folder_3); # open INFO_FILE "<D:\\prad\\test\\info.txt"; # while<INFO_FILE>{ while (<DATA>) { next unless /:/; # ignore lines without the : seperator chomp; # remove new line characters my ($what, $data)=split ":"; if ($what eq "Log_file_name") { $log_file=$data; } elsif ($what eq "Main folder name") { $folder_1=$data; } elsif ($what eq "Second folder name") { $folder_2=$data; } elsif ($what eq "Third folder name") { $folder_3=$data } } # close INFO_FILE; print "in file: $log_file, I found folders $folder_1, $folder_2, $fold +er_3\n"; __DATA__ Log_file_name:XXXX.csv Main folder name:Eitv9 Second folder name:Eitv9cmd_cln Third folder name:Eitv9gsd_cln

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

In reply to Re^3: Reading something which is next to it : by Random_Walk
in thread Reading something which is next to it : by prad_intel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.