> >-----Original Message----- >From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] >Sent: Tuesday, March 21, 2006 1:36 PM >To: beginners perl >Subject: Re: regex one liner > >Timothy Johnson wrote: >> We run into one of these "How do I do this in a one-liner?" questions >> pretty frequently, and I for one have to ask, what exactly makes the >> one-liner so compelling, especially when you are using it for something >> that will be run repeatedly? > >Because you can use them in aliases: > > alias pcalc='perl -ple '\''BEGIN{use Data::Dumper}$_=eval'\''' > >See `man alias` for details.
And you can't do this? alias pcalc='perl ~/pcalc.pl' And as for the issue of slightly varying regexes as arguments to a script (different email), it may seem easier to you, but not necessarily to the next guy that comes along. Obviously you aren't required to take other people into account when designing your scripts, but I always try to. By simply moving the part that always changes to an argument you give yourself the same flexibility and ability to use the history while at the same time leaving a trail in case you get hit by a truck and someone else needs to step into your shoes temporarily. And you never know; the person who needs to figure out what you did may end up being you. Obviously I'm not saying that it's wrong to do it, but IMHO it's worth the small bit of extra time up front, and Perl gives you all the tools needed to meet your requirements without having to cram it all into one line. That being said, if I have the time and anyone has a question, I'll be happy to try to help. I don't want to discourage anyone from expanding their knowledge. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>