Professional Web Applications Themes

POSIX module - PERL Beginners

Hi Perlers, I've seen a lot of tutorial or example code dealing with the POSIX module that does something like this: use POSIX ':sys_wait_h'; What does the ':' mean/do in the above line? --Errin...

  1. #1

    Default POSIX module

    Hi Perlers,

    I've seen a lot of tutorial or example code dealing with the POSIX
    module that does something like this:

    use POSIX ':sys_wait_h';

    What does the ':' mean/do in the above line?

    --Errin
    Errin Guest

  2. #2

    Default RE: POSIX module

    Errin Ln wrote: 

    It's called a "tag" and is typically used to import a "basket" of symbols.

    See "perldoc Exporter", under the heading "Specialised Import Lists"

    For some reason this isn't doented in my copy of POSIX. But you can see
    the symbols exported by running:

    $ perl -MPOSIX -le 'print for {$POSIX::EXPORT_TAGS{sys_wait_h}}'
    WEXITSTATUS
    WIFEXITED
    WIFSIGNALED
    WIFSTOPPED
    WNOHANG
    WSTOPSIG
    WTERMSIG
    WUNTRACED

    (your system may show different values)
    Bob Guest

  3. #3

    Default RE: POSIX module

     

    Besides googling for it, try reading:
    perldoc perlipc
    perldoc perldoc -f waitpid
    perldoc POSIX

    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.770 / Virus Database: 517 - Release Date: 9/27/2004


    Jim Guest

  4. #4

    Default Re: POSIX module

    On Wed, 29 Sep 2004 11:32:58 -0400, Jim <net> wrote: 
    >
    > Besides googling for it, try reading:
    > perldoc perlipc
    > perldoc perldoc -f waitpid
    > perldoc POSIX
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system (http://www.grisoft.com).
    > Version: 6.0.770 / Virus Database: 517 - Release Date: 9/27/2004
    >
    >[/ref]

    Thank you Bob, and Jim

    I have read about this. My question is more about the 'use' code then
    about the POSIX module. It's just a really big module that has a lot
    of these tags in it, it seems.

    Here's my problem: When I use the following in my code, it runs and works fine:

    use POSIX 'setsid';
    use POSIX 'errno_h';
    use POSIX ':sys_wait_h';

    However, when I try to combine those into one line:

    use POSIX qw/setsid errno_h :sys_wait_h/;

    Then I get the following error:

    # ismon.pl
    ":errno_h" is not exported by the POSIX module at
    /usr/perl5/5.6.1/lib/sun4-solaris-64int/POSIX.pm line 19

    ":sys_wait_h" is not exported by the POSIX module at
    /usr/perl5/5.6.1/lib/sun4-solaris-64int/POSIX.pm line 19

    Can't continue after import errors at
    /usr/perl5/5.6.1/lib/sun4-solaris-64int/POSIX.pm line 19
    BEGIN failed--compilation aborted at ./ismon.pl line 3.

    First of all, I'm not putting a ':' in front of 'errno_h' in my code,
    but Perl seems to assume it's there ... why? Is there a difference
    between the two implementations above that I'm not seeing?

    --Errin
    Errin Guest

  5. #5

    Default RE: POSIX module

    Errin Ln wrote: 

    POSIX fixes up foo_h as :foo_h for some reason
     

    Exporter only does the special :tag processing if the *first* entry in the
    import list starts with one of the following characters

    : ! /

    So move :sys_wait_h to the front and it will work.
    Bob Guest

  6. #6

    Default Re: POSIX module

    On Wed, 29 Sep 2004 12:27:03 -0400, Bob Showalter
    <com> wrote: [/ref]

    << SNIP >>
     

    Thanks Bob, that did it.

    I wonder why that is about Exporter? It seems rather counter-intuitive to me.

    --Errin
    Errin Guest

Similar Threads

  1. POSIX::ctermid()
    By Peter Michael in forum PERL Modules
    Replies: 0
    Last Post: January 21st, 11:54 AM
  2. POSIX mkstemp and gcc
    By claudibus in forum UNIX Programming
    Replies: 7
    Last Post: November 4th, 05:50 AM
  3. POSIX module sig handlers vs default
    By bob in forum PERL Miscellaneous
    Replies: 0
    Last Post: September 11th, 06:48 PM
  4. Posix queues
    By Rami in forum UNIX Programming
    Replies: 1
    Last Post: July 15th, 04:33 PM
  5. Standard Posix
    By GALVANO in forum Sun Solaris
    Replies: 3
    Last Post: July 13th, 09:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139