Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

why need my in a foreach loop?

by szabgab (Priest)
on Nov 28, 2010 at 04:36 UTC ( #874062=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    use strict;
    use 5.010;
    foreach my $word (qw(abc def ghi)) {
       say $word;
  2. or download this
    use strict;
    use 5.010;
       say $word;
    say $word;  # word is "hello" here
  3. or download this
    use strict;
    use 5.010;
       say $word;
    # generate syntax error if $word is used here

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://874062]
Approved by McDarren
erix prods ambrus to (re-)start cbstream...
[GotToBTru]: I've got a program with an if ... or ... statement with 80 clauses
[stevieb]: 80 clauses? dispatch table?
[GotToBTru]: no, lookup
[stevieb]: no, I mean have you considered using a dispatch table. an 80 condition if/else is huge :)
[GotToBTru]: that is how this should have been done, no question
[GotToBTru]: probably back when there were 5 or so clauses

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2017-06-22 13:00 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (519 votes). Check out past polls.