Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Why does this happen?

by strredwolf (Chaplain)
on Apr 04, 2001 at 11:43 UTC ( [id://69574]=note: print w/replies, xml ) Need Help??


in reply to Why does this happen?

There's a few problems, which some have touched on. However, what if I typed in a sentence for an insult? It wouldn't match if I used "disk" in a sentence, eh?

Try this instead:

#!/usr/bin/perl -w use strict; print "What is your insult? "; chomp(my $input = <>); my @matching = qw/disk duck deck/; foreach $j (@matching) { die "bastard\n" if($input =~ /$j/); }
Hmmm... can't we precompile these three items, incase they're used often?

--
$Stalag99{"URL"}="http://stalag99.keenspace.com";

Replies are listed 'Best First'.
Re: Re: Why does this happen?
by grinder (Bishop) on Apr 04, 2001 at 12:36 UTC

    You could compile them into a regexp with

    my $re = do { local $"='|'; qr/^(?:@matching)$/ };

    --
    g r i n d e r

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://69574]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-25 06:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found