|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Im trying to write a function that takes an array and does stuff with it.
i have programed in c++ and i would call it like this "doStuff(arrayName)" how would i write the funciton in perl? this also leads me to ask the question of scope in perl. sub doStuff{} how would i write this function to pass an array? |
|
#2
|
|||
|
|||
|
just a quick and probably dodgy example:
@array = (1 .. 10); &mysub(@array); exit; sub mysub { @temp = @_; foreach (@temp) { print "sub got this number $_n"; } } ---- You might want to get the return values of the array so maybe you could have return(@temp), but then you'd want to call it with @somearay = &mysub(@array); Or something like that. as for scopes in perl, a good book is learning perl by O'Reilly, it'll explain that and more. Maybe even check the perl homepage. My perl is a tad rusty. :-/ Imo |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > writing functions with a parameter |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|