I have been trying several regular expressions in the substitution operator:
$str =~ s/^0+(.)/$1/;
converts 0000 to 0 and 0001 to 1
$str =~ s/^0+./$1/;
converts 0000 to empty string, 000100 to 00, 0001100 to 100.
what difference is the parentheses making?
This seems like a bit of a misuse to me – you need the () to identify what’s your match.
http://perldoc.perl.org/perlre.html
So basically you can use
If you have more than one grouped matches they will be $1, $2, $3… etc e.g.
if ($str =~ /(0*)(1*)/) { print "I've got $1 and $2"; }