in reply to Setting Conditional Variable Based on Partial Match
First of all: use use strict; and use warnings;. That will save a lot of time for you.
It will be good to put backslash before * in regexp if you want to match an asterisk. (see perldoc perlre about metacharacters)
Yes $type must be declared outside of condition block. But rather before if clause than after it. And seems you want to use = instead of eq when assigning a value to $type
my $type = ($B1 =~ m/^\*/ or $B2 =~ m/^\*/) ? 'S' : 'I';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Setting Conditional Variable Based on Partial Match
by Osiris1975 (Novice) on Dec 23, 2008 at 20:43 UTC | |
by ccn (Vicar) on Dec 24, 2008 at 10:20 UTC |