books on perl

Discussion in 'Perl Misc' started by K4 Monk, Feb 21, 2011.

  1. K4 Monk

    K4 Monk Guest

    can someone be so kind to point out some good perl books? I've
    programmed in perl for a few years now but only to write small scripts
    etc. and never went deep down to even find out stuff like proper use
    of regex or parsing long strings for repeat patterns etc. Any help
    would be appreciated.
     
    K4 Monk, Feb 21, 2011
    #1
    1. Advertising

  2. K4 Monk

    ccc31807 Guest

    On Feb 21, 10:16 am, K4 Monk <> wrote:
    > can someone be so kind to point out some good perl books? I've
    > programmed in perl for a few years now but only to write small scripts
    > etc. and never went deep down to even find out stuff like proper use
    > of regex or parsing long strings for repeat patterns etc. Any help
    > would be appreciated.


    In my opinion, the best book not on a beginner level is 'Higher Order
    Perl' by Mark Jason Dominus. You can get it for free at
    http://hop.perl.plover.com/
    but I strongly recommend buying it, not least because it encourages
    others to write such books.

    You can also obtain books for special topics, like the Perl DBI, Perl
    CGI, networking, object oriented Perl, data munging, best practices,
    Perl and TK, and so on. Speaking for myself, the two most important
    books in my Perl development are data munging by Cross, and Perl and
    MySQL by Dubois, although both of these books are regarded poorly by
    the Perl community as a whole.

    Finally, the most essential 'book' is the Perl documentation. I
    constantly keep this open on my computer, and have been known to
    actually print dead tree copies of particular sections and study them.
    You really can't consider this as a text -- the purpose isn't (in most
    cases) to instruct -- but the documentation is the one thing that
    every Perl developer should know and love.

    CC.
     
    ccc31807, Feb 21, 2011
    #2
    1. Advertising

  3. K4 Monk

    Justin C Guest

    On 2011-02-21, K4 Monk <> wrote:
    > can someone be so kind to point out some good perl books? I've
    > programmed in perl for a few years now but only to write small scripts
    > etc. and never went deep down to even find out stuff like proper use
    > of regex or parsing long strings for repeat patterns etc. Any help
    > would be appreciated.


    Ask perl: `perldoc -q book`

    Justin.

    --
    Justin C, by the sea.
     
    Justin C, Feb 21, 2011
    #3
  4. K4 Monk wrote:

    > can someone be so kind to point out some good perl books? I've
    > programmed in perl for a few years now but only to write small scripts
    > etc. and never went deep down to even find out stuff like proper use
    > of regex or parsing long strings for repeat patterns etc. Any help
    > would be appreciated.


    a) this is an FAQ, see perlfaq2, Perl Books

    b) I just finished "Modern Perl" by 'chromatic', ISBN 978-0-9779201-5-0.
    Although available online I bought the paper edition (easier to read in the
    tub) to support the author(s).
    Highly recommended, even or especially if you already have some Perl
    experience. Gives an excellent overview of modern Do's and Don'ts, a solid
    refresh of my knowledge and a bagful of useful hints and tricks.

    YMMV.


    Cheers,
    Ekki
     
    Ekki (DF4OR) Plicht, Feb 21, 2011
    #4
  5. K4 Monk

    ccc31807 Guest

    On Feb 21, 2:02 pm, Sherm Pendley <> wrote:
    > is "O'Reilly rules!" :)


    Yes, O'Reilly generally produces books of a high caliber, with the odd
    exception here and there -- certainly several orders of magnitude
    above the Sam's Teach Yourself in 24 Hours books.

    However, I'm beginning to like the Manning books as well. The ones I
    have also do well. They tend to be Windows centric, but we don't judge
    the quality of a book by the OS or technology preference. Case in
    point: 'Object Oriented Perl' by Damian Conway.

    I also like the few Pragmatic Bookshelf books I've bought, not as
    strong perhaps as O'Reilly but still of high quality.

    CC.
     
    ccc31807, Feb 21, 2011
    #5
  6. K4 Monk

    K4 Monk Guest

    On Feb 21, 9:31 pm, Justin C <> wrote:
    > On 2011-02-21, K4 Monk <> wrote:
    >
    > > can someone be so kind to point out some good perl books? I've
    > > programmed in perl for a few years now but only to write small scripts
    > > etc. and never went deep down to even find out stuff like proper use
    > > of regex or parsing long strings for repeat patterns etc. Any help
    > > would be appreciated.

    >
    > Ask perl: `perldoc -q book`
    >
    >    Justin.
    >
    > --
    > Justin C, by the sea.


    vidura@localhost~ $ perldoc -q book
    You need to install the perl-doc package to use this program.
     
    K4 Monk, Feb 22, 2011
    #6
  7. K4 Monk

    Justin C Guest

    On 2011-02-22, K4 Monk <> wrote:
    > On Feb 21, 9:31 pm, Justin C <> wrote:
    >> On 2011-02-21, K4 Monk <> wrote:
    >>
    >> > can someone be so kind to point out some good perl books? I've
    >> > programmed in perl for a few years now but only to write small scripts
    >> > etc. and never went deep down to even find out stuff like proper use
    >> > of regex or parsing long strings for repeat patterns etc. Any help
    >> > would be appreciated.

    >>
    >> Ask perl: `perldoc -q book`
    >>
    >>    Justin.
    >>
    >> --
    >> Justin C, by the sea.

    >
    > vidura@localhost~ $ perldoc -q book
    > You need to install the perl-doc package to use this program.


    God helps those who help themselves. Install perldoc.

    Justin.

    --
    Justin C, by the sea.
     
    Justin C, Feb 22, 2011
    #7
  8. K4 Monk <> wrote:
    >> On 2011-02-21, K4 Monk <> wrote:
    >> > I've programmed in perl for a few years now

    [...]
    >vidura@localhost~ $ perldoc -q book
    >You need to install the perl-doc package to use this program.


    This combination is, well, shall we say, "interesting". How did you
    manage to program in Perl without using the Perl documentation?

    May I suggest to repair your broken installation asap?

    jue
     
    Jürgen Exner, Feb 22, 2011
    #8
  9. K4 Monk

    K4 Monk Guest

    On Feb 22, 8:10 pm, J rgen Exner <> wrote:
    > K4 Monk <> wrote:
    > >> On 2011-02-21, K4 Monk <> wrote:
    > >> > I've programmed in perl for a few years now

    > [...]
    > >vidura@localhost~ $ perldoc -q book
    > >You need to install the perl-doc package to use this program.

    >
    > This combination is, well, shall we say, "interesting". How did you
    > manage to program in Perl without using the Perl documentation?
    >
    > May I suggest to repair your broken installation asap?
    >
    > jue


    I've installed it now. I've programmed (if you can call it that) in
    perl for years and never heard about perldoc. I generally wrote
    whatever scripts I had to write with a bit of fiddling around and
    looking at existing code
     
    K4 Monk, Feb 22, 2011
    #9
  10. K4 Monk

    J. Gleixner Guest

    K4 Monk wrote:

    > I've installed it now. I've programmed (if you can call it that) in
    > perl for years and never heard about perldoc. I generally wrote
    > whatever scripts I had to write with a bit of fiddling around and
    > looking at existing code


    Welcome to the 21st century. :)

    Be sure to learn about CPAN too: http://www.cpan.org/
     
    J. Gleixner, Feb 22, 2011
    #10
  11. K4 Monk

    K4 Monk Guest

    On Feb 22, 10:38 pm, "J. Gleixner" <glex_no-s...@qwest-spam-
    no.invalid> wrote:
    > K4 Monk wrote:
    > > I've installed it now. I've programmed (if you can call it that) in
    > > perl for years and never heard about perldoc. I generally wrote
    > > whatever scripts I had to write with a bit of fiddling around and
    > > looking at existing code

    >
    > Welcome to the 21st century. :)
    >
    > Be sure to learn about CPAN too:  http://www.cpan.org/


    Thank you! btw, I posted this in another newsgroup but never got a
    response. After reading this thread and one of the booke (HOP) I have
    realized that I don't know Perl. I've never used functions extensively
    and don't understand how they work. And here's a program I wrote to
    prove it.

    #!/usr/bin/perl
    use strict;

    sub func {
    my %list;
    $list{"map"} = "key";
    $list{"l"}="j";

    my @arr;
    push (@arr, "egg");
    push (@arr, "hell");


    return (%list, @arr);

    }

    my @arrref = &func();
    my %l = %{$arrref[0]};
    my @r = @{$arrref[1]};

    print "keys\n";
    foreach my $k(keys %l) { print "$k\n"; }
    print "array\n";
    foreach my $rr(@r) { print "$rr\n"; }
     
    K4 Monk, Feb 22, 2011
    #11
  12. K4 Monk <> wrote:
    >Thank you! btw, I posted this in another newsgroup but never got a
    >response. After reading this thread and one of the booke (HOP) I have
    >realized that I don't know Perl. I've never used functions extensively
    >and don't understand how they work.


    See "perldoc perlsub"

    >And here's a program I wrote to
    >prove it.
    >
    >#!/usr/bin/perl
    >use strict;


    Good. But you should also enable warnings.

    use warnings;

    >sub func {
    > my %list;
    > $list{"map"} = "key";
    > $list{"l"}="j";


    You can write such an initialization more easily as
    my %list = (
    "map" => "key",
    "l" => "j");

    > my @arr;
    > push (@arr, "egg");
    > push (@arr, "hell");


    Most people would probably do a simple
    my @arr = ('egg", "hell");

    > return (%list, @arr);


    You are aware that you are returning a list with 6 elements, mixing your
    hash and array elements indiscrimently togehter, aren't you?
    Just like arguments the return value of a sub is just a list of scalars,
    too, and any sub-structure or composite data will be flattened.

    >}
    >
    > my @arrref = &func();


    Just print the lenght of the array here
    print scalar(@arrref);
    and it will tell you that @arrref contains 6 elements.

    > my %l = %{$arrref[0]};
    > my @r = @{$arrref[1]};


    Whatever you are trying to do here doesn't work because @arrref already
    contains the wrong data. If you want to preserve your return hash and
    return array from sub func then first of all you have to return a
    reference to them instead of their values (see "Make Rule 1" in "Making
    References" in "perldoc perlreftut")

    return (\%list, \@arr);

    Then the rest will more or less fall into place on its own.

    jue
     
    Jürgen Exner, Feb 23, 2011
    #12
  13. K4 Monk

    K4 Monk Guest

    On Feb 23, 8:09 am, J rgen Exner <> wrote:
    > K4 Monk <> wrote:
    > >Thank you! btw, I posted this in another newsgroup but never got a
    > >response. After reading this thread and one of the booke (HOP) I have
    > >realized that I don't know Perl. I've never used functions extensively
    > >and don't understand how they work.

    >
    > See "perldoc perlsub"
    >
    > >And here's a program I wrote to
    > >prove it.

    >
    > >#!/usr/bin/perl
    > >use strict;

    >
    > Good. But you should also enable warnings.
    >
    >         use warnings;
    >
    > >sub func {
    > >    my %list;
    > >    $list{"map"} = "key";
    > >    $list{"l"}="j";

    >
    > You can write such an initialization more easily as
    >         my %list = (
    >             "map" => "key",
    >             "l" => "j");
    >
    > >    my @arr;
    > >    push (@arr, "egg");
    > >    push (@arr, "hell");

    >
    > Most people would probably do a simple
    >         my @arr = ('egg", "hell");
    >
    > >    return (%list, @arr);

    >
    > You are aware that you are returning a list with 6 elements, mixing your
    > hash and array elements indiscrimently togehter, aren't you?


    Thank you jue, no I wasn't aware of this, and on my end I spent an
    hour looking for the but gave up.

    > Just like arguments the return value of a sub is just a list of scalars,
    > too,  and any sub-structure or composite data will be flattened.


    so, even if I do a func(%hash), on func's end it gets an array of a
    scalar pointing to %hash?


    >
    > >}

    >
    > > my @arrref = &func();

    >
    > Just print the lenght of the array here
    >         print scalar(@arrref);


    nice. I noted this down.

    > and it will tell you that @arrref contains 6 elements.
    >
    > > my %l = %{$arrref[0]};
    > > my @r = @{$arrref[1]};

    >
    > Whatever you are trying to do here doesn't work because @arrref already
    > contains the wrong data. If you want to preserve your return hash and
    > return array from sub func then first of all you have to return a
    > reference to them instead of their values (see "Make Rule 1" in "Making
    > References" in "perldoc perlreftut")
    >
    >         return (\%list, \@arr);
    >
    > Then the rest will more or less fall into place on its own.
    >
    > jue


    Thanks jue for your help!
     
    K4 Monk, Feb 23, 2011
    #13
  14. K4 Monk <> wrote:
    >so, even if I do a func(%hash), on func's end it gets an array of a
    >scalar pointing to %hash?


    No. It gets a flat(!) list(!) which is composed of the alternating keys
    and values of %hash, i.e. if %hash has 5 entries then the argument list
    @_ of func(%hash) will contain 10 values.

    jue
     
    Jürgen Exner, Feb 24, 2011
    #14
  15. K4 Monk

    Justin C Guest

    On 2011-02-23, K4 Monk <> wrote:
    >
    > so, even if I do a func(%hash), on func's end it gets an array of a
    > scalar pointing to %hash?


    AIUI (and ICBW, in which case this'll be a learning exercise for me
    too), if you do func(%hash) what func receives *is* an array, there's
    no 'pointing to'. For example:

    my %hash = (
    john => "lennon",
    paul => "macca",
    george => "harrison",
    ringo => "star",
    );
    func(%hash);

    func() would receive an array containing qw/john, lennon, paul, macca,
    george, harrison, ringo, star/ ... which can be shown by:
    sub func {
    print $_, "\n" for @_;
    }

    You could massage the array back into a hash in func() with (for
    example)
    sub func {
    my %hash = @_;
    # do stuff ...
    }

    Justin.

    --
    Justin C, by the sea.
     
    Justin C, Feb 24, 2011
    #15
  16. K4 Monk

    K4 Monk Guest

    On Feb 24, 5:03 am, Tad McClellan <> wrote:
    > K4 Monk <> wrote:
    > > On Feb 23, 8:09 am, J rgen Exner <> wrote:
    > >> K4 Monk <> wrote:
    > >> >I've never used functions extensively
    > >> >and don't understand how they work.

    >
    > >> See "perldoc perlsub"

    >
    > Have you done that yet?


    yep, finally!

    "The Perl model for function call and return values is simple:
    all functions are passed as
    parameters one single flat list of scalars, and all functions
    likewise return to their caller one
    single flat list of scalars. Any arrays or hashes in these
    call and return lists will collapse,
    losing their identities--but you may always use pass-by-
    reference instead to avoid this. "
     
    K4 Monk, Feb 24, 2011
    #16
  17. K4 Monk

    Justin C Guest

    On 2011-02-24, Tad McClellan <> wrote:
    > Justin C <> wrote:
    >> On 2011-02-23, K4 Monk <> wrote:
    >>>
    >>> so, even if I do a func(%hash), on func's end it gets an array of a
    >>> scalar pointing to %hash?

    >>
    >> AIUI (and ICBW, in which case this'll be a learning exercise for me
    >> too), if you do func(%hash) what func receives *is* an array,

    >
    >
    > Not it *is not* an array.
    >
    > It is a list.


    kick($self)

    I know this, why do I always call it an array?! <shakes head>

    Justin.

    --
    Justin C, by the sea.
     
    Justin C, Feb 24, 2011
    #17
  18. On Thu, 24 Feb 2011 14:18:32 +0000, Justin C wrote:

    > kick($self)


    Better written as:

    $self->kick();

    although if kick() does not exist, the former fails at compile time while
    the latter fails at run time.

    :)

    M4
     
    Martijn Lievaart, Feb 24, 2011
    #18
  19. >>>>> "Martijn" == Martijn Lievaart <> writes:

    Martijn> Better written as:

    Martijn> $self->kick();

    Martijn> although if kick() does not exist, the former fails at compile time while
    Martijn> the latter fails at run time.

    And if kick doesn't know what to do with an object of the type that
    $self is, it'll have to check that itself unless it's a method call. :)

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
    <> <URL:http://www.stonehenge.com/merlyn/>
    Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
    See http://methodsandmessages.posterous.com/ for Smalltalk discussion
     
    Randal L. Schwartz, Feb 24, 2011
    #19
  20. K4 Monk

    Justin C Guest

    On 2011-02-25, Tad McClellan <> wrote:
    > Justin C <> wrote:
    >> On 2011-02-24, Tad McClellan <> wrote:
    >>> Justin C <> wrote:
    >>>> On 2011-02-23, K4 Monk <> wrote:
    >>>>>
    >>>>> so, even if I do a func(%hash), on func's end it gets an array of a
    >>>>> scalar pointing to %hash?
    >>>>
    >>>> AIUI (and ICBW, in which case this'll be a learning exercise for me
    >>>> too), if you do func(%hash) what func receives *is* an array,
    >>>
    >>>
    >>> Not it *is not* an array.
    >>>
    >>> It is a list.

    >>
    >> kick($self)
    >>
    >> I know this, why do I always call it an array?! <shakes head>

    >
    >
    > It even happens to Larry.
    >
    > He gave us wantarray() rather than wantlist()


    I'm in good company then! That doesn't make me feel so bad.

    Justin.

    --
    Justin C, by the sea.
     
    Justin C, Feb 25, 2011
    #20
    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. HDL Book Seller
    Replies:
    0
    Views:
    955
    HDL Book Seller
    Dec 1, 2004
  2. Luis Esteban Valencia

    Design Patterns Books and Best Practices Books.

    Luis Esteban Valencia, Jun 30, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    522
    Joerg Jooss
    Jul 1, 2005
  3. MiniMe
    Replies:
    0
    Views:
    508
    MiniMe
    Apr 19, 2006
  4. MiniMe
    Replies:
    0
    Views:
    442
    MiniMe
    Apr 20, 2006
  5. Guest

    Books, Books, Books...

    Guest, Sep 19, 2004, in forum: C++
    Replies:
    3
    Views:
    560
    ÁÍÄÑÅÁÓ ÔÁÓÏÕËÁÓ
    Sep 19, 2004
Loading...

Share This Page