Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Help with Regular Expressions and Perl

by Punitha (Priest)
on Apr 01, 2010 at 04:20 UTC ( #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


Comment on Re: Help with Regular Expressions and Perl
Select or Download Code
Re^2: Help with Regular Expressions and Perl
by afoken (Parson) 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
Node Status?
node history
Node Type: note [id://832197]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2014-12-25 02:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls