in reply to Re: How to split a string
in thread How to split a string

Is there a way in a-future-language to slice a string (say '1029') into serialized variables and end up with

f_zero = 1; f_one = 0; f_two = 2; f_three = 9;

*grin*

Replies are listed 'Best First'.
Re^3: How to split a string
by Aristotle (Chancellor) on Jan 28, 2005 at 21:03 UTC

    Obviously…

    my @numword = qw( zero one two three four five six seven eight nine te +n ); my $i = 0; ${ "f_" . $numword[ $i++ ] } = $_ for split //, $string;

    Nevermind the fact that you can vandalize the symbol table to put things in it with whose names don't conform to identifier rules, such as ${ '[ ha ha ha ]' } = 1;.

    Makeshifts last the longest.

      Perl has identifier rules? I never knew.

        Variable and function names must match \w+ and must begin with a non-digit.

        Makeshifts last the longest.