in reply to Re^2: Split without removing characters
in thread Split without removing characters

Whilst a good point, it would have been helpful to add that a character other than a pipe character could be substituted, thereby avoiding the problem whereby $foo comes with embedded pipe characters. In fact you could use a complex string which you feel is almost guaranteed not to occur!

e.g.

my $sepstring = '7c6xb1%$#!@#$!@'; my $foo = "Hello WorldFoo BarPerl MonksSlash Dot"; for ($foo) { s/([a-z])([A-Z])/$1$sepstring$2/g; for (split /\Q$sepstring\E/ ) { print "$_ \n"; } }

Replies are listed 'Best First'.
Re^4: Split without removing characters
by cmeyer (Pilgrim) on Jun 20, 2005 at 18:35 UTC

    I wonder why you defend an approach that is more complex, less efficient, and prone to a problem that is "almost guaranteed not to occur", when there is a simple approach that is guaranteed not to have such a problem?

    -Colin.

    WHITEPAGES.COM | INC