Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Diff between 'print POSIX::cuserid' and 'use POSIX; print cuserid'

by linuxer (Deacon)
on Jan 08, 2013 at 00:10 UTC ( #1012133=note: print w/ replies, xml ) Need Help??


in reply to Diff between 'print POSIX::cuserid' and 'use POSIX; print cuserid'

In your first example, you did a use POSIX; in the second, you did not. Why?

Without loading POSIX you won't be able to call a function like POSIX::cuserid.

Enable strictwarnings and see yourself what happens:
$ perl -wE 'say POSIX::cuserid' Name "POSIX::cuserid" used only once: possible typo at -e line 1. say() on unopened filehandle cuserid at -e line 1.
But with loading POSIX:
$ perl -MPOSIX -wE 'say POSIX::cuserid' linuxer

Updates

  • replaced strict with warnings; removed strict from code examples; the warning is the crucial part.


Comment on Re: Diff between 'print POSIX::cuserid' and 'use POSIX; print cuserid'
Select or Download Code
Re^2: Diff between 'print POSIX::cuserid' and 'use POSIX; print cuserid'
by wsanders (Novice) on Jan 08, 2013 at 21:10 UTC
    Thanks, yes, so in #2 POSIX isn't loaded, so perl -e 'print POSIX::cuserid' should return nothing, actually. That's the answer. There is something odd about this user's environment that is causing it to print his username. In *my* environment, and root's, it behaves the way it is supposed to. Not going to investigate further.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012133]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2015-07-03 08:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (50 votes), past polls