3 arrays into @_

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
hi Y'all,

 I am writing a backup script for an Oracle Database server on Linux.  It
 is very long so I only included the code I need help with here.  The
 entire script is published here.  http://bobotheclown.org/scripts/comlang

I am trying to turn this code into a subroutine:

open(FH13, ">$contentsfile") or die "Couldnt get FH13:$!";
print FH13 @joblog;
print FH13 "\n";
print FH13 "breakpointforrecover\n";
print FH13 "\n";
print FH13 @intersection;
print FH13 "\n";
print FH13 "\n";
print FH13 @splitnames;
close FH13;

My question is this:

Since I have to pass all of those arrays into the subroutine as @_, how
can I tell when one ends and the next begins?

I would like for it to be a subroutine because the only way I currently
get a logfile i if the backup runs successfully.  I want it in any case.

Rocky Allen

Re: 3 arrays into @_

Quoted text here. Click to load it

You can't, so instead pass three *references* to arrays:

   myfunc( \@joblog, \@intersection, \@splitnames );

Then deref them in the subroutine body:

   my($joblog, $intersection, $splitnames) = @_;
   print FH13 @$joblog;

See also:

   perldoc perlreftut
   perldoc perlref

    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas

Site Timeline