in reply to How to split a string

Well, generally, you may be better using an array. This can be done quite easily with:

@f = split //, $s; # Now, each char is in $f[0], $f[1], etc.

If you absolutely must have seperated variables, you would have to venture into symbolic dereferencing <insert standard security warnings here>.

my $i = 0; ${'f' . $i ++} = $_ for split //, $s

This code is untested, but should work ;-)

Ted Young

($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)

Replies are listed 'Best First'.
Re^2: How to split a string
by Red_Dragon (Beadle) on Jan 28, 2005 at 21:38 UTC
    Thank you for generously considering my question and providing an elegant solution,

    I had already tried the array form as a solution, but it was inadequate for my purposes due to my limited understanding of Perl.

    The string in question is extracted from an SQL table. The values placed in serialized variables are used as flags that govern print statements. Properly deployed they will allow granular control over what is written to a logfile without having to alter Perl code. All adjustments can be made by changing the control string in the SQL table.

    Thanks again, I truly appreciate your input.

    R_D