John,
You will want to use 'return' rather than 'last' to exit a subroutine.
Dirk Bremer - Systems Programmer II - ESS/AMS - NISC St. Peters
636-922-9158 ext. 8652 fax 636-447-4471
[EMAIL PROTECTED]
www.nisc.cc
----- Original Message -----
From: "John Deretich" <[EMAIL PROTECTED]>
To: "'[EMAIL PROTECTED]'"
<[EMAIL PROTECTED]>
Sent: Monday, December 09, 2002 12:56
Subject: last
> Hi ,
>
> is any one familiar with using a last statement
> when exiting a subroutine?
> Here's the code that I am working with:
>
> use strict;
>
> my $logdrive=undef; #Establishing
> variable;
> my $logdrive1=undef; #Establishing
> variable;
> my $logdrive = env_variable("varname"); #invoking subroutine to
find
> env variable
> my $logdrive1 = env_variable("varname"); #invoking subroutine to
find
> env variable
>
> sub env_variable {
> my $returnvar=undef;
> if (($_[0] ne 'varname') or ($_[0] ne 'varname')) { #verify if correct
> variable is passed
> last; #Terminate and continue if the variable is
> incorrect
> }
> if ($_[0] = 'varname') { #verify if the
> correct value is passed
> if ( ( -e ($logdrive=$ENV{"varname"})) && ($logdrive =~
> /^(.*\w+)/i)) { #Verfiy the value is a-z,0-9,ignore case
> print "Running environment variable logdrive on the
> workstation\n";
> }
> }
> else {
> $returnvar = 'R';
> #Setting default value
> print "Running default variable logdrive on the
> workstation\n";
> print "$returnvar \n"
> }
> return $returnvar;
> }
>
> I am receiving the following error message: "can't "last" outside a block"
>
> please advise,
>
> John
> _______________________________________________
> Perl-Win32-Admin mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
>
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs