in reply to what is the best way to seperate the digits and strings from variable ?

Actually, I think it's worth mentioning that if you want only the digits in the beginning of the string you can do something like this:

$variable = '12345(checkthis)'; $variable += 0;

That numifies $variable, which happens to exclude everything starting from the first non-digit character.

Other (twisted) ways of doing the same would include the spacestation:

$variable = -+- '12345(checkthis)';

If, OTOH, you really want all the digits, regardless of them being in the beginning of the string, or even of them being together or separated by other chars, you can always use some silly regexen twisting such as:

$variable = join '', "12345(checkthis)" =~ /\d*/g;

Replies are listed 'Best First'.
Re^2: what is the best way to seperate the digits and strings from variable ?
by Roy Johnson (Monsignor) on May 09, 2005 at 15:53 UTC
    That last is probably better written as
    ($variable = '12345(checkthis)') =~ tr/0-9//dc;

    Caution: Contents may have been coded under pressure.
      I said "silly regexen twisting". I was meaning to show that there are a bunch of ways to do it (slightly off-topic, I know, but still worth mentioning).