[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Commify and "1 while" syntax



Hi everyone,

I was racking my brain last night over this one:

	1 while ($number =~ s/^(-?\d+)(\d{3})/$1,$2/);

This will add commas into a number string and is similar to the example in
the Programming Perl book (2d Edition) on page 74.  I understand that the
"1 while" will make Perl repeatedly match the regular expression and apply
it to $number, resulting in commas in the appropriate spots.

My question is what is the "1" preceding "while" for?  You can change the
"1" to something else (e.g. "2", or "FOO" or "x") and it still works
properly, but you can't eliminate it entirely.  I can't find any
explanation as to what this string preceding the while is supposed to do.
I can take it on faith that this is appropriate syntax, but I like to
understand what is going on!

Thanks for any help.

Darryl Tang


_________________________________________________________

Yoshi's Franchise Corporation
of America, Inc.

http://www.yoshisonline.com


-end message-





===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org