[26313] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8490 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 5 14:05:28 2005

Date: Wed, 5 Oct 2005 11:05:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 5 Oct 2005     Volume: 10 Number: 8490

Today's topics:
        3 arrays into @_ <everythingelse@bobotheclown.org>
    Re: 3 arrays into @_ <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 05 Oct 2005 16:28:01 GMT
From: Rocky Allen <everythingelse@bobotheclown.org>
Subject: 3 arrays into @_
Message-Id: <pan.2005.10.05.16.28.00.51156@bobotheclown.org>

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.


regards,
Rocky Allen 



------------------------------

Date: Wed, 5 Oct 2005 11:50:01 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: 3 arrays into @_
Message-Id: <slrndk811p.roi.tadmc@magna.augustmail.com>

Rocky Allen <everythingelse@bobotheclown.org> wrote:
> 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?


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


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8490
***************************************


home help back first fref pref prev next nref lref last post