Dear Monks,
I have a text file which have a one column listing of file names, the suroutine which is defined for reading the txt file to extract only 8 charecter reports name. Caling the subroutine and assigning it to array variable as in below code when i try to append a path "/efsprod/docmnt" to each file name from array element, it displaying filename and at end i could see the "/test/var/o" as output.
Text file</br> #AAA45S49.${datestamp}.${timestamp}.txt #BBB75SWI.${datestamp}.${timestamp}.txt #YYYYYY.${datestamp}.${timestamp}.txt #XXXXXXX.${datestamp}.${timestamp}.txt #CCCCCCC.${datestamp}.${timestamp}.txt #DDDDDDD.${datestamp}.${timestamp}.txt #EEEEEEE.${datestamp}.${timestamp}.txt #FFFFFFF.${datestamp}.${timestamp}.txt #FFFFFF2.${datestamp}.${timestamp}.txt #GGGGGGG.${datestamp}.${timestamp}.txt #HHHHHHH.${datestamp}.${timestamp}.txt #IIIIIII.${datestamp}.${timestamp}.txt #JJJJJJJ.${datestamp}.${timestamp}.txt
Code I am trying to append the filename to the Path as below
#!/usr/bin/perl @array = &report(); foreach $file(@array) { $path = "/efsprod/docmnt/"; $file = "$path" . "$file"; print "$file"; } sub report() { open(F,"Textfile.txt") or die "$!\n"; while(chomp($line=<F>)) { $line=substr($line,0,9)l $line= reverse($line); chop $line; $line=reverse($line); print "$line\n"; }
Once after succeeding the concatination i need to verify the each file which is existed in "/efsprod/docmnt", if exist i need to copy the file from source "/efsprod/docmnt" to destination directory as current directory from where i am running the script(i.e /tmp/xxx/). The above code just printing the filenames which has been red from the text file and at the end of the o/p displaying as /efsprod/docmnt/0
The o/p i am expecting as $file = /test/var/XXX001 /test/var/...... /test/var/XXX01B #but i am getting o/p as XX001BC YY001BC ...... ...... /test/var/0

In reply to Unable to concatinate a Path to the array elements, which will have the values as return values from sunroutine by perladdict

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.