in reply to how to get output
Change:
my $out = $Ora_code =~ /ORA\-\d{5}/
to:
my ($out) = $Ora_code =~ /(ORA\-\d{5})/
.
Adding the first set of parens causes $out to be treated as a one-element list. Without those parens, you have scalar context instead of list context; regex matches in scalar context return "truth" of the match instead of anything captured in the match. That Truth is represented as the "1" you are seeing.
Adding the second set of parens declares what data should be captured when the regex is evaluated during the match.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: how to get output
by dbashyam (Novice) on Feb 18, 2014 at 05:38 UTC | |
by Kenosis (Priest) on Feb 18, 2014 at 05:47 UTC | |
by dbashyam (Novice) on Feb 18, 2014 at 05:44 UTC |
In Section
Seekers of Perl Wisdom