thevoid has asked for the wisdom of the Perl Monks concerning the following question:
but I keep getting the error syntax error at -path- line 17, near "elsif }", or something similar depending on how I've tried to arrange the blocks and curly brackets. I've looked at several tutorials for examples and can't even find it in perldoc or perlfaq. Can someone please tell me where I'm going wrong?#!/usr/bin/perl #hash.plx use warnings; use strict; my %phnums = ( derrick => '07786255633', juan => '07798685311', kevin => '07740647707', ); print "Enter a name : "; my $name = <STDIN>; chomp ($name); if ($name =~ /^derrick\b/i) { print $phnums{"derrick"}; } elsif { ($name =~ /^juan\b/i) { print $phnums{"juan"}; } else { ($name =~ /^kevin\b/i) { print $phnums{"kevin"}; } } }
Cheers, Paul.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using if-elsif-else
by chargrill (Parson) on Dec 28, 2006 at 15:46 UTC | |
|
Re: using if-elsif-else
by monkey_boy (Priest) on Dec 28, 2006 at 15:46 UTC | |
|
Re: using if-elsif-else
by pajout (Curate) on Dec 28, 2006 at 16:05 UTC | |
by chargrill (Parson) on Dec 29, 2006 at 04:43 UTC | |
by thevoid (Scribe) on Dec 29, 2006 at 10:39 UTC | |
by thevoid (Scribe) on Dec 28, 2006 at 16:07 UTC | |
|
Re: using if-elsif-else
by MonkE (Hermit) on Dec 28, 2006 at 15:58 UTC | |
|
Re: using if-elsif-else
by alpha (Scribe) on Dec 28, 2006 at 15:47 UTC | |
|
Re: using if-elsif-else
by thevoid (Scribe) on Dec 28, 2006 at 16:02 UTC |