On Jun 3, 2011, at 10:22 AM, Uri Guttman wrote: >> s> my $sortstr = substr("00$totalcells", -2); > that looks like you are forcing leading 0's. the common idiom for that > is sprintf "%02d", $totalcells. your way works but is harder to read.
Thanks, Uri. I didn't catch that. I didn't write this script. I'm using it to learn from and cleaning it up at the same time. I know that learning Perl from an older script probably isn't the best way to do it, but since I have a vested interest in how this script works, it's forcing me to learn it faster than I would otherwise. However, if anyone knows of a shopping cart written in modern perl, I'd love to have a look. >> s> $html =~ s|</td><td|</td>\n<td|g; > why are you doing that insert of a newline each time in that loop? you > don't use or modify $html anywhere else in this loop. Actually, it's being used on an HTML template and just makes the HTML code look cleaner. >> s> I want to use "$name" in another loop just after this one, but when I >> do, I get "Global symbol $name requires explicit package". > did you want to use $name as the loop variable again? that is perfectly > fine as this $name is scoped only to that loop. if you just want to use > $name for any other reason you need to just declare it with my. I wasn't very clear in what I wanted. Sorry. I wanted to use the value of $name in another loop but after testing, it looks like Shawn was correct when he wrote: > The variable used in a foreach loop is independent of anything outside the > loop. I actually had to use another variable in the second loop to grab the name. Thanks to everyone who responded. I got it to work now. Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/