in reply to Basic but stupid problem i cannot wrap my head around
In your first input string, there is an a, this gets matched and then assigned to $z (and printed).
In your second input string, there is an empty string before the /, and no a. This gets matched and then assigned to $z (and printed).
Maybe you don't want the stuff in front of the slash to be empty?
perl -le '$t="/b"; if ($t =~/^(+*?)\//){$z=$1}elsif($t=~/\/(.*)/){$z=$ +1} print $z'
|
|---|