Damian Conway has written a module that simulates a switch for Perl.
<snip href="http://search.cpan.org/doc/DCONWAY/Switch-2.03/Switch.pm">
SYNOPSIS
use Switch;
switch ($val) {
case 1 { print "number 1" }
case "a" { print "string a" }
case [1..10,42] { print "number in list" }
case (@array) { print "number in list" }
case /\w+/ { print "pattern" }
case qr/\w+/ { print "pattern" }
case (%hash) { print "entry in hash" }
case (\%hash) { print "entry in hash" }
case (\&sub) { print "arg to subroutine" }
else { print "previous case not true" }
}
</snip>
On 10 Jul 2001 11:01:57 -0400, Jason Purdy wrote:
> Just got the answer to #1 for you: check out 'switch' - documented in the
> 'perlsyn' perldoc. There is no 'case' or 'switch' function, but you can
> emulate it with a block & exit routine, as documented.
>
> Jason
>
> ----- Original Message -----
> From: "Sparkle Williams" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, July 10, 2001 9:43 AM
> Subject: Perl-case statement, and module syntax error
>
>
> > I'm having two problems
> > 1) Is there an equivalent of the case function in Perl?
> >
> > 2)I'm also getting a syntax error for the following part of my program
> that
> > I'm attempting to run on my Unix system. I get a syntax error message for
> > 'new($url, ', 'login($username, 'cwd($ftp_home), ', and 'get($filename '.
> I
> > don't understand why and I don't know how to fix it...help!
> >
> > $ftp = Net::FTP->new($url, Debug=>0);
> >
> > $ftp->login($username, $password);
> >
> > echo $ftp->cwd($ftp_home), "\n";
> >
> > $ftp->get($filename);
> >
> > $ftp->quit;
> >
> > _________________________________________________________________
> > Get your FREE download of MSN Explorer at http://explorer.msn.com
> >
>
>
--
Today is Sweetmorn, the 45th day of Confusion in the YOLD 3167
Or is it?