Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Strange behavior with switch statement

Expand Messages
  • Charles K. Clarkson
    ... Why use switch() at all? my @month_names = qw/ JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC /; my $archiveMonthName = $month_names[$numberOfMonth - 1];
    Message 1 of 9 , Mar 19, 2011
    • 0 Attachment
      On 3/16/2011 8:59 AM, Tim Lewis wrote:

      > I have come across a strange happening in some code. The code below is
      > a stripped out version of my entire program, but it still does the
      > same weird thing. If the code below is run, it gives me the error

      > String found where operator expected at testme.pl line 16, near "case "1""

      Why use switch() at all?

      my @month_names = qw/ JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC /;
      my $archiveMonthName = $month_names[$numberOfMonth - 1];



      Charles Clarkson
      --
      Mobile Home Investor
      Free Market Advocate
      Programmer

      I'm not really a smart person. I just play one on the Internet.

      Stephenville, TX
      http://twitter.com/CharlesClarkson
      +1 (254) 968-8328
    • Tim Lewis
      Charles, that is excellent code, and much easier than IF statements. Thanks! Tim From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com] On
      Message 2 of 9 , Mar 19, 2011
      • 0 Attachment
        Charles, that is excellent code, and much easier than IF statements. Thanks!

        Tim





        From: perl-beginner@yahoogroups.com [mailto:perl-beginner@yahoogroups.com] On Behalf Of Charles K. Clarkson
        Sent: Saturday, March 19, 2011 11:04 AM
        To: perl-beginner@yahoogroups.com
        Subject: Re: [PBML] Strange behavior with switch statement





        On 3/16/2011 8:59 AM, Tim Lewis wrote:

        > I have come across a strange happening in some code. The code below is
        > a stripped out version of my entire program, but it still does the
        > same weird thing. If the code below is run, it gives me the error

        > String found where operator expected at testme.pl line 16, near "case "1""

        Why use switch() at all?

        my @month_names = qw/ JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC /;
        my $archiveMonthName = $month_names[$numberOfMonth - 1];

        Charles Clarkson
        --
        Mobile Home Investor
        Free Market Advocate
        Programmer

        I'm not really a smart person. I just play one on the Internet.

        Stephenville, TX
        http://twitter.com/CharlesClarkson
        +1 (254) 968-8328





        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.