FAQ
Hi Members,

I am a linux system admin. I want to use perl as a command line like sed
and awk.
For example suppose , i need to extract IP Addr from a string or file using
regrex
i mean
str="hello ip is 192.168.2.1 and data is xxx"
And i want ip addr only using Regex
echo $str | perl -pe ??????

Please guide me,

Search Discussions

  • Shawn H Corey at May 24, 2011 at 12:05 pm

    On 11-05-24 12:10 AM, vishesh kumar wrote:
    Hi Members,

    I am a linux system admin. I want to use perl as a command line like sed
    and awk.
    For example suppose , i need to extract IP Addr from a string or file using
    regrex
    i mean
    str="hello ip is 192.168.2.1 and data is xxx"
    And i want ip addr only using Regex
    echo $str | perl -pe ??????

    Please guide me,
    Download the module Regex::Common from CPAN:
    http://search.cpan.org/~abigail/Regexp-Common-2011041701/lib/Regexp/Common.pm

    The pattern Regex::Common::net matches IPv4 addresses.


    --
    Just my 0.00000002 million dollars worth,
    Shawn

    Confusion is the first step of understanding.

    Programming is as much about organization and communication
    as it is about coding.

    The secret to great software: Fail early & often.

    Eliminate software piracy: use only FLOSS.
  • Shlomi Fish at May 24, 2011 at 10:46 pm
    Hi Shawn (and all),
    On Tuesday 24 May 2011 15:05:06 Shawn H Corey wrote:
    On 11-05-24 12:10 AM, vishesh kumar wrote:
    Hi Members,

    I am a linux system admin. I want to use perl as a command line like
    sed

    and awk.
    For example suppose , i need to extract IP Addr from a string or file
    using regrex
    i mean

    str="hello ip is 192.168.2.1 and data is xxx"

    And i want ip addr only using Regex

    echo $str | perl -pe ??????

    Please guide me,
    Download the module Regex::Common from CPAN:
    http://search.cpan.org/~abigail/Regexp-Common-2011041701/lib/Regexp/Common.
    pm

    The pattern Regex::Common::net matches IPv4 addresses.
    The identifier for the module is "Regexp::Common" (with the "p") - not
    "Regex::Common" . Your URL should be mostly OK (though KMail broke it). Minor
    nitpick.

    Regards,

    Shlomi Fish

    --
    -----------------------------------------------------------------
    Shlomi Fish http://www.shlomifish.org/
    Parody of "The Fountainhead" - http://shlom.in/towtf

    What is is. Perceive It. Integrate it. Act on it. Idealize it.
    -- Leonard Peikoff

    Please reply to list if it's a mailing list post - http://shlom.in/reply .
  • Shlomi Fish at May 25, 2011 at 12:40 pm
    Hi Fudmer,

    next time, please reply to all recipients and don't send the reply only to me.
    See below for my response:
    On Wednesday 25 May 2011 13:53:53 fudmer rieley wrote:
    I c/n get the referenced link to open.. said page not found?
    http://search.cpan.org/~abigail/Regexp-Common-2011041701/lib/Regexp/Common.
    This link was broken due to a KMail bug, and it isn't a permanent link. See
    this instead:

    http://search.cpan.org/perldoc?Regexp::Common

    Regards,

    Shlomi Fish


    --
    -----------------------------------------------------------------
    Shlomi Fish http://www.shlomifish.org/
    The Case for File Swapping - http://shlom.in/file-swap

    I learned a lot from my teachers, and from my friends more than my teachers,
    and from my pupils the most. -- Rabbi Hanina

    Please reply to list if it's a mailing list post - http://shlom.in/reply .

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedMay 24, '11 at 4:10a
activeMay 25, '11 at 12:40p
posts4
users3
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase