perl - Different ways to test for $1 after regex? -


normally when check if regex succeeded do

if ($var =~ /aaa(\d+)bbb(\d+)/) { # $1 , $2 should defined } 

but recall seeing variation of seamed shorter. perhaps 1 buffer.

can think or other ways test if $1 after successful regex?

you can avoid $1 , similar altogether:

if (my ($anum, $bnum) = $var =~ /aaa(\d+)bbb(\d+)/) {     # work $anum , $bnum } 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

node.js - Node - Passport Auth - Authed Post Route hangs on form submission -

Does Firefox offer AppleScript support to get URL of windows? -