Dr.Ruud wrote:
Chandru schreef:
Prabu:
I am a perl user as well as i works on some sed scripts.I am also a
subscriber of "sed-users".In that list,people maintain the sed
one-liners in the name.
"HANDY ONE-LINERS FOR SED"
People in the list will get a mail regularly with the one-liners in
the name.We can also maintain some perl-one liners in our list and
someone good in perl can contribute to the one-liner and this can be
send to the list regularly("HANDY PERL ONE-LINERS ").So that it
helps perl users a lot.
Thats what I am also looking for...
If moderator accepts we can keep updating the one-list. It'll be
useful for most of the perl users...
We could start with converting that file to Perl:
----------------------------------------------------------------------
---
HANDY ONE-LINERS FOR SED (Unix stream editor) Apr. 26,
2004 compiled by Eric Pement - pemente[at]northpark[dot]edu
version 5.4 Latest version of this file is usually at:
http://sed.sourceforge.net/sed1line.txt
http://www.student.northpark.edu/pemente/sed/sed1line.txt
This file is also available in Portuguese at:
http://www.lrv.ufsc.br/wmaker/sed_ptBR.html
FILE SPACING:
# double space a file
sed G
perl -wpe '$_.=$/'
perl -wpe '$\=$/'
perl -wpe 'BEGIN{$\=$/}'
perl -wne 'print qq{$_$/}'
Check each thus:
perl -MO=Deparse -wpe 'BEGIN{$\=$/}'
BTW, it can be hard to find out what O=Deparse does.
I remember going from `perldoc O` to `perldoc perlcompile`
to `perldoc B`, to `perldoc perltoc` and searching for Deparse,
to finally finding `perldoc B::Deparse`.
# double space a file which already has blank lines in it. Output
file # should contain no more than one blank line between lines of
text.
sed '/^$/d;G'
perl -wne 'BEGIN{$\=qq/\n/};print unless /^$/'
# triple space a file
sed 'G;G'
perl -wpe 'BEGIN{$\=qq{$/$/}}'
etc.
But would this help beginners much? Maybe a different style, a different
set of basic operations?
It may not help Perl Beginners much.But will give some short and cute
solution to some problems.Yes,we can have a different style, of basic
operation
For Example:
To validate an e-mail Id in a single line.([EMAIL PROTECTED])
perl -ne 'print "valid\n" if $_ =~ /[EMAIL PROTECTED]/ ;' /dev/stdin
To print line other than this one(5th one)
perl -ne 'print "$_" if $. != 5' filename
so can make a good one-liner list.
--
Prabu.M.A
When I was born I was so surprised
I didnt talk for a period and half
-Gracie Allen
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>