Lets say I do this:
my ($a,$b,$let) = $version =~ m/^(\d+)\.(\d+)\.?([A-Za-z])?$/;
so this will match for instance: 1.3a, 1.3,…
I want to have a default value for $let if let is not available, lets say, default 0.
so for 1.3 I will get:
$a = 1
$b = 3
$let = 0
is it possible? (from the regex it self, without using additional statements)
Thanks,
This will work – updated to use bitwise or instead of ternary operator.
Here is a test script
Output is
original solution using ternary operator also works