been really struggling here.... probably a dumb approach
so I have 3 files, file1,file2,file3 generated by filehandles over ssh. File are written on local machine and contain CSV data coming from 6 nodes (need to stay like this). My script works but I am trying to optimize with a foreach loop on each of the files rather than hard coded for each.
so I have this array:
@FILES = ( 1, 2, 3 );
foreach $FILE (@FILES) {
# Open filehandle tailing file written by ssh<br><br>
open ( ${fh.$FILE}, "tail -f file$FILE |") || die "can't open file$
+FILE";
while ( ${line.$FILE} = ${fh.$FILE} ) {
# Here I do my split on the CSV line and assign to arrays (keepi
+ng the
# $FILE value as a suffix to the array name)<br><br>
@{fields.$FILE} = split(/,/,${line.$FILE});
push @{AAA.$FILE}, ${fields.$FILE[0]};
# .....
The issue I have is that ${line.$FILE} does not seem to be filled by the filehandle, I get the mem address (GLOB(0x563b358e1060) for example).
any help greatly appreciated!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.