On Wed, 23 Mar 2005 17:41:31 -0800, Perl wrote:
> Hi.
> 
> I would like to search a scalar variable and have the output to another
> scalar. For example:
> 
> $test = "This is some test data";
> 
> I want another scalar, $regex to hold the output of a regular expression
> lookup against $test.
> 
> So something like this:
> 
> $regex =~ /test/ running against $test. Is this possible somehow?
> 
> 

Simply assign the result of the match to a variable:
my $re_result = $test =~ m/test/;

See perlop for details and perlretut for more detailed examples.

-- 
Offer Kaye

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to