Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: calling subroutines

by bobosm (Initiate)
on Oct 12, 2013 at 16:06 UTC ( #1057996=note: print w/ replies, xml ) Need Help??


in reply to Re: calling subroutines
in thread calling subroutines

Tnx for reply, and how I can generate a random number for variable num1 which is in subroutine?


Comment on Re^2: calling subroutines
Re^3: calling subroutines
by davido (Archbishop) on Oct 12, 2013 at 16:13 UTC

    Pass a parameter through your subroutine:

    my $number = rand; some($number); sub some { my $num1 = shift; print "$num1\n"; }

    But I don't have any idea how you are supposed to be reconciling that with your existing code that takes user input. Why are you taking user input from STDIN if your goal is to generate values from within the program? And is $num2 really supposed to always be the value 2?

    This is homework, right? Even on a student's limited budget, Learning Perl, from OReilly, is a worthwhile purchase. Or if you are lucky you can find it or request it at the library. Also, read perlintro, and perlsyn. You could spend countless hours stumbling around in the dark, or spend two hours reading those two free documents, after which you will be able to complete your assignments with swift confidence.

    If the web server is down for those two final links I posted, just type "perldoc perlintro", and "perldoc perlsyn" on any system that has Perl installed. They're already on that system, no network access required.


    Dave

      I know why is not oky, Yes I have read some books and rework perl.

        Yes I have read some books...

        Which Perl books have you read?


        Dave

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2014-11-21 02:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (104 votes), past polls