in reply to Passing regex result into function

Try:
my $str = 'abc'; my ($arg) = $str =~ /b/i; PassRegex($arg, 'parm2', 'parm3');

Regex matches behave differently depending if they are in a list or scalar context.

Update: And to more specifically answer your question, no match returns undef

.

Update 2: You could also do something like this:

PassRegex($str =~ /b/i || 0, 'parm2', 'parm3');

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re^2: Passing regex result into function
by AnomalousMonk (Archbishop) on Apr 16, 2016 at 00:24 UTC

    The  m// operator returns false (the empty string), not undef, on match failure when evaluated in scalar context:

    c:\@Work\Perl\monks>perl -wMstrict -le "my $str = 'abc'; PassRegex(scalar($str =~ /x/i), 'parm2', 'parm3'); ;; use Data::Dumper; ;; sub PassRegex { print Dumper(\@_); print qq{BoolExpr = '$_[0]' parm2 = '$_[1]' parm3 = '$_[2]'}; return; } " $VAR1 = [ '', 'parm2', 'parm3' ]; BoolExpr = '' parm2 = 'parm2' parm3 = 'parm3'
    Please see Regexp Quote-Like Operators.


    Give a man a fish:  <%-{-{-{-<

Re^2: Passing regex result into function
by sdsommer (Initiate) on Apr 15, 2016 at 20:49 UTC

    Thank You! That answers my question. Next time I'll remember to check the documentation first.