Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

RE: Subroutine question

by reyjrar (Hermit)
on Sep 18, 2000 at 22:07 UTC ( [id://32993]=note: print w/replies, xml ) Need Help??


in reply to Subroutine question

could you just pass $script $arg and $file as arguments to the sub routine?
ie in the main loop: $stuff_to_do[0] = "/path/to/script -e;;arguments;;file"; ... ... foreach $line (@stuff_to_do) { ($script,$arg,$file) = split(/;;/,$line); &file_processing($script,$arg,$file); } ... then your subroutine would be: sub file_processing { my ($script, $arg, $file) = @_; .... } I think that's what you're trying to do, but not sure.. -brad..

Replies are listed 'Best First'.
RE: RE: Subroutine question
by BlaisePascal (Monk) on Sep 18, 2000 at 22:14 UTC
    I think that's what he's trying to do, but he's also modifying the global @array1, and he wants to modify the global @array2 the second time around.

    Personally, I'd consider that poor style, and rewrite it as...

    @array1 = file_processing($script,$arg1,$file1); @array2 = file_proceesing($script,$arg2,$file2); ... sub file_processing { my ($script,$arg,$file) = @_; my @results; ... return @results; }
    Actually, I wouldn't... I'd call the sub "processfile", and make several other tweaks if I was writing this myself, but that's just me.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-03-29 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found