in reply to Path to enlightment

perldoc perlre
perldoc -q strip

Cheers,
KM

Replies are listed 'Best First'.
Re: Re: Path to enlightment
by arturo (Vicar) on Jan 23, 2001 at 23:29 UTC

    OK, I ++'d KM for his answer, since it gives what was asked for -- a hint. Slightly more than a hint:

    # FILE is open for read, OUTPUT is open for writing while (<FILE>) { s/^(\d+:)//; # take $_, replace one or more # digits at the beginning of the line #followed by a : with #nothing print OUTPUT; }

    Note: that may not be exactly what you want; for how to change it, see KM's first reference. 'Course, there's some one-liner goodness to be had here too (you can do this on the command line with one -- albeit complex -- command. For that, see:

    perldoc perlrun

    Specifically, the -p switch).

    Good luck!

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

      s/^(\d+:)//;

      Minor nit.. you don't need to do the grouping. And, although he didn't say it he may also want the whitespace removed after the colon.

      s!^\d+:\s+!!;

      Cheers,
      KM

        s!^\d+:\s+!!o;
        I added the o modifier, since the pattern doesn't change, may as well compile it once for the loop.

        The o modifier is a no-op on a regex that doesn't contain any interpolated variables, BTW.

                - tye (but my friends call me "Tye")
        The 'o' modifier on your regexp is useless as it applies to regexp's that contain variables in them. From the Camel

        PATTERN may contain variables, which will be interpolated (and the pattern recompiled) every time the pattern search is evaluated....mentioning /o constitutes a promise that you won't change the variables in the pattern. If you do change them, Perl won't even notice.
Re: Re: Path to enlightment
by extremely (Priest) on Jan 24, 2001 at 04:06 UTC
    Hey KM you can link up the documentation like this:
    perldoc perlre

    Which I did with [perlman:perlre|perldoc perlre]. I think it is cool, anyway...

    Update Hmm, KM has a very valid point below... /me ponders

    --
    $you = new YOU;
    honk() if $you->love(perl)

      Hey KM you can link up the documentation like this:

      I have said in the past, no :) Why? I think you should view the documentation provided with your installed version of Perl. But, if I remember to next time, maybe I will.

      Cheers,
      KM