in reply to Re^2: Is it possible to split a hash key?
in thread Is it possible to split a hash key?

... The difference is that the regex is not the string itself (/ /) but /\s+/

...not to forget the subtle, additional magic of ' ' vs. /\s+/ in the handling of leading whitespace. Compare

my $s = " foo bar baz"; print join("|", split /\s+/, $s), "\n"; # prints |foo|bar|baz print join("|", split ' ', $s), "\n"; # prints foo|bar|baz

Replies are listed 'Best First'.
Re^4: Is it possible to split a hash key?
by Anno (Deacon) on Jul 29, 2007 at 13:23 UTC
    ...not to forget the subtle, additional magic of ' ' vs. /\s+/ in the handling of leading whitespace.

    Oh right, that too. split() is too clever for its own good by half.

    Anno

      Gee, see I thought most people would learn that one exception because it's the most useful mode for "text."

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊