last, next are used in relationship to a block like

        while ( 1 ) {
         next if ( $abc < 1 );
         last if ( $abc == 1 );
           # other code
       }

    used with while, for, foreach or really I believe any block defintion.
The guru's can give us a better info if necessary.

        What I would believe you want is to use return and have the sub
called like:

        if ( ! callsub( <variables passed) ) {  # return 0 if not valid
passed params
         # what to do if invalid
       }else {
         # what to do if valid.  May need nothing, since you may display
some message and then
           # go back to top of display
       }

Wags ;)
-----Original Message-----
From: John Deretich [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 09, 2002 10:57
To: '[EMAIL PROTECTED]'
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


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  • last John Deretich
    • Re: last Dirk Bremer \(NISC\)
    • RE: last Jarrod Ramsey
    • Wagner, David --- Senior Programmer Analyst --- WGO

Reply via email to