[30938] in Perl-Users-Digest
Perl-Users Digest, Issue: 2183 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 5 03:09:46 2009
Date: Thu, 5 Feb 2009 00:09:11 -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 Thu, 5 Feb 2009 Volume: 11 Number: 2183
Today's topics:
error printing page using LWP::Simple <larry@example.invalid>
Re: error printing page using LWP::Simple <noreply@gunnar.cc>
Re: error printing page using LWP::Simple <tim@burlyhost.com>
Re: error printing page using LWP::Simple <larry@example.invalid>
Re: error printing page using LWP::Simple <larry@example.invalid>
Re: error printing page using LWP::Simple <peter@makholm.net>
File handle to "in memory" file <devnull4711@web.de>
new CPAN modules on Thu Feb 5 2009 (Randal Schwartz)
OT: Re: Perl Peeves <bruce-usenet@noreplybicycle.synonet.comnoreply>
Re: Perl Peeves <hansmu@xs4all.nl>
Re: Perl Peeves <bruce-usenet@noreplybicycle.synonet.comnoreply>
Re: what is the best way to convert a formatted time to <jurgenex@hotmail.com>
Re: what is the best way to convert a formatted time to <noreply@gunnar.cc>
Re: what is the best way to convert a formatted time to <rabbits77@my-deja.com>
Re: what is the best way to convert a formatted time to <jurgenex@hotmail.com>
Re: what is the best way to convert a formatted time to <tim@burlyhost.com>
Re: what is the best way to convert a formatted time to <rabbits77@my-deja.com>
Re: what is the best way to convert a formatted time to <tim@burlyhost.com>
Re: what is the best way to convert a formatted time to <thegist@nospam.net>
Re: what is the best way to convert a formatted time to <uri@stemsystems.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 4 Feb 2009 16:23:28 -0700
From: Larry Gates <larry@example.invalid>
Subject: error printing page using LWP::Simple
Message-Id: <xcckk25j2pwr$.dgx3g8xd42i6$.dlg@40tude.net>
use strict;
use warnings;
use LWP::Simple;
# load the complete content of the url in question
# via LWP::Simple::get(...)
my $t = get 'http://www.fourmilab.ch/cgi-bin/
Yoursky?z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
print "t is $t";
# perl scraper2.pl
C:\MinGW\source>perl scraper2.pl
Use of uninitialized value in concatenation (.) or string at scraper2.pl
line 14
.
t is
C:\MinGW\source>
I would have expected $t to have the whole page. What gives?
--
larry gates
tmps_base = tmps_max; /* protect our mortal string */
-- Larry Wall in stab.c from the perl source code
------------------------------
Date: Thu, 05 Feb 2009 00:49:55 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: error printing page using LWP::Simple
Message-Id: <6uunt5FhglhnU1@mid.individual.net>
Larry Gates wrote:
> use strict;
> use warnings;
> use LWP::Simple;
>
> # load the complete content of the url in question
> # via LWP::Simple::get(...)
>
> my $t = get 'http://www.fourmilab.ch/cgi-bin/
> Yoursky?z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
>
> print "t is $t";
>
> # perl scraper2.pl
>
> C:\MinGW\source>perl scraper2.pl
> Use of uninitialized value in concatenation (.) or string at scraper2.pl
> line 14
> .
> t is
> C:\MinGW\source>
>
> I would have expected $t to have the whole page. What gives?
I don't know. It works for me.
However, the site disallows via robots.txt automatic access to their
cgi-bin, so whatever you are attempting to do, you'd better stop doing it.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 04 Feb 2009 15:53:25 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: error printing page using LWP::Simple
Message-Id: <VTpil.630$6G3.269@newsfe15.iad>
Larry Gates wrote:
> use strict;
> use warnings;
> use LWP::Simple;
>
> # load the complete content of the url in question
> # via LWP::Simple::get(...)
>
> my $t = get 'http://www.fourmilab.ch/cgi-bin/
> Yoursky?z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
>
> print "t is $t";
>
> # perl scraper2.pl
>
> C:\MinGW\source>perl scraper2.pl
> Use of uninitialized value in concatenation (.) or string at
> scraper2.pl line 14
> .
> t is
> C:\MinGW\source>
>
> I would have expected $t to have the whole page. What gives?
Where is all of the code? Your example only has maybe 10 lines,
including comments, yet it shows the concatenation error on line 14.
Try giving $t a value before expecting the result from get. The above
code should work without error, but it doesn't seem you've provided all
of the actual code above.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Wed, 4 Feb 2009 22:00:18 -0700
From: Larry Gates <larry@example.invalid>
Subject: Re: error printing page using LWP::Simple
Message-Id: <1nqxrvdj41f5b$.1877nbjjmr2n4$.dlg@40tude.net>
On Wed, 04 Feb 2009 15:53:25 -0800, Tim Greer wrote:
> Larry Gates wrote:
>
>> I would have expected $t to have the whole page. What gives?
>
> Where is all of the code? Your example only has maybe 10 lines,
> including comments, yet it shows the concatenation error on line 14.
> Try giving $t a value before expecting the result from get. The above
> code should work without error, but it doesn't seem you've provided all
> of the actual code above.
# use strict;
use warnings;
use LWP::Simple;
# load the complete content of the url in question
# via LWP::Simple::get(...)
my $t = get 'http://www.fourmilab.ch/cgi-
bin/
Yoursky?z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
print "t is $t";
# perl scraper2.pl
I tend to leave more whitespace in production.
--
larry gates
stab_val(stab)->str_nok = 1; /* what a wonderful hack! */
-- Larry Wall in stab.c from the perl source code
------------------------------
Date: Wed, 4 Feb 2009 22:02:09 -0700
From: Larry Gates <larry@example.invalid>
Subject: Re: error printing page using LWP::Simple
Message-Id: <h532tfh1n68l.1l24r9n9woknf.dlg@40tude.net>
On Thu, 05 Feb 2009 00:49:55 +0100, Gunnar Hjalmarsson wrote:
> However, the site disallows via robots.txt automatic access to their
> cgi-bin, so whatever you are attempting to do, you'd better stop doing it.
Really? It didn't occur to me I was doing something naughty.
--
larry gates
And other operators aren't so special syntactically, but weird
in other ways, like "scalar", and "goto".
-- Larry Wall in <199711071749.JAA29751@wall.org>
------------------------------
Date: Thu, 05 Feb 2009 09:01:30 +0100
From: Peter Makholm <peter@makholm.net>
Subject: Re: error printing page using LWP::Simple
Message-Id: <871vude2hx.fsf@vps1.hacking.dk>
Larry Gates <larry@example.invalid> writes:
> I would have expected $t to have the whole page. What gives?
Read the fine documentation for LWP::Simple. The get() function
returns undef if it fails. To examine why, you probably need to use a
non-simple interface.
//Makholm
------------------------------
Date: Thu, 05 Feb 2009 07:42:52 +0100
From: Frank Seitz <devnull4711@web.de>
Subject: File handle to "in memory" file
Message-Id: <6uvg37Fh1tocU3@mid.individual.net>
Hi folks,
with
open $fh,'>',\$var
I can connect a file handle $fh with a scalar $var.
How can I find out, given $fh, whether $fh is connected
with a scalar and which scalar it is connected with.
Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
------------------------------
Date: Thu, 5 Feb 2009 05:42:31 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Feb 5 2009
Message-Id: <KEKvuv.5Cs@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Algorithm-Evolutionary-0.62
http://search.cpan.org/~jmerelo/Algorithm-Evolutionary-0.62/
Perl extension for performing paradigm-free evolutionary algorithms.
----
Apache2-WURFLFilter-1.41
http://search.cpan.org/~ifuschini/Apache2-WURFLFilter-1.41/
is a Apache Mobile Filter that manage content (text & image) to the correct mobile device
----
App-Cpan-1.56_01
http://search.cpan.org/~bdfoy/App-Cpan-1.56_01/
easily interact with CPAN from the command line
----
App-Lazyd-0.01
http://search.cpan.org/~gugod/App-Lazyd-0.01/
quick and lazy way to add delicious.com bookmarks.
----
Astroboy-1.05
http://search.cpan.org/~leocharre/Astroboy-1.05/
organize mp3s on disk by id3 tags
----
B-Hooks-OP-Annotation-0.10
http://search.cpan.org/~chocolate/B-Hooks-OP-Annotation-0.10/
Annotate and delegate hooked OPs
----
B-Hooks-OP-Annotation-0.20
http://search.cpan.org/~chocolate/B-Hooks-OP-Annotation-0.20/
Annotate and delegate hooked OPs
----
Catalyst-Devel-1.09
http://search.cpan.org/~mramberg/Catalyst-Devel-1.09/
Catalyst Development Tools
----
Catalyst-Runtime-5.8000_06
http://search.cpan.org/~mramberg/Catalyst-Runtime-5.8000_06/
The Catalyst Framework Runtime
----
Crypt-FSHP-0.2.4
http://search.cpan.org/~bdd/Crypt-FSHP-0.2.4/
Fairly Secure Hashed Passwords. A PKCS#5 PBKDF1 similar implementation.
----
Crypt-GCrypt-1.21
http://search.cpan.org/~aar/Crypt-GCrypt-1.21/
Perl interface to the GNU Cryptographic library
----
DBD-JDBC-0.71
http://search.cpan.org/~vizdom/DBD-JDBC-0.71/
JDBC proxy driver for the DBI module
----
Data-Page-FlickrLike-1.01
http://search.cpan.org/~sekimura/Data-Page-FlickrLike-1.01/
Generates flickr-like navigation links
----
Data-Page-FlickrLike-1.02
http://search.cpan.org/~sekimura/Data-Page-FlickrLike-1.02/
Generates flickr-like navigation links
----
Data-Token-v0.0.3
http://search.cpan.org/~scott/Data-Token-v0.0.3/
Generate an unpredictable unique token
----
Devel-Refcount-0.04
http://search.cpan.org/~pevans/Devel-Refcount-0.04/
obtain the REFCNT value of a referent
----
Dotiac-addon-case-insensitive-0.1
http://search.cpan.org/~maluku/Dotiac-addon-case-insensitive-0.1/
----
EBook-Tools-0.4.1
http://search.cpan.org/~azed/EBook-Tools-0.4.1/
Object class for manipulating and generating E-books
----
Env-Sanctify-0.02
http://search.cpan.org/~bingos/Env-Sanctify-0.02/
Lexically scoped sanctification of %ENV
----
Fey-0.20
http://search.cpan.org/~drolsky/Fey-0.20/
Better SQL Generation Through Perl
----
Games-Framework-RCP-0.04_01
http://search.cpan.org/~wolfman/Games-Framework-RCP-0.04_01/
Generic video game tactics based battle system.
----
Git-CPAN-Patch-0.1.2
http://search.cpan.org/~yanick/Git-CPAN-Patch-0.1.2/
Patch CPAN modules using Git
----
HTML-FormHandler-0.12
http://search.cpan.org/~gshank/HTML-FormHandler-0.12/
form handler written in Moose
----
HTML-FormHandler-0.13
http://search.cpan.org/~gshank/HTML-FormHandler-0.13/
form handler written in Moose
----
HTML-Tested-0.49
http://search.cpan.org/~bosu/HTML-Tested-0.49/
Provides HTML widgets with the built-in means of testing.
----
HTTP-Headers-Fast-0.06
http://search.cpan.org/~tokuhirom/HTTP-Headers-Fast-0.06/
faster implementation of HTTP::Headers
----
Hash-FieldHash-0.03
http://search.cpan.org/~gfuji/Hash-FieldHash-0.03/
A lightweight field hash implementation
----
IO-Pty-Easy-0.04
http://search.cpan.org/~doy/IO-Pty-Easy-0.04/
Easy interface to IO::Pty
----
LaTeX-Table-0.9.13
http://search.cpan.org/~limaone/LaTeX-Table-0.9.13/
Perl extension for the automatic generation of LaTeX tables.
----
Moose-0.67
http://search.cpan.org/~drolsky/Moose-0.67/
A postmodern object system for Perl 5
----
Moose-0.68
http://search.cpan.org/~drolsky/Moose-0.68/
A postmodern object system for Perl 5
----
MooseX-Role-Matcher-0.04
http://search.cpan.org/~doy/MooseX-Role-Matcher-0.04/
generic object matching based on attributes and methods
----
MooseX-Role-Matcher-0.05
http://search.cpan.org/~doy/MooseX-Role-Matcher-0.05/
generic object matching based on attributes and methods
----
Net-Amazon-S3-0.50
http://search.cpan.org/~lbrocard/Net-Amazon-S3-0.50/
Use the Amazon S3 - Simple Storage Service
----
Net-LastFM-Submission
http://search.cpan.org/~sharifuln/Net-LastFM-Submission/
simple Perl interface to the Last.fm Submissions Protocol (v1.2.1)
----
Net-LastFM-Submission-0.2
http://search.cpan.org/~sharifuln/Net-LastFM-Submission-0.2/
Perl interface to the Last.fm Submissions Protocol
----
Net-OpenSSH-0.27
http://search.cpan.org/~salva/Net-OpenSSH-0.27/
Perl SSH client package implemented on top of OpenSSH
----
Net-Whois-Raw-1.62
http://search.cpan.org/~despair/Net-Whois-Raw-1.62/
Get Whois information for domains
----
POE-Component-Client-NRPE-0.12
http://search.cpan.org/~bingos/POE-Component-Client-NRPE-0.12/
a POE Component that implements check_nrpe functionality
----
POE-Component-MessageQueue-0.2.6
http://search.cpan.org/~dsnopek/POE-Component-MessageQueue-0.2.6/
A POE message queue that uses STOMP for its communication protocol
----
POE-Component-SmokeBox-0.12
http://search.cpan.org/~bingos/POE-Component-SmokeBox-0.12/
POE enabled CPAN smoke testing with added value.
----
Padre-Plugin-Perl6-0.026
http://search.cpan.org/~azawawi/Padre-Plugin-Perl6-0.026/
Padre plugin for Perl6
----
Pod-Parser-1.37
http://search.cpan.org/~marekr/Pod-Parser-1.37/
base class for creating POD filters and translators
----
RTx-Tags-0.14
http://search.cpan.org/~jpierce/RTx-Tags-0.14/
Tag Cloud support for RT with simple-searchable custom fields.
----
SVN-Class-0.13_01
http://search.cpan.org/~karman/SVN-Class-0.13_01/
manipulate Subversion workspaces with Perl objects
----
Scalar-Defer-0.19
http://search.cpan.org/~jesse/Scalar-Defer-0.19/
Lazy evaluation in Perl
----
Scalar-Defer-0.20
http://search.cpan.org/~jesse/Scalar-Defer-0.20/
Lazy evaluation in Perl
----
Simo-0.05_06
http://search.cpan.org/~kimoto/Simo-0.05_06/
Very simple framework for Object Oriented Perl.
----
Simo-0.05_07
http://search.cpan.org/~kimoto/Simo-0.05_07/
Very simple framework for Object Oriented Perl.
----
Simo-0.05_08
http://search.cpan.org/~kimoto/Simo-0.05_08/
Very simple framework for Object Oriented Perl.
----
String-BufferStack-1.12
http://search.cpan.org/~alexmv/String-BufferStack-1.12/
Nested buffers for templating systems
----
Syntax-Highlight-Perl6-0.040
http://search.cpan.org/~azawawi/Syntax-Highlight-Perl6-0.040/
Perl 6 Syntax Highlighter
----
Sys-Mmap-Simple-0.11
http://search.cpan.org/~leont/Sys-Mmap-Simple-0.11/
Memory mapping made simple and safe.
----
Sys-Sendfile-0.08
http://search.cpan.org/~leont/Sys-Sendfile-0.08/
Zero-copy data transfer
----
TeamCity-BuildMessages-v0.999.3
http://search.cpan.org/~elliotjs/TeamCity-BuildMessages-v0.999.3/
Encode and emit messages that TeamCity can interpret during a build.
----
Test-NoTabs-0.8
http://search.cpan.org/~bobtfish/Test-NoTabs-0.8/
Check the presence of tabs in your project
----
VUser-Google-ProvisioningAPI-0.24
http://search.cpan.org/~rsmith/VUser-Google-ProvisioningAPI-0.24/
Perl module that implements the Google Apps for Your Domain Provisioning API
----
WWW-Mechanize-Plugin-Web-Scraper-0.02
http://search.cpan.org/~blom/WWW-Mechanize-Plugin-Web-Scraper-0.02/
Scrape the planet!
----
XML-TinyXML-0.10
http://search.cpan.org/~xant/XML-TinyXML-0.10/
Little and efficient Perl module to manage xml data.
----
ZConf-BGSet-GUI-GTK-0.0.0
http://search.cpan.org/~vvelox/ZConf-BGSet-GUI-GTK-0.0.0/
GTK GUI for ZConf::BGSet
----
vuser-0.5.0
http://search.cpan.org/~rsmith/vuser-0.5.0/
Virtual user management utility
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Thu, 05 Feb 2009 00:24:40 GMT
From: Bruce Cook <bruce-usenet@noreplybicycle.synonet.comnoreply>
Subject: OT: Re: Perl Peeves
Message-Id: <498a31c5@news.mel.dft.com.au>
Peter J. Holzer wrote:
> On 2009-02-03 14:59, Bruce Cook
> <bruce-usenet@noreplybicycle.synonet.comnoreply> wrote:
>> Uri Guttman wrote:
>>>>>>>> "PJH" == Peter J Holzer <hjp-usenet2@hjp.at> writes:
>>> PJH> Who said I don't like it? I never said such a thing. I don't even
>>> think PJH> it is very complex. The number 0, the strings '' and '0'
>>> and the undef PJH> value are false, all other scalars are true.
>>>
>>> i agree this is a simple and clear rule. why people fuss over it, i
>>> don't know. let perl be perl. forcing a specific value to be the one
>>> 'true' false (sic :) is a waste of time and anal. it is like normalizing
>>> for no reason and it bloats the code. even the concept of using the
>>> result of a boolean test for its numeric or string value bothers me. a
>>> boolean test value (of any kind in any lang) should only be used in a
>>> boolean context. anything else is a slippery shortcut that makes the
>>> code more complex and harder to read.
>>
>> That's basically where I'm coming from - I have an immediate cringe when
>> I see the result of a test being used as an int.
>
> I find this odd from someone who claims to have an extensive background
> in assembler and early C programming. After all, in machine code
> everything is just bits. And early C had inherited quite a bit (no pun
> intended) from that mindset, if mostly via its typeless predecessors
> BCPL and B.
It's basically a background thing. As you say everything is just bits. The
earlier compilers I work with were all 16 bit, and literally everything was
a 16-bit int, pointers, *everything* (even when chars were passed into
functions, there were passed 16-bit (to satisfy even-byte boundary
constraints), manipulated 16-bit, you just ignored the top 8-bits of the
word in certain operations. To add to this, the compilers didn't do a lot
of sanity checking, the compiler just assumed you knew what you were doing
and would faithfully "just do it". Early compilers didn't have function
prototyping (a function prototype was a syntax error), void was a keyword
introduced to the language later, so void * was unheard of in most code.
(If you wanted to check your code out for bad stuff you ran lint over the
code and it would give you a whole bunch of error lines, fairly much what
you'd expect to get as warnings, and in some case outright errors from a
modern compiler)
This engendered very fast and loose usage of ints for everything. In a lot
of early code you'd see pointers, chars and all sorts declared as int and
some truely horrendous coding:
foo (a,b) {
int a,b; /* We don't know what a and b are at this point, just declare them
int for now */
struct bar *z;
struct frotz * y;
/* First word that a points to signals a bar or not */
if(*(int *)a == 1) {
z= a;
...
} else {
y=a;
...
}
Code could have been done properly using unions, however that was work and
because everyone knew what was really happening in the background why
bother?
This all came crashing down when we started porting to other platforms,
which had different architecture driven rules.
We still didn't have compilers that would point our our stupidity, so to
make code portable took a great deal of self-discipline. One of the big
things you had to get right was data typing integrity (even though C didn't
explicitly type anything much)
It became quite common for a project to have a project-wide header file
which defined the projects' base datatypes and one of the common ones that
turned up was:
typedef int bool;
This didn't mean bool was special, declaring it just signaled to the
programmers that they were dealing with an int that had certain meaning.
In systems programming you would get things like this simplistic example:
bool is_rx_buffer_full (int buffer) {
....
return (qio_buffer_set[buffer]->qio_status & QIO_RX_FLAGS);
}
note that this function is declared as returning bool, which implies that
what it returns should only be used in a conditional expression. If you
tried to use it as an int, you could, but you wouldn't get what you
expected.
...
step_func= operations[buffer][is_rx_buffer_full(buffer)];
/* oh shit, we seem to have wandered off into the weeds -
no runtime bounds checking in C so it's time to fire up the
debugger to find why we're crashing. */
knowing that is_rx_buffer_full is bool, we would have done it this way:
step_func= operations[buffer][is_rx_buffer_full(buffer)?1:0];
we could have made is_rx_buffer_full() return 0 or 1, but that would have
taken extra code and on 16 bits you simply didn't just do extra code to make
things pretty. In most cases that return value would just have been used in
a condition and so would be fine (and that's what bool in this header says
it's for). 0 or non-0 served well enough for what it was to accomplish.
if you wanted to use a bool as an int, you disciplined yourself to normalize
it then.
This was all done by convention - no typing in the language, but if the
programmer ignored the implied typing, you could almost guarantee there'd be
tears.
The whole industry hit the portability issue at about the same time. This
lead to a lot of the modern features of C, including posix, function
prototypes, a lot of the standard header files, many of the standard
compiler warnings and of course the C standards. Others decided that C was
just stupid for portability and created their own language (DEC used BLISS,
which was an extremely strongly typed language and served them well across
many very different architectures)
>> I find it odd that
>> normalization of bool results is built into the compiler,
>
> What "normalization of bool results is built into the compiler"?
Consider:
c= (a || b)
as you say, these are just ints like everything else in C.
Easiest way to compile that on most architectures would be:
mov a,c
bis c,b ; bis being the '11 OR operator
however if you need to make sure your result is 1 or 0
mov a,c
bis c,b
beq 1$ ; normalize !0 to 1
mov #1,c
1$:
(obviously here I'm ignoring architecture implementation of the actual
storage of a,b & c for clarity )
[...]
> You make the mistake of assuming a-priory that there must be such a
> thing as a "logical" or "boolean" type. C has no such thing. The
> operators !, ==, <, &&, etc. all return results of type int.
> (1 == 1) does not return "true", it returns "1", just like the δ(1,1)
> returns 1. You may not like that, but that's the way it is in C.
>
>> and not useful in itself.
What I meant was literally that the construct !0 is not useful in itself.
> I find it very useful that operators built into the language returned a
> defined result. If anything, C has too many "implementation defined" and
> "undefined" corners for my taste.
Yes, but I think it's also one of the strengths of C. You define your own
rules to make it fit to your needs for a particular project and as long as
you're consistent and design those rules properly it all works.
Modern languages try to address these undefined corners, but it often makes
them difficult to use for some applications.
Bruce
------------------------------
Date: Thu, 05 Feb 2009 02:40:01 +0100
From: Hans Mulder <hansmu@xs4all.nl>
Subject: Re: Perl Peeves
Message-Id: <498a44b1$0$192$e4fe514c@news.xs4all.nl>
Peter J. Holzer wrote:
> The "special false" value is an integer (the integer
> zero) and it is also printable (it prints as ''), but depending on your
> expectations it may not be "cleanly printable" (a "normal" integer of
> value 0 prints as '0', not '').
The regular documentation does not admit it, but a Perl scalar can have
a numeric value and a string value simultaneously, and the two need not
match. The special false value has the values 0 and '':
my $false = (1 < 0);
printf "Numeric value: %d, String value: '%s'\n", $false, $false;
prints:
Numeric value: 0, String value: ''
The magic variable $! tends to contain more wildly mismatching values.
For example:
open my $fh, '<', "blah blah blah";
printf "Numeric: %d, String: '%s'\n", $!, $!;
prints (on my system):
Numeric value: 2, String value: 'No such file or directory'
(Both string and numeric values of $! are OS dependent.)
If you want to create your own mismatching scalars, you can use the
function dualvar in the module Scalar::Util
use Scalar::Util 'dualvar';
my $t = dualvar(1, "True");
printf "Numeric value: %d, String value: '%s'\n", $t, $t;
prints:
Numeric value: 1, String value: 'True'
Incidentally, 'dualvar' is a misnomer: it returns dual values, not dual
variables.
The function Dump in the module Devel::Peek is the only I'm aware of
that will accurately report the value(s) of such a dual scalar.
[.....]
> In perl, there are only scalars, so you have to tell it whether you
> want a string or a numeric comparison[1].
> [1] Strictly speaking the interpreter could figure it out at run-time.
The bitwise operators ( &, |, ^ and ~) do exactly that. They check at
runtime whether their operands have a string value or number a numeric
value and behave accordingly:
my $x = 6;
my $y = 12;
printf "Numeric bitwise or: %d\n", $x | $y ;
printf "String bitwise or: %s\n", "$x" | "$y";
prints:
Numeric bitwise or: 14
String bitwise or: 72
> But since the type (NV, IV, UV, PV, or a combination) can be changed
> just by using a variable, this would be extremely confusing.
There's that.
Hope this helps,
-- HansM
------------------------------
Date: Thu, 05 Feb 2009 03:50:16 GMT
From: Bruce Cook <bruce-usenet@noreplybicycle.synonet.comnoreply>
Subject: Re: Perl Peeves
Message-Id: <498a61f7$1@news.mel.dft.com.au>
Hans Mulder wrote:
> Peter J. Holzer wrote:
>> The "special false" value is an integer (the integer
>> zero) and it is also printable (it prints as ''), but depending on your
>> expectations it may not be "cleanly printable" (a "normal" integer of
>> value 0 prints as '0', not '').
>
> The regular documentation does not admit it, but a Perl scalar can have
> a numeric value and a string value simultaneously, and the two need not
> match. The special false value has the values 0 and '':
>
> my $false = (1 < 0);
> printf "Numeric value: %d, String value: '%s'\n", $false, $false;
>
> prints:
>
> Numeric value: 0, String value: ''
>
>
> The magic variable $! tends to contain more wildly mismatching values.
> For example:
>
> open my $fh, '<', "blah blah blah";
> printf "Numeric: %d, String: '%s'\n", $!, $!;
>
> prints (on my system):
>
> Numeric value: 2, String value: 'No such file or directory'
I hadn't realized this, that's a really neat feature !
>
> (Both string and numeric values of $! are OS dependent.)
>
>
> If you want to create your own mismatching scalars, you can use the
> function dualvar in the module Scalar::Util
>
> use Scalar::Util 'dualvar';
>
> my $t = dualvar(1, "True");
> printf "Numeric value: %d, String value: '%s'\n", $t, $t;
>
> prints:
>
> Numeric value: 1, String value: 'True'
>
> Incidentally, 'dualvar' is a misnomer: it returns dual values, not dual
> variables.
I assume that knows about numeric vs string operators (== vs eq) and would
use the string value on assignment ?
nice, you learn something every day.
I was aware of functions that returned either scalar or array depending upon
how they're called:
@foo= (scalar) time(); #Returns a single epoch
vs @foo= time(); # returns the components hour:min:sec etc
Bruce
------------------------------
Date: Wed, 04 Feb 2009 13:24:51 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <ok1ko4dfeelc0juv13l9iimpd700qfva0l@4ax.com>
rabbits77 <rabbits77@my-deja.com> wrote:
>Jürgen Exner wrote:
>> rabbits77 <rabbits77@my-deja.com> wrote:
>>> What is the best way to convert a formatted time to a
>>> unix "time since epoch"?
>>
>> See "perldoc -q epoch":
>> How can I take a string and turn it into epoch seconds?
>>
>>> So, I have a string like
>>> 2009-02-3 21:31:29
>>> and I want that converted to the number of milliseconds since the unix
>>> epoch. What is the best way to do this?
>>
>> You don't. Your input data only has a resolution of seconds. There is no
>> point in computing the output to milliseconds and pretending to have a
>> resolution that is three orders of magnitude higher than your input
>> provides.
>I left out part of the data.
>I really have a string like this
>2009-02-3 21:31:29,777
>Anyway, its a shame you wanted to be a cunt instead of just answer the
>question...
If you deliberately withhold important information then you shouldn't be
surprised if you get solutions for a different problem.
Garbage in - garbage out.
>I already got a helpful answer earlier in the thread. Time::Local does
>the trick.
Guess what, Time::Local is mentioned in the FAQ answer that I pointed
out. Did you read it?
jue
------------------------------
Date: Wed, 04 Feb 2009 22:48:34 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <6uugpkFha37eU1@mid.individual.net>
Jürgen Exner wrote:
> rabbits77 <rabbits77@my-deja.com> wrote:
>> What is the best way to convert a formatted time to a
>> unix "time since epoch"?
>
> See "perldoc -q epoch":
> How can I take a string and turn it into epoch seconds?
>
>> So, I have a string like
>> 2009-02-3 21:31:29
>> and I want that converted to the number of milliseconds since the unix
>> epoch. What is the best way to do this?
>
> You don't. Your input data only has a resolution of seconds. There is no
> point in computing the output to milliseconds and pretending to have a
> resolution that is three orders of magnitude higher than your input
> provides.
Hey guys (Jürgen, Tad, Sinan), give it a break, please.
I had already answered the question, as well as questioned the seemingly
contradictory millisecond requirement, and the OP had explained the latter.
This whole sub-thread appears to be totally unnecessary, and only serves
the purpose of adding to the high noise level of this group.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 04 Feb 2009 20:29:13 -0500
From: rabbits77 <rabbits77@my-deja.com>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <4d3c5$498a40f3$d0365e1a$29674@news.eurofeeds.com>
x-no-archive: yes
> Why did you (attempt to) ask for no archiving of your post?
No, this will actually work. With Google anyway. Since many users are
simply not allowed by their clients to modify headers Google will honor
the x-no-archive if it is the first line of a post.
Speaking of Google, maybe you should use it before typing.
> If it is archived, then others seeking an answer to the same
> question would be able to find it.
How uncharacteristically altruistic of you. Typically your posts are
socially retarded rants on grammar and semantics.
Are you back on your meds?
------------------------------
Date: Wed, 04 Feb 2009 14:34:43 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <pq5ko4tgtf93pj1riq0udd787efok9j1cr@4ax.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>Hey guys (Jürgen, Tad, Sinan), give it a break, please.
>
>I had already answered the question, as well as questioned the seemingly
>contradictory millisecond requirement, and the OP had explained the latter.
>
>This whole sub-thread appears to be totally unnecessary, and only serves
>the purpose of adding to the high noise level of this group.
Fair enough. But I do take objection to the implication of "already" in
your first sentence. According to the time stamps you are right. But at
the time I wrote and sent my answer your reply had not arrived at my
client yet and therefore was not visible to me.
That's why I wrote my reply in the first place: there was no other reply
yet.
jue
------------------------------
Date: Wed, 04 Feb 2009 19:56:25 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <Jrtil.1854$xm4.559@newsfe20.iad>
rabbits77 wrote:
> Speaking of Google, maybe you should use it before typing.
I don't think many people care what provider you use, but I don't think
suggesting people give up a real news client and using google groups
will win anyone over. :-)
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Thu, 05 Feb 2009 00:23:01 -0500
From: rabbits77 <rabbits77@my-deja.com>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <39b99$498a77ae$d0365e1a$31966@news.eurofeeds.com>
x-no-archive: yes
Tim Greer wrote:
> rabbits77 wrote:
>
>> Speaking of Google, maybe you should use it before typing.
>
> I don't think many people care what provider you use, but I don't think
> suggesting people give up a real news client and using google groups
> will win anyone over. :-)
I will charitably assume you are not being intentionally obtuse...
My suggestion was that he use Google to check his (invalid) conjecture
that adding x-no-archive to the first line of a post does not matter.
If you had simply looked at the headers of my post you would see that I
do not use Google Groups to post.
------------------------------
Date: Wed, 04 Feb 2009 21:30:19 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <LPuil.12483$Yz.10691@newsfe01.iad>
rabbits77 wrote:
> x-no-archive: yes
>
> Tim Greer wrote:
>> rabbits77 wrote:
>>
>>> Speaking of Google, maybe you should use it before typing.
>>
>> I don't think many people care what provider you use, but I don't
>> think suggesting people give up a real news client and using google
>> groups will win anyone over. :-)
> I will charitably assume you are not being intentionally obtuse...
> My suggestion was that he use Google to check his (invalid) conjecture
> that adding x-no-archive to the first line of a post does not matter.
> If you had simply looked at the headers of my post you would see that
> I do not use Google Groups to post.
I really don't care, but when you said "Speaking of Google, maybe you
should use it before typing.", it sure sounded like you meant he should
try Google groups, rather than "verify it won't archive". You using
Google groups has no bearing on what I thought you meant. I was
mistaken about what you had meant, and you've cleared it up. Not a big
deal.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Thu, 05 Feb 2009 01:04:24 -0500
From: TheGist <thegist@nospam.net>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <gmdvh8$lnv$1@aioe.org>
Uri Guttman wrote:
>>>>>> "r" == rabbits77 <rabbits77@my-deja.com> writes:
>
> >> Why did you (attempt to) ask for no archiving of your post?
>
> r> No, this will actually work. With Google anyway. Since many users are
> r> simply not allowed by their clients to modify headers Google will honor
> r> the x-no-archive if it is the first line of a post.
> r> Speaking of Google, maybe you should use it before typing.
>
> >> If it is archived, then others seeking an answer to the same
> >> question would be able to find it.
>
> r> How uncharacteristically altruistic of you. Typically your posts are
> r> socially retarded rants on grammar and semantics.
> r> Are you back on your meds?
>
> and you don't show attributions for whom you are insulting. seems kinda
> dumbass as well. pot meet kettle. and don't flame me back as i have
> dragon scale armor on.
They actually make that in your size?
How many dragons did that take?
------------------------------
Date: Thu, 05 Feb 2009 00:33:32 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <x763jp78ib.fsf@mail.sysarch.com>
>>>>> "r" == rabbits77 <rabbits77@my-deja.com> writes:
>> Why did you (attempt to) ask for no archiving of your post?
r> No, this will actually work. With Google anyway. Since many users are
r> simply not allowed by their clients to modify headers Google will honor
r> the x-no-archive if it is the first line of a post.
r> Speaking of Google, maybe you should use it before typing.
>> If it is archived, then others seeking an answer to the same
>> question would be able to find it.
r> How uncharacteristically altruistic of you. Typically your posts are
r> socially retarded rants on grammar and semantics.
r> Are you back on your meds?
and you don't show attributions for whom you are insulting. seems kinda
dumbass as well. pot meet kettle. and don't flame me back as i have
dragon scale armor on.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
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:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#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 2183
***************************************