Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
st4k,
The problem is the way you have your data entered into the files. I can tell that your files look like this:
file1:    file2:    file3:
one\n     four\n    seven\n
two\n     five\n    eight\n
three^Z   six^Z     nine^Z
The ^Z represent the end of file character. So that when you dump the array using:
print @out;
There are no line breaks between three-four and six-seven. To correct this you should chomp each read and store all the data without newlines:
for (my $i = 0; $i < $num; $i++) { print "$ARGV[$i]\n"; open (FH, "$ARGV[$i]") || die "Cant open: $!"; while (<FH>) { chomp; ## <- added this line push @out, lc; } close FH || die "Cant open: $!"; }
To print this as you would expect, use this instead:
print join (@out,"\n");
This tells print to make one long string with a newline inserted between each element of @out.

Hope this helps.

--Jim


In reply to Re: I'm so confused by jlongino
in thread I'm so confused by st4k

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2021-11-27 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?