in reply to Re: simple "if.. elsif.. else.." statements, trying "for.. if.." too
in thread simple "if.. elsif.. else.." statements, trying "for.. if.." too

I usually use switch when coding in other langages. I can't find the website were I read this strange for loop. Thank you, I'll search in the switch doc.
  • Comment on Re^2: simple "if.. elsif.. else.." statements, trying "for.. if.." too

Replies are listed 'Best First'.
Re^3: simple "if.. elsif.. else.." statements, trying "for.. if.." too
by jwkrahn (Abbot) on May 18, 2012 at 15:05 UTC

    What you probably saw was:

    for ($os_arch) { if (/x86_64/) {

    Which is short for:

    for my $os_type ($os_arch) { if ($os_type =~ m/x86_64/) {
Re^3: simple "if.. elsif.. else.." statements, trying "for.. if.." too
by tobyink (Canon) on May 18, 2012 at 14:42 UTC

    I imagine you wanted this:

    for ($os_arch) { when ("x86_64") { ... } ... }

    Or:

    given ($os_arch) { when ("x86_64") { ... } ... }
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'