Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Help with Regular Expressions and Perl

by Punitha (Priest)
on Apr 01, 2010 at 04:20 UTC ( [id://832197]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://832197]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-19 14:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found