in reply to •Re: Editing Files In Place
in thread Editing Files In Place

Oooh purdy. It'd always bugged me that one "had" to use -i. It's bit unfortunate you have to go the whole ARGV/STDIN route, but that's better than forking. thanks!

--
perl -pew "s/\b;([mnst])/'$1/g"

Replies are listed 'Best First'.
•Re: Re: •Re: Editing Files In Place
by merlyn (Sage) on Jun 13, 2002 at 00:16 UTC
    the whole ARGV/STDIN
    Excuse me? There's no use of STDIN in that program. An empty diamond is the same as <ARGV>, not <STDIN>.

    And beginning Perl hackers who confuse the two will eventually get burned. My rule is to never use <> (aka <ARGV>) if you ever print some kind of prompt, and I flunk any use to the contrary in code review. Work it out for yourself to see why. The proper use for interaction where you prompt and read input is <STDIN>.

    -- Randal L. Schwartz, Perl hacker

      Well yes, I new it was the ARGV filehandle, but I tend to think of waka waka as STDIN. If @ARGV is empty waka waka reads from STDIN.

      (I'd even contemplated writing magic ARGV but decided against it ;-)

      --
      perl -pew "s/\b;([mnst])/'$1/g"

        but I tend to think of waka waka as STDIN
        And that's exactly the kind of thinking I'm arguing against.

        The empty angle-brackets have precisely one function: to be used to process the files specified on the command line to create a filter written in Perl. That it happens to read standard input if no filenames are specified or if a lone dash is included, is merely a special case, not the typical case. So, I'm working everywhere to kill the bad memes, and yours is an example of that.

        -- Randal L. Schwartz, Perl hacker