--- Matija Papec <[EMAIL PROTECTED]> wrote:
> Btw, when we talk about structures is there something like switch in
> perl which could replace following code?
> 
> $x==1 and $y = 1;
> $x==2 and $y = 2;
> $x==3 and $y = 3;

I mentioned Damian Conway's Switch.pm earlier today:

  use Switch;
  my $x = shift;
  my $y;

  switch ($x) {
    case 1 { $y=1; }
    case 2 { $y=2; }
    case 3 { $y=3; }
  }
  print "$y\n";

It's on CPAN.


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Reply via email to