http://www.perlmonks.org?node_id=534376

I don't know how usefull this will be to anyone. It's rather obscure. Perldoc -f split says:

As a special case, specifying a PATTERN of space (’ ’) will split on white space just as "split" with no arguments does.  Thus, "split(’ ’)" can be used to emulate awk’s default behavior, whereas "split(/ /)" will give you as many null initial fields as there are leading spaces.  A "split" on "/\s+/" is like a "split(’ ’)" except that any leading whitespace produces a null first field.  A "split" with no arguments really does a "split(’ ’, $_)" internally.

That reads like stereo instructions. I think I understand it but it appears that B::Deparse is having problems with it:

#!/usr/bin/perl -w $string = ' abc def '; @array1 = split " ", $string; @array2 = split ?\s+?, $string; print '2: ' . ( join '|', @array1 ) . "\n"; print '3: ' . ( join '|', @array2 ) . "\n";

Run it through deparse and you get:

BEGIN { $^W = 1; } $string = ' abc def '; @array1 = split(?\s+?, $string, 0); @array2 = split(?\s+?, $string, 0); print '2: ' . join('|', @array1) . "\n"; print '3: ' . join('|', @array2) . "\n";

Run this script and you get the following output:

2: abc|def 3: |abc|def

This caused me to not trust Deparse quite so much. I'm going to be a little more careful about trusting what Deparse spits out.

Harley J Pig