Jim Angstadt wrote: > Dear Joe and Dirk, > > Thanks for getting me to look at assertions. > > Expanding the requirement a little, > here is what I have so far: > > my @nums = qw/ 00123 04 004.01 000 00 0 .0 > 0.01 0012.001 000.0001 /; > foreach ( @nums ) { > s/(\b)0+(?=\d)(\.*.*)/$1$2/g; # fails on 0.01 > print $_, "\n"; > } > > Any ideas?
Try this one: use strict; my @nums = qw(00123 04 004.01 000 00 0 .0 0.01 0012.001 000.0001); $_ = join ' ', @nums; # save orig for bottom part foreach (@nums) { print "$_ => "; s/(?<!\.)\b0+(?=[\d\.])//g; print "$_\n"; } # doing them all at once also works: print "$_\n"; s/(?<!\.)\b0+(?=[\d\.])//g; print "$_\n"; -- ,-/- __ _ _ $Bill Luebkert ICQ=14439852 (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl) -/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/ _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs