in reply to Converting to number doesn't always work...
$N =~ tr|[0-9]||cd;
NB: The first field of the tr/// operator (see Quote-Like Operators in perlop) is a search list, and it does not "know" about [...] character classes (the search list is itself a kind of character class), so the [ ] characters are among the "digit" characters which are not deleted.
Don't know about the rest of the question.c:\@Work\Perl\monks>perl -wMstrict -le "my $n = 'abc[]1p2q3][xyz'; $n =~ tr|[0-9]||cd; print qq{'$n'}; " '[]123]['
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Converting to number doesn't always work...
by harangzsolt33 (Deacon) on Nov 22, 2019 at 05:55 UTC |