Perhaps I'm missing something but I don't think that's going to work. Firstly, shouldn't the file read be outside the map? Seems to be a syntax error with it inside. Secondly, with the read in the right place all that gets passed to the print statement is the result of the chomp so you just pass a series of 1s to the socket. Thirdly, the lines passing through the map are not going to be interpreted as separate records so the lines will all get concatenated with a single "\r\n" at the end.

Perhaps something along these lines would be better? (I've used "XX" instead of "\r" for visibility).

use strict; use warnings; print map { chomp; qq{$_ XX\n} } <DATA>; __END__ line 1 line 2 line 3

and the output

line 1 XX line 2 XX line 3 XX

If you do use English; it is a good idea to specify the -no_match_vars option to avoid a performance hit on all regexen in your script.

# Avoid performance hit on regexen by specifying # -no_match_vars. # use English q{-no_match_vars};

I hope this is of interest.

Cheers,

JohnGG


In reply to Re^2: print list to socket by johngg
in thread print list to socket by yesterday

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.