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?

Read `perldoc perlintro` first. Use `perldoc -q keyphrase`.


Maybe there should be a Oneliner module:

  perl -MOneliner,a=double_space_a_file -wpe'1' infile

;)

-- 
Affijn, Ruud

"Gewoon is een tijger."



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to