rammohan has asked for the wisdom of the Perl Monks concerning the following question:
output: both strings are same. My question is why it doesn't executing elsif. What's the wrong in me code.I'm purely beginner please let us know#!/usr/bin/perl -w use strict; use warnings; my$str = 'perl_script'; my$length = length $str; if ($str eq 'perl_script') { print 'both strings are same'; } elsif($length = 8){ print "the given string has 8 characters"; } elsif($length >8){ print "the given string has more that 8 characters"; } else{ print"Doen't matched both strings"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl If and Elsif statement help
by kcott (Archbishop) on Dec 30, 2013 at 06:02 UTC | |
by rammohan (Acolyte) on Dec 30, 2013 at 06:59 UTC | |
|
Re: Perl If and Elsif statement help
by davido (Cardinal) on Dec 30, 2013 at 05:19 UTC | |
|
Re: Perl If and Elsif statement help
by rammohan (Acolyte) on Dec 30, 2013 at 05:30 UTC | |
by davido (Cardinal) on Dec 30, 2013 at 05:43 UTC | |
by GrandFather (Saint) on Dec 30, 2013 at 05:39 UTC | |
by Anonymous Monk on Dec 30, 2013 at 07:59 UTC |