[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Who can make this script smaller?



On Thu, 7 Jan 1999, William Chesters wrote:

> perl -0e '$_=<>;print"$&
> "while/<A[^<]*<\/A>/gsi'

	Hmmm ... I don't understand it O:-)

	Let's see: if we put in one-liner, it's:

	perl -0e '$_=<>;print"$& "while/<A[^<]*<\/A>/gsi'

	"-0e" is a perl parameter, so it must be in the man page :-)
	"$_" is a special variable in Perl, but I don't remember which O:-)
So I don't know exactly what it does. What I know is that with "$_=<>;" you
open standard input and put it in the $_ array, isn't it?
	Then, the 'print "$&"while/<A[^<]*<\/A>/gsi' prints the contents of
the $& variable, which I guess is each line of the array $_. And I guess
that the "while" statement after the print makes that only lines matching
the regular expression between the bars are to be printed. The 'gsi' at the
end are regular sed parameters.

	Well, what did I miss, what am I wrong at? My Perl knowledge would
be quite improved if I knew that :-)

--
Roberto Suarez Soto            |         Hard work has a future payoff.
ask4it@biosys.net              |             Laziness pays off now.
Corgo - Lugo - Galicia - Spain |

-
European Universities' Linux User Groups -- Misc list
http://humbolt.geo.uu.nl/eulug/