[30947] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2192 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 8 11:41:04 2009

Date: Sun, 8 Feb 2009 03: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           Sun, 8 Feb 2009     Volume: 11 Number: 2192

Today's topics:
    Re: [OT] Programmers (UK)...? (Vicky Conlan)
    Re: automating a perl installation on a cluster (or usi <nospam@invalid.invalid>
    Re: automating a perl installation on a cluster (or usi <nospam@invalid.invalid>
    Re: error printing page using LWP::Simple <larry@example.invalid>
    Re: error printing page using LWP::Simple <tadmc@seesig.invalid>
    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 <larry@example.invalid>
    Re: good email parser ?? <rabbits77@my-deja.com>
        new CPAN modules on Sun Feb  8 2009 (Randal Schwartz)
    Re: OT: Re: Perl Peeves <bruce-usenet@noreplybicycle.synonet.comnoreply>
        parse newline <ela@yantai.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 8 Feb 2009 10:53:34 +0000 (UTC)
From: comps@riffraff.plig.net (Vicky Conlan)
Subject: Re: [OT] Programmers (UK)...?
Message-Id: <gmmdje$pun$1@magenta.plig.net>

According to <uri@stemsystems.com>:
>also the london perl monger's manage their own jobs list so you would
>get more a more focused group. and i know several UK hackers who might
>be available. but maybe hiring in 2 months is not useful immediately.

I was going to suggest LPM, but he did say Leeds not London.  In my
experience the problem he's going to have is that if you want Perl
programmers, most of them are very firmly based in London.
-- 


------------------------------

Date: Sun, 8 Feb 2009 07:43:21 +0000 (UTC)
From: Rahul <nospam@invalid.invalid>
Subject: Re: automating a perl installation on a cluster (or using         non-standard nfs paths)
Message-Id: <Xns9BAC1184CE5D26650A1FC0D7811DDBC81@85.214.105.209>

Sam <sam@email-scan.com> wrote in
news:cone.1234012171.767069.27881.500@commodore.email-scan.com: 

> Use your Linux distribution's native software update and maintenance
> tools. 
> 
> With RPM/yum based distros, for example, provided that you package
> your Perl module properly, and define your dependencies, and you have
> your standard yum repositories enabled, "yum install
> perl-yourmodule.rpm" will automatically download and install all of
> your dependencies, if necessary. 

Ah! Thanks Sam! I didn't realize yum maintained CPAN modules too. I thought 
"CPAN was the yum for perl!" 

> 
> The best way to handle non-standard paths is to eliminate them. Use
> your standard Perl install, and use the built-in, tested tools, that
> are part of your distribution.
> 

I don't agree. Vut maybe I am wrong! Standardization has its avantages. But 
one needs to make a case b case exception sometimes. In my case if I go 
with the standardized paths it will mean 200 installs locally on each 
remote host. That's duplication of effort, netork bandwidth and hard disk 
space. Future updates will again have to be pushed to all 200 machines. 
Besides this way it is harder to maintain module consistancy rather than if 
I just install thinggs centrally.

Thus for me the NFS mount to a custom dir approach does seem the better way 
to go. Feel free to point out flaws. Maybe I am wrong!

-- 
Rahul


------------------------------

Date: Sun, 8 Feb 2009 07:46:13 +0000 (UTC)
From: Rahul <nospam@invalid.invalid>
Subject: Re: automating a perl installation on a cluster (or using non-standard nfs paths)
Message-Id: <Xns9BAC1200C3C346650A1FC0D7811DDBC81@85.214.105.209>

Ben Morrow <ben@morrow.me.uk> wrote in news:edq166-a0h.ln1
@osiris.mauzo.dyndns.org:

> Specifically, an entry /foo in PERL5LIB will also include
> /foo/VERSION/ARCH, /foo/VERSION and /foo/ARCH where VERSION is something
> like 5.8.8 and ARCH is something like i386-linux. It will also include
> directories for any compatible previous versions that were found at
> Configure time: you can get the list with perl -V:inc_version_list. This
> is exactly the same logic as used by 'use lib'.
> 

Thanks Ben. That explains it! When I looked up PERL5LIB online the 
explaination I found was too terse to explain that underlying logic. Now I 
know more!

-- 
Rahul


------------------------------

Date: Sat, 7 Feb 2009 22:26:39 -0700
From: Larry Gates <larry@example.invalid>
Subject: Re: error printing page using LWP::Simple
Message-Id: <1a3gcsygoyqtz.12ab273ctepfn.dlg@40tude.net>

On Fri, 6 Feb 2009 15:44:24 -0600, Tad J McClellan wrote:

> Larry Gates <larry@example.invalid> wrote:
>> On Fri, 6 Feb 2009 06:53:28 -0600, Tad J McClellan wrote:
>>
>>>>>> my $t = get 'http://www.fourmilab.ch/cgi-
>>>>>> bin/
>>>>>> Yoursky?z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
>>> 
>>>>>> Is it not a problem that the url is folded over with newlines?
>>> 
>>> 
>>> Yes, that is absolutely a problem. So fix it.
>>
>> I've asked this question before and didn't get an answer I could use.  How
>> does a person do proper line continuations in perl?
> 
> 
> By pressing the wide key labeled "Enter" or "Return" on your keyboard.  :-)
> 
> 
> If you instead meant to ask how to get a really long string that
> does not hit the wordwrap limit, then use the concatenation operator:
> 
>    my $t = get 'http://www.fourmilab.ch/cgi-'
>                . 'bin/'
>                . 'Yoursky?z=1&lat=35.0836&ns=North&lon=106.651&ew=West';

That explains the error expecting a period.

Hoe does a perl program say read lines until one of them contains 'jd', and
indeed if it contains this tring, then it's the only one wecare about for
now.

My hands are injured.
-- 
larry gates

Real theology is always rather shocking to people who already
think they know what they think.  I'm still shocked myself.  :-)
             -- Larry Wall in <199708261932.MAA05218@wall.org>


------------------------------

Date: Sat, 7 Feb 2009 23:42:23 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: error printing page using LWP::Simple
Message-Id: <slrngoss5v.bvp.tadmc@tadmc30.sbcglobal.net>

Larry Gates <larry@example.invalid> wrote:


> Hoe does a perl program say read lines until one of them contains 'jd',


Are you serious, or are you joking around?

    while ( <> ) {
        last if /jd/;
    }
    print "There is a jd in this line: $_";


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Sat, 7 Feb 2009 23:31:45 -0700
From: Larry Gates <larry@example.invalid>
Subject: Re: error printing page using LWP::Simple
Message-Id: <14vjxrcufj5o$.44aucdkf4abx$.dlg@40tude.net>

On Sat, 7 Feb 2009 23:42:23 -0600, Tad J McClellan wrote:

> Larry Gates <larry@example.invalid> wrote:
> 
> 
>> Hoe does a perl program say read lines until one of them contains 'jd',
> 
> 
> Are you serious, or are you joking around?
> 
>     while ( <> ) {
>         last if /jd/;
>     }
>     print "There is a jd in this line: $_";

No, I'm not kidding.  It's new syntax for me.

Dietrich Bonhoefeer spoke of the last, and the penultimate, dat Vorletzte.

If you canbump execution back oneline, can you capture what lies onthe same
line with 'jd'.
-- 
larry gates

And you can still put in all that cruft if you want to.  You can even
force yourself to have to do it.  But to me, it feels a bit like slavery,
so I'm still looking for a land flowing with milk and honey, even if
there are a few giants in it.  -- Larry Wall


------------------------------

Date: Sun, 8 Feb 2009 03:41:46 -0700
From: Larry Gates <larry@example.invalid>
Subject: Re: error printing page using LWP::Simple
Message-Id: <1c7k3ylg7jqxh.15mhiu30266ew$.dlg@40tude.net>

On Fri, 6 Feb 2009 15:40:49 -0600, Tad J McClellan wrote:

> Larry Gates <larry@example.invalid> wrote:
> 
> 
>><input type="text" name="jd" value="2454869.37545" size="20" 
>>
>> How do I grab the julian date from this?
> 
> 
> You use a module that understands HTML for processing HTML data.
> 
> 
> ---------------------------
> #!/usr/bin/perl
> use warnings;
> use strict;
> use HTML::TreeBuilder;
> use LWP::Simple;
> 
> my $site_url = 'http://www.fourmilab.ch/cgi-bin/Yoursky';
> my $url_args = 'z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
> my $t = get "$site_url?$url_args" || "Problem";
> 
> my $tree = HTML::TreeBuilder->new_from_content($t);
> 
> foreach my $elem ( $tree->find_by_attribute('name', 'jd') ) {
>     print $elem->attr('value'), "\n";
> }
> ---------------------------

Tad, 

I have huge problems with modules on windows.  Much of itcould be with two
sprained hands, but all of it is more than I can do right now.

There's modules out there for this, u.a. Time :: juilian or date:: time
456713333.

There was a time that I coud downloada modulefromcpan and put it in a place
that activestate could understand,but that was a while back.  My
sysadminbuddy just got my cd-rom rolling.  He had to straighten out a pin.

I'll try the download but bet against it.

Cheers,
-- 
larry gates

Down that path lies madness.  On the other hand, the road to hell is
paved with melting snowballs.
             -- Larry Wall in <1992Jul2.222039.26476@netlabs.com>


------------------------------

Date: Sun, 8 Feb 2009 03:59:54 -0700
From: Larry Gates <larry@example.invalid>
Subject: Re: error printing page using LWP::Simple
Message-Id: <bqlw8rhq6jhe.w7wumnbzic0u.dlg@40tude.net>

On Fri, 06 Feb 2009 13:23:21 -0800, Tim Greer wrote:

> Larry Gates wrote:
> 
>> On Thu, 05 Feb 2009 20:50:36 -0800, Tim Greer wrote:
>> 
>>> my $site_url = 'http://www.fourmilab.ch/cgi-bin/Yoursky';
>>> my $url_args = "z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
>>> my $t = (get "$site_url?$url_args" or "Problem");
>>> print "t is $t\n";
>> 
>> Big pimpin, Tim.
>> 
>> use strict;
>>   use warnings;
>>   use LWP::Simple;
>> 
>>   # load the complete content of the url in question
>>   # via LWP::Simple::get(...)
>> 
>> my $site_url = 'http://www.fourmilab.ch/cgi-bin/Yoursky';
>> my $url_args = 'z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
>> 
>> my $t = 'Something went right!';
>> print "t is $t\n";
>> 
>> $t = (get "$site_url?$url_args" or "Problem");
>> 
>> 
>> print "t is $t\n";
>> 
>> 
>> #  perl scraper3.pl
>> 
>> #end script show target
>> 
>> <td>
>> <input type="text" name="jd" value="2454869.37545" size="20"
>> 
>> How do I grab the julian date from this?  Full page listing after sig.
> 
> Well, first of all that was just in response to someone mentioning or,
> I'd change the code:
> 
> my $site_url = 'http://www.fourmilab.ch/cgi-bin/Yoursky';
> my $url_args = 'z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
> my $t = get "$site_url?$url_args" || "There was a problem".
> 
> I'd also consider using something else, like useragent, so you know what
> the problem was, instead of just having it be undefined.  Sometimes you
> can act on the problem, or at least know not to try again if it's
> forbidden on the target site, or whatever else.
> 
> You can grab the Julian date with something like:
> 
> my $juldate = ($t =~ m/name="jd" value="([^"]+)"/) ? $1 : "No date";
> 
> Of course, there are dozens of ways of doing this.

Big pimpin.


C:\MinGW\source>perl scraper4.pl
t is Something went right!
juldate is 2454870.95616
C:\MinGW\source>
C:\MinGW\source>type scraper4.pl
use warnings;
use LWP::Simple;

my $site_url = 'http://www.fourmilab.ch/cgi-bin/Yoursky';
my $url_args = 'z=1&lat=35.0836&ns=North&lon=106.651&ew=West';

my $t = 'Something went right!';
print "t is $t\n";

$t = (get "$site_url?$url_args" or "Problem");

my $juldate = ($t =~ m/name="jd" value="([^"]+)"/) ? $1 : "No date";

print "juldate is $juldate";

# print "t is $t\n";

#  perl scraper4.pl



C:\MinGW\source>
-- 
larry gates

The following two statements are usually both true:
	There's not enough documentation.
	There's too much documentation.
             -- Larry Wall in <199709020026.RAA08431@wall.org>


------------------------------

Date: Sun, 08 Feb 2009 01:33:22 -0500
From: rabbits77 <rabbits77@my-deja.com>
Subject: Re: good email parser ??
Message-Id: <6d482$498e7cba$d0365e45$15975@news.eurofeeds.com>

Jack wrote:
> Hi I havent had any luck with the CPAN email modules, I just want to
> parse multipart and mime and base64, with all the varieties of email
> files out there, these modules just dont work... does anyone know a
> free or low cost command line driven email client or parser that can
> do the job.
> 
> Thank you,
I have done some work parsing email in the(fairly distant) past.
Email really isn't that varied!
In order for email to work at all, in fact, it needs to be pretty 
predictable!
I bet that you could do this yourself.
Where are your sticking points?
If I understand your question, do you just want to remove all
email attachments?


------------------------------

Date: Sun, 8 Feb 2009 05:42:29 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Feb  8 2009
Message-Id: <KEqFut.14nJ@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.

AI-Genetic-Pro-0.335
http://search.cpan.org/~strzelec/AI-Genetic-Pro-0.335/
Efficient genetic algorithms for professional purpose. 
----
Acme-CPANAuthors-Russian-0.0102
http://search.cpan.org/~zoffix/Acme-CPANAuthors-Russian-0.0102/
We are Russian CPAN authors 
----
Acme-CPANAuthors-Russian-0.02
http://search.cpan.org/~sharifuln/Acme-CPANAuthors-Russian-0.02/
We are Russian CPAN authors 
----
Algorithm-Evolutionary-0.62_3
http://search.cpan.org/~jmerelo/Algorithm-Evolutionary-0.62_3/
Perl extension for performing paradigm-free evolutionary algorithms. 
----
App-Software-License-0.01
http://search.cpan.org/~flora/App-Software-License-0.01/
commandline interface to Software::License 
----
App-Textcast-0.02_01.4
http://search.cpan.org/~nkh/App-Textcast-0.02_01.4/
Light weight text casting 
----
App-sh2p-0.05
http://search.cpan.org/~clive/App-sh2p-0.05/
Perl program to aid for conversion from UNIX shell to Perl 
----
B-Hooks-OP-Annotation-0.21
http://search.cpan.org/~chocolate/B-Hooks-OP-Annotation-0.21/
Annotate and delegate hooked OPs 
----
Business-iDEAL-Adyen-0.01
http://search.cpan.org/~blom/Business-iDEAL-Adyen-0.01/
Backend for iDEAL payments through adyen.com 
----
Cache-Memcached-Fast-0.14
http://search.cpan.org/~kroki/Cache-Memcached-Fast-0.14/
Perl client for memcached, in C language 
----
Catalyst-View-PDF-Reuse-0.02
http://search.cpan.org/~jonallen/Catalyst-View-PDF-Reuse-0.02/
Create PDF files from Catalyst using Template Toolkit templates 
----
CatalystX-ListFramework-Builder-0.41
http://search.cpan.org/~oliver/CatalystX-ListFramework-Builder-0.41/
Instant AJAX web front-end for DBIx::Class, using Catalyst 
----
Devel-REPL-1.003003
http://search.cpan.org/~oliver/Devel-REPL-1.003003/
a modern perl interactive shell 
----
Fey-ORM-0.20
http://search.cpan.org/~drolsky/Fey-ORM-0.20/
A Fey-based ORM 
----
Foorum-1.000002
http://search.cpan.org/~fayland/Foorum-1.000002/
forum system based on Catalyst 
----
Foorum-1.000003
http://search.cpan.org/~fayland/Foorum-1.000003/
forum system based on Catalyst 
----
Google-Code-Upload-0.03
http://search.cpan.org/~fayland/Google-Code-Upload-0.03/
uploading files to a Google Code project. 
----
Google-Code-Upload-0.04
http://search.cpan.org/~fayland/Google-Code-Upload-0.04/
uploading files to a Google Code project. 
----
Hey-MySQL-3.14
http://search.cpan.org/~wilsond/Hey-MySQL-3.14/
Simple method for interacting with MySQL (don't use it, not maintained) 
----
IRC-Bot-Log-Extended-0.03
http://search.cpan.org/~fayland/IRC-Bot-Log-Extended-0.03/
extends IRC::Bot::Log for IRC::Bot 
----
Log-Dispatch-DesktopNotification-0.01
http://search.cpan.org/~flora/Log-Dispatch-DesktopNotification-0.01/
Send log messages to a desktop notification system 
----
Module-Release-2.02
http://search.cpan.org/~bdfoy/Module-Release-2.02/
Automate software releases 
----
Muldis-D-0.59.0
http://search.cpan.org/~duncand/Muldis-D-0.59.0/
Formal spec of Muldis D relational DBMS lang 
----
Muldis-D-0.59.1
http://search.cpan.org/~duncand/Muldis-D-0.59.1/
Formal spec of Muldis D relational DBMS lang 
----
Net-LastFM-Submission-0.4
http://search.cpan.org/~sharifuln/Net-LastFM-Submission-0.4/
Perl interface to the Last.fm Submissions Protocol 
----
Net-SloppyXMPP-0.01
http://search.cpan.org/~wilsond/Net-SloppyXMPP-0.01/
A rather sloppy XMPP client implementation 
----
Net-UPCDatabase-0.06
http://search.cpan.org/~wilsond/Net-UPCDatabase-0.06/
Simple OO interface to UPCDatabase.com 
----
Net-UPCDatabase-0.07
http://search.cpan.org/~wilsond/Net-UPCDatabase-0.07/
Simple OO interface to UPCDatabase.com 
----
Parse-Gnaw-0.40
http://search.cpan.org/~gslondon/Parse-Gnaw-0.40/
An extensible parser. Define grammars using subroutine calls. Define your own grammar extensions by defining new subroutines. Parse text in memory or from/to files or other streams. 
----
Path-Ancestor-0.01
http://search.cpan.org/~mschilli/Path-Ancestor-0.01/
Find the longest common ancestor of N paths 
----
Perl6-Conf-0.01
http://search.cpan.org/~szabgab/Perl6-Conf-0.01/
Experimental Perl 6 implementation of an INI file reader 
----
Readonly-XS-1.05
http://search.cpan.org/~elliotjs/Readonly-XS-1.05/
Companion module for Readonly.pm, to speed up read-only scalar variables. 
----
SQL-Translator-0.09003
http://search.cpan.org/~jrobinson/SQL-Translator-0.09003/
manipulate structured data definitions (SQL and more) 
----
Set-Relation-0.5.0
http://search.cpan.org/~duncand/Set-Relation-0.5.0/
Relation data type for Perl 
----
Test-Weaken-1.003_002
http://search.cpan.org/~jkegl/Test-Weaken-1.003_002/
Test that freed references are, indeed, freed 
----
Text-Reflow-1.06
http://search.cpan.org/~mward/Text-Reflow-1.06/
Perl module for reflowing text files using Knuth's paragraphing algorithm. 
----
Tie-TZ-4
http://search.cpan.org/~kryde/Tie-TZ-4/
tied $TZ setting %ENV and calling tzset() 
----
Video-FourCC-Info-1.1.1
http://search.cpan.org/~frequency/Video-FourCC-Info-1.1.1/
Find information about codecs specified as Four Character Code 
----
WebService-Etsy-0.4
http://search.cpan.org/~imalpass/WebService-Etsy-0.4/
Access the Etsy REST API. 
----
WebService-LastFM-0.07
http://search.cpan.org/~cbrink/WebService-LastFM-0.07/
Simple interface to Last.FM Web service API 
----
Xacobeo-0.06_02
http://search.cpan.org/~potyl/Xacobeo-0.06_02/
XPath (XML Path Language) visualizer. 
----
ack-1.88
http://search.cpan.org/~petdance/ack-1.88/
grep-like text finder 


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: Sun, 08 Feb 2009 08:22:11 GMT
From: Bruce Cook <bruce-usenet@noreplybicycle.synonet.comnoreply>
Subject: Re: OT: Re: Perl Peeves
Message-Id: <498e9631$1@news.mel.dft.com.au>

Peter J. Holzer wrote:

> On 2009-02-05 00:24, Bruce Cook
> <bruce-usenet@noreplybicycle.synonet.comnoreply> wrote:
>> Peter J. Holzer wrote:
>>
>>> On 2009-02-03 14:59, Bruce Cook
>>> <bruce-usenet@noreplybicycle.synonet.comnoreply> wrote:
>>>> Uri Guttman wrote:
>>>>> 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*
> 
> floats and longs weren't, I hope.

Where floats existed, they wern't :)
In some cases, longs were.  however you're right mostly longs were bigger 
ints.

> 
>> (even when chars were passed into functions, there were passed 16-bit
>> (to satisfy even-byte boundary constraints),
> 
> char (or more precisely any integral type smaller than int) is promoted
> to (unsigned) int when passed to a function without a prototype. This is
> still the case in C.
> 
>> manipulated 16-bit, you just ignored the top 8-bits of the word in
>> certain operations.
> 
> In arithmetic expressions, char (or more precisely any integral type
> smaller than int) is promoted to (unsigned) int. This is still the case
> in C.
> 
>> 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".
> 
> That's what lint was for, as you note below. If you have only 64 kB
> address space, you want to keep your programs small.
> 
>> Early compilers didn't have function prototyping (a function prototype
>> was a syntax error),
> 
> Prototypes were originally a feature of C++ and were introduced into C
> with the C89 standard. I think I've used compilers which supported them
> before that (gcc, Turbo C, MSC, ...) but it's too long ago for me to be
> certain.

Turbo C only gained prototypes during the C89 pre-standards releases. I 
remember seeing that come in in a turbo c release and thinking "that would 
be nice if only it were portable"  :)

>> void was a keyword introduced to the language later, so void * was
>> unheard of in most code.
> 
> About the same time as prototypes, although I don't think I've ever used
> a C compiler which didn't support it, while I've used several which
> didn't support prototypes.

Most of the work I was doing on these platforms was from '81 to '94, so most 
of it was pre-standards, and even after '89 it took a while for compilers to 
become available on these platforms that supported c89 properly.

>> 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:
> [...]
>> 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.
> 
> As they say, "port early, port often". Thankfully I was exposed to the
> VAX and 68k-based systems shortly after starting to program in C, so I
> never got into the "I know what the compiler is doing" mindset and
> rather quickly got into the "if it isn't documented/specified you cannot
> rely on it" mindset.

Yes, a pair of reasonably disparate architectures.  Would have made quite a 
few of the porting issues quite obvious from the start.

>> 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.
> 
> That's a good thing if the "certain meaning" is documented and strictly
> adhered to.
> 
> 
>> 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);
>> }
> 
> So a "bool" isn't a two-valued type - it can take many values. This is
> not what I expect from a boolean type.

Yes, agreed.  It was quite common though for people to treat bools as 
zero/not-zero in the same manner that C used false.

>> 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.
> 
> Actually I would get what I expect if I treat your "bool" as an int, but
> not what I expect when I treat your "bool" as what I expect from a
> boolean type.
> 
> Expectations differ.
> 
> So documentation is very important and this is (to get back to Perl) why
> I criticised that the "true" return value of several operators in Perl
> is not documented.
> 
> 
>> 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)
> 
> Actually, BLISS is older than C, so it can't have been developed because
> people were disappointed by C. Also according to wikipedia, BLISS was
> typeless, not "extremely strongly typed".

True, DEC came to BLISS independently.  There was pressure from the ultrix 
team to port applications to C, however is was decided that C didn't have 
the built-in language structure to achieve the system independence that 
BLISS gave them

 The BLISS I've seen is very explicit about it's types and behavior expected 
of the types.  I believe (and I am not a bliss expert) that there was an 
architecture file for each system and a data type definitions (some 
standard, some application-specifiec) that specified expected behavior, such 
as size, overflow, endian-ness, etc.  One of the jobs the BLISS compiler had 
was to make sure that data types used on an architecture aligned with what 
the application was expecting.

> 
>>>> 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
> 
> Not generally, because
> 
>  * || is defined to be short-circuiting, so it MUST NOT evaluate
>    b unless a is false.

this would only apply if the b portion was more than testing an int (which 
in the case I used is all it is).  It is only actually important if b is 
something with a side effect, such as an assignment, auto-increment or 
function call.

>  * a and b need not be integer types.

true, but it is what I'm giving as an example of the normalization.
> 
> And of course the result of the operation is defined as being 0 or 1.

I think only after C89,  I can remember that being one of the points that 
was being argued over in the pre-standardisation process.

> I don't see this as "normalisation", because there is no intermediate
> step which does a bit-wise or.
> 
> c = (a || b)
> 
> is semantically exactly equivalent to
> 
> c = (a != 0 ? 1
>             : (b != 0 ? 1
> : 0))
> 
> It is not equivalent to
> 
> c = ((a | b) != 0 ? 1 : 0)

I understand what you're saying, however if you are instead thinking in the 
mindset of a bool being an int that is zero/not zero it actually is.  This 
is part of the reason for that particular standardisation argument, some of 
the participants didn't get the prevailing mentality of the language at that 
time.   

It'd be interesting to get clc archives from 86-89 to see what was being 
said at the time.  I will try to find my K&R1, which I'm fairly sure said 
nothing about normalisation.

> (Of course in some situations an optimizing compiler may determine that
> it is equivalent in this specific situation and produce the same code)

In fact I think you'd find that this was the default way that a lot of the 
compilers would have compiled an integer logical or operation in those days.

> 
>>> 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.
> 
> I strongly disagree with this. The various implementation defined and
> undefined features of C don't make it simpler for the application
> programmer - on the contrary, they make it harder, sometimes a lot
> harder. What they do simplify (and in some cases even make possible) is
> to write an efficient compiler for very different platforms.
> 
> hp




------------------------------

Date: Sun, 8 Feb 2009 17:05:47 +0800
From: "ela" <ela@yantai.org>
Subject: parse newline
Message-Id: <gmm79b$dsa$1@ijustice.itsc.cuhk.edu.hk>

It's always a nightmare for me to parse newline characters. No matter \n, 
10, 13, I just don't know why some newlines are printed. As the file is 
generated by another program, I cannot see the source code, and manual 
inspection does not discover any abnormalty.

using chop, chomp or to use replace cannot help. Does anybody have 
experience in handling this? 




------------------------------

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 2192
***************************************


home help back first fref pref prev next nref lref last post