Re: using HTML::Template effectively

Discussion in 'Perl Misc' started by Rainer Weikusat, Jun 27, 2012.

  1. Ben Morrow <> writes:

    [...]

    >> It's too much work cleaning up after the nasal demons when they get on
    >> your keyboard.

    >
    > In principle there are no nasal demons in Perl. If perl ever does
    > something undefined, that's a bug in perl (or possibly in an XS module
    > you've loaded).


    It is generally impossible to 'do something undefined' (although
    certain people who frequent C-related newsgroups apparently can't ever
    get the meaning of this adjective into their head). When the C
    standard states that 'in such-and-such a case, the behaviour is
    undefined', this is defined as 'the C standard imposes no requirements
    for this situation', or, in other words, it contains no specific
    information regarding it. Insofar such information is desired, it can
    usually be obtained in some other way. A C implementation which would
    cause a computer to turn into a dancing icebear in some situation where
    the C standard 'leaves the behaviour undefined' would not be
    considered non-compliant because of this. But this doesn't mean it
    such an implementation is possible and completely wild speculations
    of this kind belong in the realm of fiction.

    That said, there's at least one case where the behaviour of perl
    (5.10.1) is not defined. The documentation of the sort operator states
    that

    In list context, this sorts the LIST and returns the sorted
    list value.In scalar context, the behaviour of "sort()" is
    undefined.
    Rainer Weikusat, Jun 27, 2012
    #1
    1. Advertising

  2. Rainer Weikusat

    Justin C Guest

    Re: sort in scalar context; undefined behaviour in Perl

    On 2012-06-29, Cal Dershowitz <> wrote:
    >
    > What is FUD?


    http://lmgtfy.com/?q=fud&l=1


    Justin.

    --
    Justin C, by the sea.
    Justin C, Jun 29, 2012
    #2
    1. Advertising

  3. Re: sort in scalar context; undefined behaviour in Perl

    >>>>> "Ben" == Ben Morrow <> writes:

    Ben> In this case, I presume there was an idea at some point that sort in
    Ben> scalar (void?) context could be used to sort an array in place, and
    Ben> rather than explain that properly someone thought it would be better
    Ben> just to throw some 'undefined's around. In fact, I very much doubt this
    Ben> will ever happen, given that

    Ben> @ary = sort @ary;

    Ben> is already optimised to sort in place.

    There was also a patch submitted at one time (tongue-in-cheek) to have
    sort in a scalar context invoke "nethack", based on a sentence in one of
    the early editions of Learning Perl.

    print "Just another Perl hacker,"; # the original

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
    <> <URL:http://www.stonehenge.com/merlyn/>
    Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
    See http://methodsandmessages.posterous.com/ for Smalltalk discussion
    Randal L. Schwartz, Jun 29, 2012
    #3
  4. Re: sort in scalar context; undefined behaviour in Perl

    >>>>> "Cal" == Cal Dershowitz <> writes:

    Cal> Are there illegal filenames in perl? What is the character class of legal
    Cal> characters in a filename?

    Perl defers those choices to the underlying operating system.

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
    <> <URL:http://www.stonehenge.com/merlyn/>
    Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
    See http://methodsandmessages.posterous.com/ for Smalltalk discussion
    Randal L. Schwartz, Jul 4, 2012
    #4
  5. Rainer Weikusat

    Ivan Shmakov Guest

    random string generation

    >>>>> Cal Dershowitz <> writes:

    [...]

    > Also, if you were going to design a character class such that it was
    > to be used in randomly-generating prefixes for files, which would you
    > use?


    > As for me, o O 0 ~ ` < > i 1 I { } [ ] | wouldn't make the first cut.


    Depending on the task, I'd generate a wide enough random number
    (or a UUID), and encode it with a Base32 variant, such as the
    Crockford's one. Like, e. g.:

    #!/usr/bin/perl

    use strict;
    use warnings;

    require Convert::Base32::Crockford;
    require UUID;

    UUID::generate (my $uuid);
    UUID::unparse ($uuid, my $s);
    my $fn
    = Convert::Base32::Crockford::encode_base32 ($uuid);
    print ($fn, "\n");

    Then, when looking the file up by the user's supplied name, I'd
    convert the latter into upper case, and replace [oO] with 0 and
    [iIlL] with 1.

    Alternatively, the RFC 4648 Base32 variant may be used, which
    includes B but not 8 (which could be confused with the former.)

    http://en.wikipedia.org/wiki/Base32

    [...]

    --
    FSF associate member #7257
    Ivan Shmakov, Jul 7, 2012
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J. Gleixner

    Re: using HTML::Template effectively

    J. Gleixner, Jun 26, 2012, in forum: Perl Misc
    Replies:
    0
    Views:
    462
    J. Gleixner
    Jun 26, 2012
  2. Peter Makholm

    Re: using HTML::Template effectively

    Peter Makholm, Jun 27, 2012, in forum: Perl Misc
    Replies:
    0
    Views:
    439
    Peter Makholm
    Jun 27, 2012
  3. Rainer Weikusat

    Re: using Template effectively

    Rainer Weikusat, Aug 21, 2012, in forum: Perl Misc
    Replies:
    0
    Views:
    335
    Rainer Weikusat
    Aug 21, 2012
  4. Rainer Weikusat

    Re: using Template effectively

    Rainer Weikusat, Aug 21, 2012, in forum: Perl Misc
    Replies:
    0
    Views:
    324
    Rainer Weikusat
    Aug 21, 2012
  5. Peter J. Holzer

    Re: using Template effectively

    Peter J. Holzer, Aug 21, 2012, in forum: Perl Misc
    Replies:
    7
    Views:
    479
    Rainer Weikusat
    Aug 23, 2012
Loading...

Share This Page