Trim whitespace with cookbook recipe does not result in trimmed array

J

John W. Krahn

Paul said:
Why are you using four lines when two will do? More explicitly, why
are you forcing Perl to do all these consecutive reads and
substitutions? Why not just one?

my $file = do { local $/; <DATA>};
$file =~ s/\s+//g;

That is two lines! (Yes I can count :)

( my $file = do { local $/; <DATA> } ) =~ s/\s+//g;



John
 
U

Uri Guttman

JWK> That is two lines! (Yes I can count :)

JWK> ( my $file = do { local $/; <DATA> } ) =~ s/\s+//g;

i will use more code but do it much faster!

use File::Slurp ;

(my $text = read_file( \*DATA ) ) =~ tr/ \r\n\t//d ;

uri
 
P

Paul Lalli

John said:
That is two lines! (Yes I can count :)

The "one" referred to the number of reads and substitutions, John. If
you re-read the first sentence, you'll see where it says "two will do".

Paul Lalli
 
T

Tad McClellan

SomeDude said:
Describe *precisely* the input to your program. Also provide example
input data for your program. If you need to show file input, use the
__DATA__ token (perldata.pod) to provide the file contents inside of
your Perl program.

I don't think that was well written.


Then rewrite it, post it here for discussion, and I'll put
your better version into the guidelines.
 
T

Tad McClellan

SomeDude said:
Or modify the Posting Guidelines.


Post your rewritten version and if it passes discussion, then
it will be incorporated into the guidelines.

The way
it's written would get one to flunk essay writings in college.


That isn't relevant, as the guidelines are not an essay!

If you have any constructive criticism, I would like to see it.

IT's called communicating clearly,


Show me how you would clearly communicate it.

and it goes a long, long way in
corporations and other well-paying jobs.


I do happen to be pretty well-paid. Thanks for noticing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top