David Gilden wrote:
Hello,
In the following I was thinking it would just print out: "Hello"
#!/usr/bin/perl -w
$S = "Hello, Perl!";
($R) = grep {/\w+/} $S;
print "$R\n";
I am trying for some sort of inline filtering so I can do the following:
#!/usr/bin/perl -w use CGI qw/:standard/;
use strict;
my $page = grep {/\w{1,50}/i} param('page'); # only allow $page to contain 1-50 of [a-z0-9_] ....snip....
Is this even possible?
Dave Gilden (kora musician / audiophile / webmaster @ www.coraconnection.com / Ft. Worth, TX, USA)
Grep works on arrays. perldoc -f grep
you just want a regex
($R) = grep {/\w+/} $S; =>
$s =~ /(Hello)/; $r = $1;
--
END
------------------------------------------------------
Philip M. Gollucci ([EMAIL PROTECTED]) 301.254.5198
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Developer / Liquidity Services, Inc.
http://www.liquidityservicesinc.com
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>