Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Could somebody please explain why the following does this?
#! /usr/bin/perl use warnings; use strict; use test(); my $output = testroutine(); print $output, "\n";

and this has the same result...
#! /usr/bin/perl use warnings; use strict; use test; my $output = testroutine(); print $output, "\n";
the result being...
Undefined subroutine &main::testroutine called at ./test.pl line 8.
If I run the following:
$ perl -e 'map {print $_,"\n"} @INC' /usr/lib/perl5/5.8/cygwin /usr/lib/perl5/5.8 /usr/lib/perl5/site_perl/5.8/cygwin /usr/lib/perl5/site_perl/5.8 /usr/lib/perl5/site_perl/5.8/cygwin /usr/lib/perl5/site_perl/5.8 /usr/lib/perl5/vendor_perl/5.8/cygwin /usr/lib/perl5/vendor_perl/5.8 /usr/lib/perl5/vendor_perl/5.8/cygwin /usr/lib/perl5/vendor_perl/5.8 .
Now if I alter test.pl to look like:
#! /usr/bin/perl use warnings; use strict; use lib '.'; #My Change use test(); my $output = testroutine(); print $output, "\n";
When run, the program outputs the following:
This is a test
For information test.pm which is in the same directory as test.pm has the following code:
sub testroutine { return "This is a test"; } 1;
Now I may be very ignorant of the use. However, I would expect my first example to work if my second example works. Why would enabling use lib import the module into my namespace? When before I use use lib, '.' is in my @INC. Second, I would think that in actuality both examples should fail since I'm calling test.pm by use test(), I would think this would NOT populate anything into my namespace? I hope this long post makes sense, for I am eager to learn.

Thanks!
s;;5776?12321=10609$d=9409:12100$xx;;s;(\d*);push @_,$1;eg;map{print chr(sqrt($_))."\n"} @_;

In reply to Use, Exporter, I'm Dizzy. by logie17

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found