Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

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

Report this thread to moderator Post Follow-up to this message
Old Post
Errin Larsen
09-30-04 07:55 AM


RE: POSIX module
Errin Larsen wrote:
> 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?

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 documented 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)

Report this thread to moderator Post Follow-up to this message
Old Post
Bob Showalter
09-30-04 07:55 AM


RE: 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?
>

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



Report this thread to moderator Post Follow-up to this message
Old Post
Jim
09-30-04 07:55 AM


Re: POSIX module
On Wed, 29 Sep 2004 11:32:58 -0400, Jim <jkipp5@comcast.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
>
>

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 f
ine:

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

Report this thread to moderator Post Follow-up to this message
Old Post
Errin Larsen
09-30-04 07:55 AM


RE: POSIX module
Errin Larsen wrote:
> 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?

POSIX fixes up foo_h as :foo_h for some reason

> Is there a difference
> between the two implementations above that I'm not seeing?

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.

Report this thread to moderator Post Follow-up to this message
Old Post
Bob Showalter
09-30-04 07:55 AM


Re: POSIX module
On Wed, 29 Sep 2004 12:27:03 -0400, Bob Showalter
<bob_showalter@taylorwhite.com> wrote:
> Errin Larsen wrote: 

<< SNIP >>

>
> 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.
>

Thanks Bob, that did it.

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

--Errin

Report this thread to moderator Post Follow-up to this message
Old Post
Errin Larsen
09-30-04 07:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:42 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.