in reply to !~ /\w/ challenge, anyone?

perl -ne}{$./'' file

Update: Jeffa pointed out that for the above to work on *nix, you need to single quote the whole thing, which in turn means switching the single quotes to double quotes like this:

perl -ne'}{die$./""' file

A variation on thelenm's theme below

On Win32:perl -pe"}{*{'['|']'}=*."

On *nix: perl -pe'}{*{"["|"]"}=*.' file


Examine what is said, not who speaks.

The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.

Replies are listed 'Best First'.
Re: Re: !~ /\w/ challenge, anyone?
by John M. Dlugosz (Monsignor) on Feb 05, 2003 at 20:14 UTC
    Very clever: it avoids both an explicit print or the $_ variable by generating an error instead, that happens to state the result within the message.