sandyago has asked for the wisdom of the Perl Monks concerning the following question:

Original node title and content restored by GrandFather:

Head and tail in perl

Where to use and what it will do?

Subsequent content:

Where to use \b and \B in Regular expression? I'm a beginner to Pearl. So, I didn't get clear understanding.

Replies are listed 'Best First'.
Re: Word boundaries
by kennethk (Abbot) on Dec 31, 2015 at 17:24 UTC
    Where to use \b and \B in Regular expression? I'm a beginner to Pearl. So, I didn't get clear understanding.
    It looks like the question changed since Anonymous Monk commented, so I'll archive what I'm answering. Please note that PM likes to archive threads as they were for posterity. Next time you have a new question, please start a new thread.

    \b and \B are documented in Assertions in perlre. It is also discussed in perlretut, saying:

    An anchor useful in basic regexps is the word anchor \b. This matches a boundary between a word character and a non-word character \w\W or \W\w:
    $x = "Housecat catenates house and cat"; $x =~ /cat/; # matches cat in 'housecat' $x =~ /\bcat/; # matches cat in 'catenates' $x =~ /cat\b/; # matches cat in 'housecat' $x =~ /\bcat\b/; # matches 'cat' at end of string
    Note in the last example, the end of the string is considered a word boundary.

    In general, the most useful skill you can develop early in learning about Perl is navigating the documentation.


    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re: Head and tail in perl
by Anonymous Monk on Dec 31, 2015 at 09:26 UTC

    Head and tail in perl

    Where to use and what it will do?

    What areyou talking about sandyago?

      perl -MLWP::Simple -e'print head "http://www.example.com"'

      what it means???

        perl -MLWP::Simple -e'print head "http://www.example.com"'

        what it means???

        it means a simple http head request

        also, you skipped perlintro and perlrun which introduce basic syntax, one liners, and looking up documentation

Re: Word boundaries
by Laurent_R (Canon) on Dec 31, 2015 at 18:26 UTC
    I'm a beginner to Pearl.
    Yeah, I can see that... The proper name of the language is Perl, not Pearl.