http://www.perlmonks.org?node_id=832197


in reply to Help with Regular Expressions and Perl

Hi vc859,

The syntax for 'join' is:

join EXPR,LIST

So your code should be

$variable = join("\n",@variable = <INFILE>);

Punitha

Replies are listed 'Best First'.
Re^2: Help with Regular Expressions and Perl
by afoken (Chancellor) on Apr 01, 2010 at 19:29 UTC

    Just a small note: Using slurp mode is usually far more efficient than join()ing a temporary array or list.

    $variable=do { local $/=undef; <INFILE> };

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^2: Help with Regular Expressions and Perl
by amedico (Sexton) on Apr 03, 2010 at 23:44 UTC
    Although the questioner probably does not want to be using join here at all - reading the file via <INFILE> does not remove the file's newlines, so there is probably no need to be adding more.