pattern matching - What does s-/-- and s-/\Z-- in perl mean? -
i beginner in perl , have query regarding pattern matching. came across line in perl written
$variable =~ s-/\z--; and code goes ahead variable assigned
$variable1 =~ s-/--; can please tell me these 2 lines do? want know s-/\z-- , s-/-- mean.
$variable =~ s-/\z--; - used delimiter here. however, best practice suggests either use / or {} delimiters.
it re-written as:
$variable =~ s{/\z}{}; # remove / @ end of string consider:
$variable1 =~ s-/--; again, re-written as:
$variable1 =~ s{/}{}; # remove first /
Comments
Post a Comment