translate this send into perl

Discussion in 'Perl' started by sfgroups@gmail.com, Mar 16, 2005.

  1. Guest

    How will I do this in perl?


    print 1 line of context before and after regexp, with line number
    # indicating where the regexp occurred (similar to "grep -A1 -B1")
    sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h

    Thanks
    Sundaram
    , Mar 16, 2005
    #1
    1. Advertising

  2. Red Guest

    wrote:
    > How will I do this in perl?
    >
    > print 1 line of context before and after regexp, with line number
    > # indicating where the regexp occurred (similar to "grep -A1 -B1")
    > sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h


    See the documentation for s2p: perldoc s2p
    I think this will do what you want.

    Regards,
    Rob.
    Red, Mar 16, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marat
    Replies:
    5
    Views:
    3,759
    John C. Bollinger
    Nov 10, 2004
  2. mike
    Replies:
    3
    Views:
    476
    Thomas Weidenfeller
    Jan 24, 2005
  3. Replies:
    2
    Views:
    5,679
    Hal Rosser
    Jun 25, 2005
  4. Greg N.
    Replies:
    8
    Views:
    530
    Neredbojias
    Jul 28, 2005
  5. A.Hanemann
    Replies:
    4
    Views:
    502
    Gerald Aichholzer
    Aug 23, 2005
Loading...

Share This Page