Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^4: i need help in subroutines

by uva (Sexton)
on Feb 07, 2006 at 12:37 UTC ( [id://528490]=note: print w/replies, xml ) Need Help??


in reply to Re^3: i need help in subroutines
in thread i need help in subroutines

thanx Corion,,,, i am not sure whether the following code is write ======================================
#file1 is in "d:/test.pm" sub uvaraj { $name='ramu'; print 'uvaraj is a good boy in nature but...'; }
===================================
#file2 is in "d:/run.pl" use lib 'D:/'; use test; &uvaraj;
==================== i run the second file, it is giving error as "test.pm didnt return a true value"

Replies are listed 'Best First'.
Re^5: i need help in subroutines
by Corion (Patriarch) on Feb 07, 2006 at 12:43 UTC

    Put the following line near the top of your script:

    use diagnostics;

    Perl will then tell you the cause of the error. The diagnostics pragma has many helpfull hints. Please also read the Writeup Formatting Tips and use the Preview feature so your posts are readable to others. Perlmonks uses HTML for formatting.

      thanx Corion,,,, i am not sure whether the following code is write ======================================
      #file1 is in "d:/test.pm" sub uvaraj { $name='ramu'; print 'uvaraj is a good boy in nature but...'; }
      ===================================
      #file2 is in "d:/run.pl" use lib 'D:/'; use test; &uvaraj;
      ==================== i run the second file, it is giving error as "test.pm didnt return a true value"

        You appear to be using the first file you mention ('d:/test.pm') as a module, and it is complaining that it did not return a true value. Modules must return a true value to let perl know they loaded correctly. Try appending the following as the last line of that file, and see if it makes a difference:

        1;

        In addition to the resources previously mentioned by Corion, et. al., you may also wish to look at the Tutorials section of this site (especially tachyon's Simple Module Tutorial), and in the documentation that comes with perl at perlfaq7 (question "How do I create a module?"), as well as perlmod, perlmodlib, perlmodstyle, and perlnewmod.

        HTH.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2025-01-16 04:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (53 votes). Check out past polls.