On Fri, 28 Feb 2003, Stefan Lidman wrote:
> > Note that you'll match on dudette and joeshmoe ... if you want an exact
> > match, you could do:
> >
> > print "$_\n" if (/^joe|dude$/);
>
> I guess you ment:
>
> print "$_\n" if (/^(?:joe|dude)$/);
>
> Otherwise it matches if it begins with 'joe'
> Note that you'll match on dudette and joeshmoe ... if you want an exact
> match, you could do:
>
> print "$_\n" if (/^joe|dude$/);
I guess you ment:
print "$_\n" if (/^(?:joe|dude)$/);
Otherwise it matches if it begins with 'joe' or ends
with 'dude'.
/Stefan
--
To unsubscribe, e-mail: [EM
#!/usr/bin/perl -w
use strict;
my @list = qw(fred joe bob john dude eddie rob dudette joeshmoe);
foreach (@list) {
print "$_\n" if (/joe|dude/);
}
Note that you'll match on dudette and joeshmoe ... if you want an exact
match, you could do:
print "$_\n" if (/^joe|dude$/);
On Thu, 2003-02-27 a
David O'Dell wrote:
> I'm sure there is a way to shorten the way I'm performing this test
> statement.
> In the script below the test statement is looking for two separate
> conditions.
> Is there a way to shorten it by not having to specify the variable
> twice? Thanks in advance
>
> #!/usr/loca
I'm sure there is a way to shorten the way I'm performing this test
statement.
In the script below the test statement is looking for two separate
conditions.
Is there a way to shorten it by not having to specify the variable twice?
Thanks in advance
#!/usr/local/bin/perl -w
@LIST = qw(fred joe