Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: reg exps
by jmcnamara (Monsignor) on Nov 28, 2002 at 14:19 UTC

    You could use a negated character class for this:     perl -i.bak -pe 's/[^\d.]//g' file

    Refer to perlre and perlrun.

    Or you could use tr, refer to perlop:     perl -i.bak -pe 'tr/0-9.//cd' file

    Add "\n" to the regex or -l to the command line switches to preserve newlines.

    --
    John.

Re: reg exps
by dingus (Friar) on Nov 28, 2002 at 14:18 UTC
    Substitute with what? nothing? Try this:
    open (FILE, "<$fn"); $_ = join('',<FILE>); close(FILE); s/[^\d\.]+//sg; print $_;

    Dingus


    Enter any 47-digit prime number to continue.
Re: reg exps
by ehdonhon (Curate) on Nov 28, 2002 at 14:36 UTC

    This sounds like a homework problem. What have you already tried?