cpan you have to see

Edmund von der Burg evdb at
Wed Dec 12 17:23:23 GMT 2012

On 12 December 2012 17:05, Alexej Magura <perlook at> wrote:
> Okay, allow me to clarify what the TrueFalse module that I wrote is trying
> to emulate.  It's trying to emulate the 'true' and 'false' user commands
> available under Linux.
> Haven't you ever done something like this in Unix Shell?
> while true; do ls /var/log/; sleep 5s; clear; done
> The statment 'true' in this example, as far as I know, only returns true
> and that's it.  It may not look very useful, but it can be useful when
> you just need to do something and just want to write 'Just because I
> said so, keep doing A until I say stop.'
> I'm sorry if all of you think that my modules are poorly written, but if
> you want me to take you seriously, then say something productive for a
> change, that is make some suggestions (I'm open to suggestions.)

Each language has its own idioms and ways to do things. In shell
scripting the while true ... done loop is one of them.

In Perl the equivalent would be while (1) { .... }

I can understand that you want to make some of the Perl code you write
more familiar by using constructs from other languages. However in
this particular case you are making it more confusing for other
developers. Your use of true or True means that they'll see something
that reads well, but the exact behaviour of that code is not clear.
However using something like '1' is unambiguous - 1 is almost always
used when you need a true value.

I'd suggest bringing across ideas from other languages, but using the
language's own syntax to express them :)


PS should 'True' not return 1 rather than 0?

PPS if you do want to spell out true in your code you could add something like:

use Readonly;
Readonly my $TRUE => 1;


while ( $TRUE ) {

# This will tell other developers that $TRUE is a variable (as it
starts with a $) and lets them search for it in the same file that the
use is in so they can see its value. It also can't be changed
accidentally as it is readonly (

More information about the mailing list