[32876] in Perl-Users-Digest
Perl-Users Digest, Issue: 4154 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 25 18:09:38 2014
Date: Tue, 25 Feb 2014 15:09:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 25 Feb 2014 Volume: 11 Number: 4154
Today's topics:
Re: cookie <gravitalsun@hotmail.foo>
Re: cookie <gravitalsun@hotmail.foo>
Re: cookie <john@castleamber.com>
Re: cookie <john@castleamber.com>
Re: Dancer <john@castleamber.com>
Re: Dancer <rweikusat@mobileactivedefense.com>
hex print <triflemenot@protocol.invalid>
Re: hex print <rweikusat@mobileactivedefense.com>
Re: hex print <kaz@kylheku.com>
Re: hex print <triflemenot@protocol.invalid>
Re: hex print <triflemenot@protocol.invalid>
Re: hex print <gravitalsun@hotmail.foo>
Re: hex print <rweikusat@mobileactivedefense.com>
Re: hex print <triflemenot@protocol.invalid>
Re: hex print <cwilbur@chromatico.net>
Re: hex print <john@castleamber.com>
Re: hex print <triflemenot@protocol.invalid>
Re: hex print <rweikusat@mobileactivedefense.com>
Re: hex print <john@castleamber.com>
Re: hex print <triflemenot@protocol.invalid>
Re: hex print <triflemenot@protocol.invalid>
Re: use strict; use warnings; <ben@morrow.me.uk>
Re: use strict; use warnings; <ben@morrow.me.uk>
Re: use strict; use warnings; <ben@morrow.me.uk>
Re: use strict; use warnings; <rweikusat@mobileactivedefense.com>
Re: use strict; use warnings; <kaz@kylheku.com>
Re: use strict; use warnings; <rweikusat@mobileactivedefense.com>
Re: use strict; use warnings; <rweikusat@mobileactivedefense.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 25 Feb 2014 23:42:19 +0200
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: cookie
Message-Id: <lej2nr$ppk$1@news.ntua.gr>
> You obviously didn't try it. It works.
>
>> It is very tricky and can not be done without very carefully design and
>> testing.
>
> Actually it's rather simple if you understand the request-response
> nature of HTTP and that the CGI script is invoked for each request.
>
> Try to understand what the script does for these requests:
>
> ------------------------------------------------------------------------
> GET /xho.cgi HTTP/1.0
>
> ------------------------------------------------------------------------
> POST /xho.cgi HTTP/1.0
> Content-Type: application/x-www-form-urlencoded
>
> valid=invalid
>
> ------------------------------------------------------------------------
> POST /xho.cgi HTTP/1.0
> Content-Type: application/x-www-form-urlencoded
>
> valid=valid
>
> ------------------------------------------------------------------------
> GET /xho.cgi HTTP/1.0
> Cookie: valid=valid
>
> ------------------------------------------------------------------------
>
> hp
>
Well I try it. Not only this but several other similar or not
variations. I also can see the requests , but I can not see any cookie
at Firefox cookies.sqlite
I do not know, maybe I am doing something wrong, but I end up to
conclusion that you can not send any cookie (at lease through CGI) after
the header is printed
For not messing this post , I will post a stripped down variation of my
latest try
------------------------------
Date: Tue, 25 Feb 2014 23:43:32 +0200
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: cookie
Message-Id: <lej2q4$ppk$2@news.ntua.gr>
#!/usr/bin/perl
use strict;
use warnings;
use CGI qw/:standard -compile -nosticky/; $CGI::DISABLE_UPLOADS=1;
use CGI::Carp qw/fatalsToBrowser/;
my
$cgi = new CGI;
$cgi->autoEscape(1);
# First lets check if there is already a cookie at user browser
my %cookie_data = $cgi->cookie('LastActions');
if ((exists $cookie_data{Book}) && (exists $cookie_data{Time}))
{
# some code goes here
print CGI::redirect("http://www.cpan.org");
exit
}
print
$cgi->header(
-type => 'text/html',
-charset => 'UTF-8',
-encoding => 'UTF-8',
'-Content-Language' => 'el',
-lang => 'el-Greek',
-expires => '+10h',
-nph => 0,
-status => '200 ok'),
$cgi->start_html(
-title => 'Department Library',
-text => '#000080',
-bgcolor => 'white',
-head => Link({-rel=>'shortcut icon', -type=>'image/png',
-href=>'/favicon.ico'}));
print STDOUT<<STOP_PRINTING;
<style type="text/css">
.formfield { font-family: tahoma; font-size: 9pt; font-weight: 600;
color:#191970 ; background-color: #F0FFF0 }
.formbutton { font-family: tahoma; font-size: 9pt; font-weight: 700;
color:#191970 ; background-color: #F0F8FF }
</style>
STOP_PRINTING
print $cgi->start_multipart_form(-method=>'POST',
-enctype=>'multipart/form-data', -target=>'_self');
print q'<table
style="position:absolute;left:200px;top:150px;width:600px;z-index:0;"
cellpadding="0" cellspacing="1">
<tr><td colspan="2">'. $cgi->h3("Book check Application") .'</td></tr>
<tr><td style="height: 50px;"></td><td></td></tr>
<tr><td style="height: 40px; width: 80px;">Book</td><td>'.
$cgi->textfield
(
-name => 'Book',
-default => '',
-override => 1,
-maxlength => 80,
-size => 30,
-class => 'formfield'
)
.'</td></tr>
<tr><td style="height: 40px; width: 80px;">Shelf</td><td>'.
$cgi->textfield
(
-name => 'Shelf',
-default => '',
-override => 1,
-maxlength => 80,
-size => 30,
-class => 'formfield'
)
.'</td></tr>
<tr><td style="height: 40px;"></td><td></td></tr>
<tr><td colspan="2">'.
$cgi->submit( -name =>'SUBMIT', -value=>"Check",
-class=>'formbutton'). '  '.
$cgi->defaults(-name =>'RESET', -value=>"Reset", -class=>'formbutton')
.'</td></tr>
</table>';
print $cgi->end_multipart_form();
if ( defined $cgi->param('SUBMIT') )
{
print $cgi->redirect( -uri => "http://www.cpan.org", -cookie =>
cookie(-name=>'LastActions', -path=>'/', -secure=>0, -expires=>'+2h',
-value=>{ Book => $cgi->param('Book'), Shelf => $cgi->param('Shelf') } ) );
exit;
}
print $cgi->end_html();
exit 0;
------------------------------
Date: Tue, 25 Feb 2014 16:16:39 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: cookie
Message-Id: <87lhwyyh14.fsf@castleamber.com>
George Mpouras <gravitalsun@hotmail.foo> writes:
> I do not know, maybe I am doing something wrong, but I end up to
> conclusion that you can not send any cookie (at lease through CGI)
> after the header is printed
That's correct, if you mean with "header is printed" that all header(s)
have been send and a blank line. Hence, you must print your cookie
before that.
In Firefox, install the "Live HTTP Headers" add on to see what's being
send/received.
--
John Bokma j3b
Blog: http://johnbokma.com/ Perl Consultancy: http://castleamber.com/
Perl for books: http://johnbokma.com/perl/help-in-exchange-for-books.html
------------------------------
Date: Tue, 25 Feb 2014 16:19:46 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: cookie
Message-Id: <87eh2qygvx.fsf@castleamber.com>
George Mpouras <gravitalsun@hotmail.foo> writes:
> print $cgi->redirect( -uri => "http://www.cpan.org", -cookie
> => cookie(-name=>'LastActions', -path=>'/', -secure=>0,
> -expires=>'+2h', -value=>{ Book => $cgi->param('Book'), Shelf =>
> $cgi->param('Shelf') } ) );
I can imagine that setting a cookie and redirecting to a different
domain at the same time doesn't work. But again, check with Live HTTP
headers add on for firefox.
--
John Bokma j3b
Blog: http://johnbokma.com/ Perl Consultancy: http://castleamber.com/
Perl for books: http://johnbokma.com/perl/help-in-exchange-for-books.html
------------------------------
Date: Tue, 25 Feb 2014 13:14:01 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: Dancer
Message-Id: <8738j79f9i.fsf@castleamber.com>
George Mpouras <gravitalsun@hotmail.foo> writes:
> Στις 25/2/2014 02:20, ο/η alex.karelas@gmail.com έγραψε:
>> I believe you should use a templating system. Place the lists & textboxes in your template. That's a lot easier than with CGI.
>>
>> - Alex
>>
>>
>> On Friday, February 21, 2014 10:49:09 PM UTC+2, George Mpouras wrote:
>>> I try to evolve a little and start using the Dancer instead of CGI !
>>>
>>>
>>>
>>> I read some documentation but I still can not find where the drop down
>>>
>>> lists , textboxes , ... are !
>>>
>>>
>>>
>>> I am I missing something important or what ?
>>
>
> do you think it will be easier ; these templates are scary !
If you use Template Toolkit I recommend to check out how to include
parts, and how to use macros. In various projects I use macros to build
forms and it makes things very easy. Also common
header/footer/etc. parts can be just included.
--
John Bokma j3b
Blog: http://johnbokma.com/ Perl Consultancy: http://castleamber.com/
Perl for books: http://johnbokma.com/perl/help-in-exchange-for-books.html
------------------------------
Date: Tue, 25 Feb 2014 19:20:10 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Dancer
Message-Id: <87r46rq9sl.fsf@sable.mobileactivedefense.com>
George Mpouras <gravitalsun@hotmail.foo> writes:
> Στις 25/2/2014 02:20, ο/η alex.karelas@gmail.com έγραψε:
>> I believe you should use a templating system. Place the lists & textboxes in your template. That's a lot easier than with CGI.
[...]
>> On Friday, February 21, 2014 10:49:09 PM UTC+2, George Mpouras wrote:
>>> I try to evolve a little and start using the Dancer instead of CGI !
>>>
>>>
>>>
>>> I read some documentation but I still can not find where the drop down
>>>
>>> lists , textboxes , ... are !
>>>
>>>
>>>
>>> I am I missing something important or what ?
>>
>
> do you think it will be easier ; these templates are scary !
I have some experience with both approaches for HTML-generation[*] and I'd
chose the procedural one over the template-based one any time because it
is easier to use (if you're a programmer), can be used with less work
(by using programming language facilities for building abstractions) and
can result in code which is easier to understand (for the same reason).
[*] Insofar templating goes, only with JSF/ RichFaces together with Java
which might not be a good example of a templating system. OTOH, I did an
informal 'survey' of 'Perl templating systems' some years ago because
they were "Very Recommended" and came to the conclusion that there
weren't any I'd want to use.
------------------------------
Date: Tue, 25 Feb 2014 19:48:18 +0000
From: Trifle Menot <triflemenot@protocol.invalid>
Subject: hex print
Message-Id: <1aspg95ksbbcc3biibpue2l19q2ti3errc@4ax.com>
To print a string
> my $data = 'abc123';
in hex, separated by single spaces
> 61 62 63 31 32 33
can it be done without looping?
------------------------------
Date: Tue, 25 Feb 2014 20:10:17 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: hex print
Message-Id: <87ios3q7h2.fsf@sable.mobileactivedefense.com>
Trifle Menot <triflemenot@protocol.invalid> writes:
> To print a string
>
>> my $data = 'abc123';
>
> in hex, separated by single spaces
>
>> 61 62 63 31 32 33
>
> can it be done without looping?
[rw@sable]~#perl -e 'print(join(" ", unpack("(H2)*", "abc123")), "\n");'
61 62 63 31 32 33
------------------------------
Date: Tue, 25 Feb 2014 20:26:24 +0000 (UTC)
From: Kaz Kylheku <kaz@kylheku.com>
Subject: Re: hex print
Message-Id: <20140225122516.697@kylheku.com>
On 2014-02-25, Trifle Menot <triflemenot@protocol.invalid> wrote:
> To print a string
>
>> my $data = 'abc123';
>
> in hex, separated by single spaces
>
>> 61 62 63 31 32 33
>
> can it be done without looping?
.. and for bonus points, while chained and straitjacketed, suspended in a
plexiglass tank full of water, and without using the character $ anywhere?
------------------------------
Date: Tue, 25 Feb 2014 20:32:03 +0000
From: Trifle Menot <triflemenot@protocol.invalid>
Subject: Re: hex print
Message-Id: <snupg99ooo999akj6d25qstftqmk1ldclh@4ax.com>
On Tue, 25 Feb 2014 20:10:17 +0000, Rainer Weikusat
<rweikusat@mobileactivedefense.com> wrote:
>> To print a string
>>
>>> my $data = 'abc123';
>>
>> in hex, separated by single spaces
>>
>>> 61 62 63 31 32 33
>>
>> can it be done without looping?
>[rw@sable]~#perl -e 'print(join(" ", unpack("(H2)*", "abc123")), "\n");'
>61 62 63 31 32 33
Thanks.
But to minimize it, I think I will eliminate the print() and unpack()
parentheses.
fw:~/temp # perl -e 'print join (" ", unpack "(H2)*", "abc123"), "\n";'
61 62 63 31 32 33
The (H2) parentheses create list context, I suppose? That was the
tricky part I couldn't work out on my own.
------------------------------
Date: Tue, 25 Feb 2014 20:36:34 +0000
From: Trifle Menot <triflemenot@protocol.invalid>
Subject: Re: hex print
Message-Id: <sfvpg9hegmjmuujufhh1loscs8vs63l1vu@4ax.com>
On Tue, 25 Feb 2014 20:26:24 +0000 (UTC), Kaz Kylheku <kaz@kylheku.com>
wrote:
>> can it be done without looping?
>.. and for bonus points, while chained and straitjacketed, suspended in a
>plexiglass tank full of water, and without using the character $ anywhere?
I do have a need for it, and wanted to find the best way.
------------------------------
Date: Tue, 25 Feb 2014 22:48:01 +0200
From: George Mpouras <gravitalsun@hotmail.foo>
Subject: Re: hex print
Message-Id: <leivi1$hsq$1@news.ntua.gr>
Στις 25/2/2014 21:48, ο/η Trifle Menot έγραψε:
> To print a string
>
>> my $data = 'abc123';
>
> in hex, separated by single spaces
>
>> 61 62 63 31 32 33
>
> can it be done without looping?
>
$_ = 'abc123';
s/\w/unpack('H2',$&).' '/ge;
print;
------------------------------
Date: Tue, 25 Feb 2014 20:50:59 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: hex print
Message-Id: <87eh2qrk5o.fsf@sable.mobileactivedefense.com>
Trifle Menot <triflemenot@protocol.invalid> writes:
> On Tue, 25 Feb 2014 20:10:17 +0000, Rainer Weikusat
> <rweikusat@mobileactivedefense.com> wrote:
>
>>> To print a string
>>>
>>>> my $data = 'abc123';
>>>
>>> in hex, separated by single spaces
>>>
>>>> 61 62 63 31 32 33
>>>
>>> can it be done without looping?
>
>>[rw@sable]~#perl -e 'print(join(" ", unpack("(H2)*", "abc123")), "\n");'
>>61 62 63 31 32 33
>
> Thanks.
>
> But to minimize it, I think I will eliminate the print() and unpack()
> parentheses.
>
> fw:~/temp # perl -e 'print join (" ", unpack "(H2)*", "abc123"), "\n";'
> 61 62 63 31 32 33
>
> The (H2) parentheses create list context, I suppose?
It make no sense to talk about 'list context' here as 'pack' and
'unpack' specifiers are written in a formal language other than
perl. The () mark a group here so (for unpack)
(H2)*
means 'as many two-digit hex numbers as can be pulled out of the
input'.
------------------------------
Date: Tue, 25 Feb 2014 21:10:44 +0000
From: Trifle Menot <triflemenot@protocol.invalid>
Subject: Re: hex print
Message-Id: <br0qg9h4m7ku21mdl6rlrqse5veov76u1i@4ax.com>
On Tue, 25 Feb 2014 20:50:59 +0000, Rainer Weikusat
<rweikusat@mobileactivedefense.com> wrote:
>> The (H2) parentheses create list context, I suppose?
>It make no sense to talk about 'list context' here as 'pack' and
>'unpack' specifiers are written in a formal language other than
>perl. The () mark a group here so (for unpack)
>(H2)*
>means 'as many two-digit hex numbers as can be pulled out of the
>input'.
I thought an asterisk, by itself, meant "as many as can be pulled from
the input." That was one of the things I tried earlier, and failed. But
I threw that code away, so I don't remember exactly what I tried.
The parentheses seem to add some magic. I thought the "magic" was list
context. But I'll take your word for it.
------------------------------
Date: Tue, 25 Feb 2014 16:29:00 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: hex print
Message-Id: <87d2iarieb.fsf@new.chromatico.net>
>>>>> "T" == Trifle Menot <triflemenot@protocol.invalid> writes:
T> To print a string
>> my $data = 'abc123';
T> in hex, separated by single spaces
>> 61 62 63 31 32 33
T> can it be done without looping?
No. Something will need to iterate; the best you can accomplish is
making it implicit rather than explicit.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Tue, 25 Feb 2014 16:13:38 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: hex print
Message-Id: <87ppmayh65.fsf@castleamber.com>
Trifle Menot <triflemenot@protocol.invalid> writes:
> On Tue, 25 Feb 2014 20:50:59 +0000, Rainer Weikusat
> <rweikusat@mobileactivedefense.com> wrote:
>>(H2)*
[..]
> The parentheses seem to add some magic. I thought the "magic" was list
> context. But I'll take your word for it.
Don't: perldoc -f pack
"
· A ()-group is a sub-TEMPLATE enclosed in parentheses.
A group may take a repeat count, both as postfix,
"
--
John Bokma j3b
Blog: http://johnbokma.com/ Perl Consultancy: http://castleamber.com/
Perl for books: http://johnbokma.com/perl/help-in-exchange-for-books.html
------------------------------
Date: Tue, 25 Feb 2014 22:33:20 +0000
From: Trifle Menot <triflemenot@protocol.invalid>
Subject: Re: hex print
Message-Id: <fc5qg91jksd0r5fea1gh3rm0bkrl8upkv8@4ax.com>
On Tue, 25 Feb 2014 16:29:00 -0500, Charlton Wilbur
<cwilbur@chromatico.net> wrote:
>>>>>> "T" == Trifle Menot <triflemenot@protocol.invalid> writes:
>
> T> To print a string
> >> my $data = 'abc123';
>
> T> in hex, separated by single spaces
>
> >> 61 62 63 31 32 33
>
> T> can it be done without looping?
>
>No. Something will need to iterate; the best you can accomplish is
>making it implicit rather than explicit.
I know what assembly language is, so I understand what you mean. But
those words may confuse people who only want to learn enough Perl to
solve their immediate problem.
It's not always wise to say everything you know.
------------------------------
Date: Tue, 25 Feb 2014 22:34:16 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: hex print
Message-Id: <871tyqrfdj.fsf@sable.mobileactivedefense.com>
John Bokma <john@castleamber.com> writes:
> Trifle Menot <triflemenot@protocol.invalid> writes:
>
>> On Tue, 25 Feb 2014 20:50:59 +0000, Rainer Weikusat
>> <rweikusat@mobileactivedefense.com> wrote:
>
>>>(H2)*
>
> [..]
>
>> The parentheses seem to add some magic. I thought the "magic" was list
>> context. But I'll take your word for it.
>
> Don't: perldoc -f pack
>
> "
> A ()-group is a sub-TEMPLATE enclosed in parentheses.
> A group may take a repeat count, both as postfix,
> "
Is this supposed to contradict
,----
|The () mark a group here so (for unpack)
|
|(H2)*
|
|means 'as many two-digit hex numbers as can be pulled out of the
|input'.
`----#
?
If so, how?
------------------------------
Date: Tue, 25 Feb 2014 16:40:32 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: hex print
Message-Id: <87lhwyvmsf.fsf@castleamber.com>
Rainer Weikusat <rweikusat@mobileactivedefense.com> writes:
> John Bokma <john@castleamber.com> writes:
>> Trifle Menot <triflemenot@protocol.invalid> writes:
>>
>>> On Tue, 25 Feb 2014 20:50:59 +0000, Rainer Weikusat
>>> <rweikusat@mobileactivedefense.com> wrote:
>>
>>>>(H2)*
>>
>> [..]
>>
>>> The parentheses seem to add some magic. I thought the "magic" was list
>>> context. But I'll take your word for it.
>>
>> Don't: perldoc -f pack
>>
>> "
>> · A ()-group is a sub-TEMPLATE enclosed in parentheses.
>> A group may take a repeat count, both as postfix,
>> "
>
> Is this supposed to contradict
>
>
> ,----
> |The () mark a group here so (for unpack)
> |
> |(H2)*
> |
> |means 'as many two-digit hex numbers as can be pulled out of the
> |input'.
> `----#
>
> ?
>
> If so, how?
No, it's not a contradiction. But a recommendation not to take someone's
word on Usenet for something if one can read the documentation.
Don't take it personal, it was not meant that way, and my apologies if
you read it as such.
--
John Bokma j3b
Blog: http://johnbokma.com/ Perl Consultancy: http://castleamber.com/
Perl for books: http://johnbokma.com/perl/help-in-exchange-for-books.html
------------------------------
Date: Tue, 25 Feb 2014 22:44:53 +0000
From: Trifle Menot <triflemenot@protocol.invalid>
Subject: Re: hex print
Message-Id: <sj6qg9hbd9kassc7ae9pn0qtkirpqep1t3@4ax.com>
On Tue, 25 Feb 2014 16:13:38 -0600, John Bokma <john@castleamber.com>
wrote:
>>>(H2)*
>
>[..]
>
>> The parentheses seem to add some magic. I thought the "magic" was list
>> context. But I'll take your word for it.
>
>Don't: perldoc -f pack
>
>"
> A ()-group is a sub-TEMPLATE enclosed in parentheses.
> A group may take a repeat count, both as postfix,
>"
I read that earlier, when I was trying and failing.
But with so much scalar and list context swirling around in my head, it
just didn't sink in the first time.
Seems clear now though.
------------------------------
Date: Tue, 25 Feb 2014 22:59:43 +0000
From: Trifle Menot <triflemenot@protocol.invalid>
Subject: Re: hex print
Message-Id: <mc7qg9po079udeg50cmlgnp0n9nietrna2@4ax.com>
On Tue, 25 Feb 2014 16:40:32 -0600, John Bokma <john@castleamber.com>
wrote:
>No, it's not a contradiction. But a recommendation not to take someone's
>word on Usenet for something if one can read the documentation.
Right. I did not take it as a contradiction.
And I agree it's best to read first and ask questions later. But some of
us are slow, and read something 10 times before we get it.
Slow doesn't mean stupid, it just means slow. People learn in different
ways and at different rates. A little help from another human can speed
things along.
------------------------------
Date: Tue, 25 Feb 2014 19:54:36 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: use strict; use warnings;
Message-Id: <s09vta-bps2.ln1@anubis.morrow.me.uk>
Quoth Justin C <justin.1401@purestblue.com>:
> On 2014-02-24, Ben Morrow <ben@morrow.me.uk> wrote:
> >
> > Later on you will meet globs, which have a * sigil; again, this is not
> > related in any way to the use of * to mean multiplication.
>
> I think I've only ever used globs when doing the exercises in
> Learning Perl.
Well, you have in fact used globs every time you wrote
open my $X, ...;
but you may not have explicitly realised you were doing so.
Ben
------------------------------
Date: Tue, 25 Feb 2014 19:57:30 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: use strict; use warnings;
Message-Id: <a69vta-bps2.ln1@anubis.morrow.me.uk>
Quoth Henry Law <news@lawshouse.org>:
> On 24/02/14 17:32, Marek Novotny wrote:
> > I actually think they are using the wrong word in their description.
>
> I actually think you are smarter than your instructors, even though they
> know more than you do at present.
I agree. In fact, if you're someone who can learn from books, you may
well be better off forgetting about the Perl courses you have been
offered and just sticking to Learning Perl, which is written by people
who *do* know how to teach Perl. (Of course, there may be some
administrative advantage to being able to say you've done an 'official'
Perl course.)
Ben
------------------------------
Date: Tue, 25 Feb 2014 19:52:50 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: use strict; use warnings;
Message-Id: <it8vta-bps2.ln1@anubis.morrow.me.uk>
Quoth Jrgen Exner <jurgenex@hotmail.com>:
> Ben Morrow <ben@morrow.me.uk> wrote:
> >It's not uncommon, when talking about languages like Perl which index
> >from 0, to start the ordinals at 'zeroth'.
>
> Only by those people, who also celebrated the start of the third
> millenium at the end of 1999.
No, that's the opposite problem: the Gregorian calendar is 1-indexed.
Ben
------------------------------
Date: Tue, 25 Feb 2014 21:37:25 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: use strict; use warnings;
Message-Id: <87a9deri0a.fsf@sable.mobileactivedefense.com>
Ben Morrow <ben@morrow.me.uk> writes:
> Quoth Jrgen Exner <jurgenex@hotmail.com>:
>> Ben Morrow <ben@morrow.me.uk> wrote:
>> >It's not uncommon, when talking about languages like Perl which index
>> >from 0, to start the ordinals at 'zeroth'.
>>
>> Only by those people, who also celebrated the start of the third
>> millenium at the end of 1999.
>
> No, that's the opposite problem: the Gregorian calendar is 1-indexed.
The Gregorian calender isn't indexed at all because time is not a
random-access sequence. But it is a nice example to illustrate the
differnce: 1AD is the year were Christ turned 1. That's the first year
after his birth. The first millenium ended with with 1000th year after
his birth, hence, the first year of the 2nd millenium was
1001. Ultimatively, the sequence of 'year numbers' comes into being as
years are being counted: The number for each new years is 'number of
years we have seen so far + 1'. There was never a year with 'number 0'
because 0 was the state 'no years seen so far'. This basic model works
the same of any (ordered) sequence of things.
OTOH, 'array indexing' is a surjective function F:X -> Y which maps
'some set of numbers' to 'some set of elements'. Depending on the
programming language which is being used, there may be some additional
restrictions placed on X, eg, 'the smallest element in X is always 0'
for C or 'the smallest element in X is always $[' for traditional Perl
or 'X may be any subset of the set of integers' for Pascal (and even
more). But regardless of that, there's always a 'first element' which is
the one corresponding with the smallest element of X for some specific
function.
I completely believe that some people refer to 'the zeroth element' if
array indexing happens to be 0-based that the same people will happily
call the first element of an array whose smallest index is -43 the 'minus
43th element'. I've encountered similar logic in a NIC-driver some years
ago where the RX DMA-ring was indexed by an index and the TX ring by an
outdex, ie "Why would I care about anything except my current,
myopic perspective?". But that's not a useful attitude for either
communication of higher-order abstractions.
------------------------------
Date: Tue, 25 Feb 2014 22:15:23 +0000 (UTC)
From: Kaz Kylheku <kaz@kylheku.com>
Subject: Re: use strict; use warnings;
Message-Id: <20140225140325.140@kylheku.com>
On 2014-02-25, Rainer Weikusat <rweikusat@mobileactivedefense.com> wrote:
> years are being counted: The number for each new years is 'number of
> years we have seen so far + 1'. There was never a year with 'number 0'
> because 0 was the state 'no years seen so far'. This basic model works
> the same of any (ordered) sequence of things.
Even within measurement of time, not everything is idiotically one-based,
luckily. The time after 23:59 is 00:00 (though twelve-hour time hides zero by
calling it twelve). The first minute of every hour is 00, with seconds that go
from 0 to 59.
> I completely believe that some people refer to 'the zeroth element' if
> array indexing happens to be 0-based that the same people will happily
> call the first element of an array whose smallest index is -43 the 'minus
> 43th element'.
That should be "minus forty-THIRD element", damn it! It is a perfectly grammatical ordinal, with a clear meaning.
Zeroth is a word, appearing in dictionaries and everything:
http://www.merriam-webster.com/dictionary/zeroth
The nut on a guiar is also the "zeroth fret" (and some instruments actually
have such a fret). Wikipedia has a page on it, calling it the "zero fret".
> I've encountered similar logic in a NIC-driver some years
> ago where the RX DMA-ring was indexed by an index and the TX ring by an
> outdex, ie "Why would I care about anything except my current,
> myopic perspective?". But that's not a useful attitude for either
> communication of higher-order abstractions.
"zeroth" does not entail a whimsical reinterpretation of a word fragment like
"outdex".
------------------------------
Date: Tue, 25 Feb 2014 22:17:30 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: use strict; use warnings;
Message-Id: <8761o2rg5h.fsf@sable.mobileactivedefense.com>
Rainer Weikusat <rweikusat@mobileactivedefense.com> writes:
[...]
> OTOH, 'array indexing' is a surjective function F:X -> Y which maps
> 'some set of numbers' to 'some set of elements'. Depending on the
> programming language which is being used, there may be some additional
> restrictions placed on X, eg,
[...]
> 'X may be any subset of the set of integers' for Pascal
This is an exaggeration. It may consist of the members of any interval
which is a subset of the set of integers (or however this can be
described).
------------------------------
Date: Tue, 25 Feb 2014 22:53:48 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: use strict; use warnings;
Message-Id: <87wqgipzwj.fsf@sable.mobileactivedefense.com>
Kaz Kylheku <kaz@kylheku.com> writes:
> On 2014-02-25, Rainer Weikusat <rweikusat@mobileactivedefense.com> wrote:
>> years are being counted: The number for each new years is 'number of
>> years we have seen so far + 1'. There was never a year with 'number 0'
>> because 0 was the state 'no years seen so far'. This basic model works
>> the same of any (ordered) sequence of things.
>
> Even within measurement of time, not everything is idiotically one-based,
> luckily. The time after 23:59 is 00:00 (though twelve-hour time hides zero by
> calling it twelve). The first minute of every hour is 00, with seconds that go
> from 0 to 59.
Yet you refer to that as 'first minute', not 'zeroth minute'. That's
consistent with the idea that it is the first new minute observed after
hh:59, ie, something observable is being counted here.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 4154
***************************************