in reply to how to split string(many words in one line) in a word?

I quite like this version (though I'd not submit it as a homework answer):

$_ = "The quick brown (it's a slightly reddish brown) fox jumps over t +he lazy dog"; split; print join "\n", @_;

Same output as BrowserUK's code purports to give.


Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^2: how to split string(many words in one line) in a word?
by LanceDeeply (Chaplain) on Oct 07, 2005 at 01:57 UTC
    tmtowtdhw :)
    my $string = "The quick brown (it's a slightly reddish brown) fox jump +s over the lazy dog"; my $words = join '', map { ( / / ) ? "\n" : $_ ; } split '', $string ; print "$words" ;
Re^2: how to split string(many words in one line) in a word?
by holli (Abbot) on Oct 07, 2005 at 06:57 UTC
    gives Use of implicit split to @_ is deprecated at... under warnings;.


    holli, /regexed monk/
Re^2: how to split string(many words in one line) in a word?
by revdiablo (Prior) on Oct 07, 2005 at 14:32 UTC

    Does this smell like the start of an obfu/golf contest? Maybe so!

    echo "The quick brown (it's a slightly reddish brown) fox jumps over t +he lazy dog" \ | perl -nle '$"="\n";print"@{[split]}"'

    Update:

    echo "The quick brown (it's a slightly reddish brown) fox jumps over t +he lazy dog" \ | perl -ple 's/\s+/\n/g'