Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

RE: RE: Re: script adding spaces into a file for no reason...

by httptech (Chaplain)
on May 20, 2000 at 04:35 UTC ( [id://13827]=note: print w/replies, xml ) Need Help??


in reply to RE: Re: script adding spaces into a file for no reason...
in thread script adding spaces into a file for no reason...

My solution, @{[join("",@text)]} does not return an array in this case. (Look at pg.239-241 of Effective Perl Programming for more examples of using this construct). It does use the anonymous array construct and the array dereferencing construct, but the net result is to interpret the code inside the brackets in whatever context it would have occured elsewhere outside of the constuct and the here-doc. So, because "join" returns a scalar, so does my code. It's just a quick and dirty way to interpolate a piece of code inside a larger print statement.

Of course, there are many other ways you could accomplish the same thing, I just happen to like this because it keeps the amount of variable assignment to a minimum.

Replies are listed 'Best First'.
RE: RE: RE: Re: script adding spaces into a file for no reason...
by Anonymous Monk on May 25, 2000 at 00:09 UTC
    Thanks to everyone for their help. It's working now. Here's the core file saving code for your reference. It removes unncessary line returns, etc.

    if (defined $query->param('Submit')) { open NEWNEWS, "> cgi/news.txt" || die "Cannot open file: $!"; $result = $query->param('content'); $result =~ s/\r//g; print NEWNEWS $result; close(NEWNEWS); print '<p>Saved your changes.</p>'; $query->delete('Submit'); }


    JoeG

Log In?
Username:
Password:

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

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

    No recent polls found