[23860] in Perl-Users-Digest
Perl-Users Digest, Issue: 6063 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 1 14:05:42 2004
Date: Sun, 1 Feb 2004 11:05: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, 1 Feb 2004 Volume: 10 Number: 6063
Today's topics:
Extract text from a file and write to another. (Sesa Woruban)
Re: Extract text from a file and write to another. <usenet@morrow.me.uk>
Re: Extract text from a file and write to another. <jurgenex@hotmail.com>
Re: Extract text from a file and write to another. <tadmc@augustmail.com>
Re: Historical <tadmc@augustmail.com>
Re: Historical <tassilo.parseval@rwth-aachen.de>
Re: how to check for ip address that falls inside a ran (Walter Roberson)
Re: interpreting script <usenet@morrow.me.uk>
Re: ISO lightweight OO-RDBMS in Perl <1usa@llenroc.ude>
Mail::Lite not finding file?? <pdconetwofour_numbers_@yahoo.co.uk>
Re: Mail::Lite not finding file?? <pdconetwofour_numbers_@yahoo.co.uk>
Re: Mail::Lite not finding file?? <pdconetwofour_numbers_@yahoo.co.uk>
Re: Mail::Lite not finding file?? <pdconetwofour_numbers_@yahoo.co.uk>
Re: Mail::Lite not finding file?? <usenet@morrow.me.uk>
network card <javier@t-online.de>
Re: network card <javier@t-online.de>
Re: Newbie question. Get list of files in subdir. <raisin@delete-this-trash.mts.net>
Re: Newbie question. Get list of files in subdir. <tadmc@augustmail.com>
Re: Perl For Amateur Computer Programmers <flavell@ph.gla.ac.uk>
Re: Perl For Amateur Computer Programmers (Randal L. Schwartz)
Re: Perl For Amateur Computer Programmers <dwall@fastmail.fm>
Re: Perl For Amateur Computer Programmers <uri@stemsystems.com>
Re: Perl For Amateur Computer Programmers (Walter Roberson)
Re: Upgrading <nospam@gobotherverisign.com>
Re: Upgrading <usenet@morrow.me.uk>
Re: {ipc - windows} -| no such command? <ufo.removethisspamnote@quicknet.nl>
Re: {ipc - windows} -| no such command? <ufo.removethisspamnote@quicknet.nl>
Re: {ipc - windows} -| no such command? <usenet@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 1 Feb 2004 09:11:13 -0800
From: me@sesaworuban.net (Sesa Woruban)
Subject: Extract text from a file and write to another.
Message-Id: <12db4fb.0402010911.10402062@posting.google.com>
Hiya,
I'm very new to Perl and my brain is dead. I'm trying to create a
simple programme that will extract the pertinent lines (only those
with a : in them) from a plain flat text file (that represents my
inbox) and write only those files to another text file. This is what
I've got so far:
use strict;
use warnings;
my $key;
my %hash;
my $infile = '/home/sesaworu/mail/sesaworuban.net/test/input'; #
store the file
my $outfile = '>/home/sesaworu/mail/sesaworuban.net/test/output.txt';
open (INFILE, $infile) or die "cannot open $infile: $!"; # opens the
file
open (OUTFILE, $outfile) or die "cannot open $outfile: $!"; # opens
the file
while()
{
chomp;
$key='',next if /^\s*$/;
if(/([\w\s]+):(.*)/){
$key=$1;
push @{$hash{$key}},$2;
}
else
{
push @{$hash{$key}},$_ if $key;
}
}
for(sort keys %hash)
{
print OUTFILE "$_ : ".join("\n",@{$hash{$_}})."\n";
}
How does that look?
Cheers
Sesa
------------------------------
Date: Sun, 1 Feb 2004 17:24:00 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Extract text from a file and write to another.
Message-Id: <bvjcng$ofj$1@wisteria.csv.warwick.ac.uk>
me@sesaworuban.net (Sesa Woruban) wrote:
> use strict;
> use warnings;
Good.
> my $key;
> my %hash;
Give this a better name, like %headers.
> my $infile = '/home/sesaworu/mail/sesaworuban.net/test/input'; #
> store the file
There's no need for that comment: it is perfctly clear from the code.
> my $outfile = '>/home/sesaworu/mail/sesaworuban.net/test/output.txt';
> open (INFILE, $infile) or die "cannot open $infile: $!"; # opens the
> file
I would recommend using a lexical FH:
open my $IN, $infile or die "cannot open $infile: $!";
> open (OUTFILE, $outfile) or die "cannot open $outfile: $!"; # opens
> the file
>
> while()
> {
You mean
while (<INFILE>) {
> chomp;
> $key='',next if /^\s*$/;
Use undef rather than ''... it's a better representation of 'no
value'.
> if(/([\w\s]+):(.*)/){
This is a mail message, right? In which case, don't you mean something
more like /(.+?) \s* : \s* (.*)/x ? '-' is not included in \w. Also,
do you know that a continuation header line can (and often will) contain
':': it is the whitespace at the start which marks it as a
continuation?
If this is a mailbox, you would be better off using one of the Mail::
modules on CPAN to parse it.
> $key=$1;
> push @{$hash{$key}},$2;
> }
> else
> {
> push @{$hash{$key}},$_ if $key;
> }
> }
> for(sort keys %hash)
> {
> print OUTFILE "$_ : ".join("\n",@{$hash{$_}})."\n";
> }
Ben
--
If I were a butterfly I'd live for a day, / I would be free, just blowing away.
This cruel country has driven me down / Teased me and lied, teased me and lied.
I've only sad stories to tell to this town: / My dreams have withered and died.
ben@morrow.me.uk <=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=> (Kate Rusby)
------------------------------
Date: Sun, 01 Feb 2004 17:40:56 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Extract text from a file and write to another.
Message-Id: <ISaTb.6146$07.5077@nwrddc03.gnilink.net>
Sesa Woruban wrote:
> I'm very new to Perl and my brain is dead. I'm trying to create a
> simple programme that will extract the pertinent lines (only those
> with a : in them) from a plain flat text file (that represents my
> inbox) and write only those files to another text file. This is what
> I've got so far:
>
> use strict;
> use warnings;
Good and good!
> my $key;
> my %hash;
> my $infile = '/home/sesaworu/mail/sesaworuban.net/test/input'; #
> store the file
> my $outfile = '>/home/sesaworu/mail/sesaworuban.net/test/output.txt';
Personally I find this missleading. Intuitively I would assume that $outfile
contains the file name of the output file. However it doesn't. It also
contains some wierd additional chevron.
> open (INFILE, $infile) or die "cannot open $infile: $!"; # opens the
> file
> open (OUTFILE, $outfile) or die "cannot open $outfile: $!"; # opens
> the file
And here I am missing the chevron, which would indicate that you are opening
the file for writing. No big deal, it works like you coded it, but a few
month from now it will confuse you and it will cost extra time to figure out
why the chevron is missing here.
> while()
While what? I guess you meant
while (<INFILE>)
> {
Spaces for indentation are cheap, use them liberaly
> chomp;
> $key='',next if /^\s*$/;
> if(/([\w\s]+):(.*)/){
> $key=$1;
> push @{$hash{$key}},$2;
> }
> else
> {
> push @{$hash{$key}},$_ if $key;
> }
> }
No idea what this loop body is supposed to do. It looks way to complicated
to me.
A simple single-line
{ print OUTFILE if (/:/); }
appears to be all you would need according to your spec above. "Copy a line
if it contains a colon sign".
> for(sort keys %hash)
> {
> print OUTFILE "$_ : ".join("\n",@{$hash{$_}})."\n";
> }
Well, why? Your spec doesn't say anything about sorting.
jue
------------------------------
Date: Sun, 1 Feb 2004 12:57:30 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Extract text from a file and write to another.
Message-Id: <slrnc1qj0q.97j.tadmc@magna.augustmail.com>
Sesa Woruban <me@sesaworuban.net> wrote:
> I'm trying to create a
> simple programme that will extract the pertinent lines (only those
> with a : in them) from a plain flat text file (that represents my
> inbox) and write only those files to another text file.
perl -ne 'print if /:/' infile >outfile
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 1 Feb 2004 10:15:18 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Historical
Message-Id: <slrnc1q9gm.8vb.tadmc@magna.augustmail.com>
Tassilo v. Parseval <tassilo.parseval@rwth-aachen.de> wrote:
> Also sprach Ben Morrow:
>> "edgrsprj" <edgrsprj@ix.netcom.com> wrote:
>
>>> But with those preliminary instructions people can probably figure
^^^^^^
I think "people" here is meant to be:
people with little or no training/experience in programming
??
>>> out how to do other things such as write subroutines and do sorts
>>> etc.
>>
>> No, they can't. You give no indication of how someone might go about
>> this.
>
> As if that would be a problem.
> I learnt it with the help
> of a very flimsy introduction
Were you in edgrsprj's suggested target audience then, or were you
already a "programmer"?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 1 Feb 2004 19:04:42 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Historical
Message-Id: <bvjika$b3o$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Tad McClellan:
> Tassilo v. Parseval <tassilo.parseval@rwth-aachen.de> wrote:
>> Also sprach Ben Morrow:
>>> No, they can't. You give no indication of how someone might go about
>>> this.
>>
>> As if that would be a problem.
>
>> I learnt it with the help
>> of a very flimsy introduction
>
>
> Were you in edgrsprj's suggested target audience then, or were you
> already a "programmer"?
I wasn't yet a programmer by this time. I had listened to the
introduction lecture to programming at university (that was Modula3;
guess how much of a programmer you can be after that).
Looking back, I am quite happy that I learnt Perl the way I did. I
immediately started with programs that I wanted to write. I ignored all
the features that I didn't seem to need for them. Thus I learnt Perl
with somes "holes" in it that I closed later en-passant.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 1 Feb 2004 18:06:12 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: how to check for ip address that falls inside a range.
Message-Id: <bvjf6k$d7$1@canopus.cc.umanitoba.ca>
In article <mW3Tb.1$391.6380@news.dircon.co.uk>,
Jonathan Stowe <jns@gellyfish.com> wrote:
|Ben Morrow <usenet@morrow.me.uk> wrote:
|> roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote:
|>> In article <dfd17ef4.0401291843.9179d79@posting.google.com>,
|>> for each of the three IP addresses, split the IP address on '\.',
|>> say into @ipd;
|> Or, better, use Regexp::Common.
|Or, perhaps not better, the inet_aton() subroutine in Socket.
We went over that already. Socket::inet_aton() is documented
as producing an opaque structure, and the documentation says one
should not assume the result is 32 bits wide. For example, if your
system supports IPv6, then even though you feed a dotted quad in,
the resulting structure is not certain to be 32 bits wide, and
is not certain to be numerically comparable.
--
Usenet is one of those "Good News/Bad News" comedy routines.
------------------------------
Date: Sun, 1 Feb 2004 14:09:36 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: interpreting script
Message-Id: <bvj1b0$h84$1@wisteria.csv.warwick.ac.uk>
Michele Dondi <bik.mido@tiscalinet.it> wrote:
> On Sat, 31 Jan 2004 17:52:09 +0000 (UTC), Ben Morrow
> <usenet@morrow.me.uk> wrote:
> >Michele Dondi <bik.mido@tiscalinet.it> wrote:
>
> >> or perhaps:
> >>
> >> unlink $_ and
> >> !print "Removing `$_'\n" or
> >> warn "Can't remove `$_': $!\n" for
> >> grep /\Q_ppsd.zip/ && -M >30,
> >> <*.downloaded *.kl2_download>
> >
> >Ouch! What's that ! there for? Assuming the print will always
> >succeed, this evaluates as
> >
> > (unlink and 0) or warn
>
> In fact this is what I want. Pease read more carefully and you'll
> discover that...
>
> >which means that the warn will always happen. Even without that, it's
> ^^^^^^
>
> ...it will always happen *if* unlink() succeeds. Won't it?
No. The print will happen iff the unlink succeeds, but the warn will
always happen. Consider:
1. unlink fails
(0 and <not evaluated>) or warn
=> 0 or warn
=> warn
2. unlink succeeds
(1 and 0) or warn
=> 0 or warn
=> warn
I am slightly puzzled as to what you even *thought* you meant to
write?
Ben
--
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based
on the strictest morality. [Samuel Butler, paraphrased] ben@morrow.me.uk
------------------------------
Date: 1 Feb 2004 15:13:30 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: ISO lightweight OO-RDBMS in Perl
Message-Id: <Xns94826804CA036asu1cornelledu@132.236.56.8>
kj <no-email@please.post.com> wrote in news:bvivl5$m5i$1@reader2.panix.com:
> Note: I'm *not* interested in Perl interfaces to standard RDBMSs
> like MySQL or Oracle.
I am not sure if you'll appreciate this, but I will recommend SQLite
coupled with Class::DBI. At the very least, read the docs for Class::DBI
for examples of how to use that module to solve problems similar to yours.
Sinan.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: Sun, 01 Feb 2004 14:15:31 GMT
From: p cooper <pdconetwofour_numbers_@yahoo.co.uk>
Subject: Mail::Lite not finding file??
Message-Id: <7S7Tb.3420$7P3.31321271@news-text.cableinet.net>
I can convert a pipe-delimited file to *.xls and can read it locally using
excel.
I then try to attach it to an email:
at the other end the email comes through with a 0K (empty) attachment with
the correct name.
Im using a defined variable for the path and filename in case it was typos.
In addition running the script from the command line generates no errors
and the message comes through the system.
Run from the browser I get
Can't call method "add_worksheet" on an undefined value
at /home/servers/ais/cgi-bin/excel.pl line 23.
(historical path...)
Not sure if they are related........
#!/usr/bin/perl -w
use CGI qw (:cgi-lib standard carpout); # Include CGI functions
use CGI::Carp qw(fatalsToBrowser); # Send error messages to browser
use Fcntl ':flock'; # import LOCK_* constants
use strict;
use Spreadsheet::WriteExcel;
use MIME::Lite;
my $path ="/home/paul/";
my $dbfile='db.xls';
my $pathdb=$path.$dbfile;
# Create a new Excel workbook
my $workbook = Spreadsheet::WriteExcel->new($pathdb);
# Add a worksheet
my $worksheet = $workbook->add_worksheet();
open(FH,"</tmp/results");
my @data=(<FH>);
close (FH);
my $n=1;
foreach my $i (@data)
{
chomp $i;
my @a = split(/\|/, $i);
$array_ref = \@a;
$worksheet->write($n, 0, $array_ref);
$n++;
}
my $message = MIME::Lite->new(
From => 'xxxxx@xx.ac.uk' ,
To => 'xxx@blueyonder.co.uk' ,
Cc =>'xxx@yahoo.com',
Subject => "The database file as an Excel format",
Type => "text/plain",
Encoding => '7bit',
Data => "Database file"
);
my ($mime_type, $encoding) = ('application/vnd.ms-excel', 'base64');
$message->attach (
Type => $mime_type ,
Encoding => $encoding ,
Path => $pathdb ,
Filename => 'database.xls'
);
# ----- Tell MIME::Lite to use Net::SMTP instead of sendmail
MIME::Lite->send('smtp', 'smtp.isp.com', Timeout => 20);
$message->send;
------------------------------
Date: Sun, 01 Feb 2004 14:41:30 GMT
From: p cooper <pdconetwofour_numbers_@yahoo.co.uk>
Subject: Re: Mail::Lite not finding file??
Message-Id: <ue8Tb.3446$c04.31501514@news-text.cableinet.net>
sorry -current version is this:
my $message = MIME::Lite->new(
From => 'xxx@xx.ac.uk' ,
To => 'xxx@blueyonder.co.uk' ,
Cc =>'xxx@yahoo.com',
Subject => "The database file as an Excel format",
Type => 'multipart/mixed',
Encoding => '7bit',
# Data => "Database file"
);
my ($mime_type, $encoding) = ('application/vnd.ms-excel', 'base64');
$message->attach(Type => 'TEXT',
Data => 'I hope you can use this!');
$message->attach (
Type => $mime_type ,
# Encoding => $encoding ,
Path => $pathdb ,
Filename => 'database.xls'
);
# ----- Tell MIME::Lite to use Net::SMTP instead of sendmail
MIME::Lite->send('smtp', 'smtp.blueyonder.co.uk', Timeout => 20);
$message->send;
------------------------------
Date: Sun, 01 Feb 2004 14:45:18 GMT
From: p cooper <pdconetwofour_numbers_@yahoo.co.uk>
Subject: Re: Mail::Lite not finding file??
Message-Id: <2i8Tb.3450$c04.31501514@news-text.cableinet.net>
fixed - I need a $workbook-> close before doing anything with it
------------------------------
Date: Sun, 01 Feb 2004 14:49:33 GMT
From: p cooper <pdconetwofour_numbers_@yahoo.co.uk>
Subject: Re: Mail::Lite not finding file??
Message-Id: <1m8Tb.3454$c04.31501514@news-text.cableinet.net>
but I still get this when calling it from a browser
Can't call method "add_worksheet" on an undefined value
at /home/servers/ais/cgi-bin/excel.pl line 23.
router paul # cat -n /home/servers/aninfosys/cgi-bin/excel.pl
17 my $path ="/home/paul/";
18 my $dbfile='db.xls';
19 my $pathdb=$path.$dbfile;
20 # Create a new Excel workbook
21 my $workbook = Spreadsheet::WriteExcel->new($pathdb);
22 # Add a worksheet
23 my $worksheet = $workbook->add_worksheet();
24 # Add and define a format
25 my $format = $workbook->add_format(); # Add a format
26 # $format->set_bold();
------------------------------
Date: Sun, 1 Feb 2004 17:02:43 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Mail::Lite not finding file??
Message-Id: <bvjbfj$nbt$1@wisteria.csv.warwick.ac.uk>
p cooper <pdconetwofour_numbers_@yahoo.co.uk> wrote:
> but I still get this when calling it from a browser
> Can't call method "add_worksheet" on an undefined value
> at /home/servers/ais/cgi-bin/excel.pl line 23.
> router paul # cat -n /home/servers/aninfosys/cgi-bin/excel.pl
>
> 17 my $path ="/home/paul/";
> 18 my $dbfile='db.xls';
> 19 my $pathdb=$path.$dbfile;
> 20 # Create a new Excel workbook
> 21 my $workbook = Spreadsheet::WriteExcel->new($pathdb);
> 22 # Add a worksheet
> 23 my $worksheet = $workbook->add_worksheet();
Chances are the permissions on /home/paul/db.xls are wrong. They
should be 0666; and if the file doesn't exist, you will need 777
permissions on the directory it's in as well. I'd suggest you create
the file in /tmp if all you are doing with it is mailing it somewhere.
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: Sun, 1 Feb 2004 17:17:22 +0100
From: "Xaver Biton" <javier@t-online.de>
Subject: network card
Message-Id: <bvj8nc$v8o$07$1@news.t-online.com>
hi,
there's a way to set up a network card and create a a network connection
with perl on win32. It woul be great if you couls mane me an example.
Thks.
Xavre
------------------------------
Date: Sun, 1 Feb 2004 17:31:59 +0100
From: "Xaver Biton" <javier@t-online.de>
Subject: Re: network card
Message-Id: <bvj9ip$5jg$05$1@news.t-online.com>
> there's a way to set up a network card and create a a network connection
> with perl on win32. It woul be great if you couls mane me an example.
I see some Programms, that by installing it, they create a network
connection, for the current user, how they do that. I ve tried with
Win32::IPHelper and with Win32::IPConfig, but a can see only the current
configuration, the question is how can I create a totally new connection?
Thks.
Xaver
------------------------------
Date: Sun, 1 Feb 2004 08:26:47 -0600
From: Web Surfer <raisin@delete-this-trash.mts.net>
Subject: Re: Newbie question. Get list of files in subdir.
Message-Id: <MPG.1a86c8a4e5bde2a09897a6@news.mts.net>
[This followup was posted to comp.lang.perl.misc]
In article <pan.2004.02.01.04.09.27.199380@inette.com>,
DHxxxx@inette.com says...
> How do I read in a list of all the files in a subdirectory?
>
> I just want to build a list of the .wav files that are in a folder so that
> I can feed them to an encoder. This should be very simple - so simple
> that I am obviously overlooking the obvious. However, I have learned a ton
> of stuff trying, for sure:)
>
> Thanks
> DH
>
Try the following :
open(DIR,"$dirname") or die("opendir failed for $dirname : $!\n");
@entries = readdir DIR;
closedir DIR;
@wav = grep /\.wav$/i,@entries;
print "The .wav files under $dirname are : ",
join(", ",@wav),"\n";
------------------------------
Date: Sun, 1 Feb 2004 10:28:19 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Newbie question. Get list of files in subdir.
Message-Id: <slrnc1qa93.8vb.tadmc@magna.augustmail.com>
Web Surfer <raisin@delete-this-trash.mts.net> wrote:
> [This followup was posted to comp.lang.perl.misc]
We can tell because we are reading comp.lang.perl.misc.
Why do you feel it necessary to point that out in every post?
> Try the following :
>
> open(DIR,"$dirname") or die("opendir failed for $dirname : $!\n");
>
> @entries = readdir DIR;
> closedir DIR;
>
> @wav = grep /\.wav$/i,@entries;
You don't need the @entries temporary variable:
my @wav = grep /\.wav$/i, readdir DIR;
(you _do_ have "use strict" enabled, don't you?)
> print "The .wav files under $dirname are : ",
> join(", ",@wav),"\n";
You don't even need the @wav temporary variable (untested):
print "The .wav files under $dirname are : ",
join(", ", grep /\.wav$/i, readdir DIR),"\n";
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 1 Feb 2004 14:51:06 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Perl For Amateur Computer Programmers
Message-Id: <Pine.LNX.4.53.0402011443120.16494@ppepc56.ph.gla.ac.uk>
On Sat, 31 Jan 2004, Alan J. Flavell wrote:
> On Sat, 31 Jan 2004, Walter Roberson wrote:
>
> > [Last time I posted mentioning that I'd seen it used in the UK, someone
> > replied to the effect of "No, it isn't used here!". Gee, I guess my
> > eyes must have been playing tricks on me...]
>
> Sorry, but I think you've been seeing a cursively-handwritten "lb".
> They do look very similar.
Apologies if I seem to be prolonging this off-topic subthread beyond
reason, but I've been searching around a bit, and this does seem to
throw reasonable light on the whole thing:
http://www.encyclopedia4u.com/n/number-sign.html
* Used as the symbol for the pound avoirdupois in the U.S. (where
lb. would be used in the UK and Canada). Never called 'pound' in the
UK.
o Keith Gordon Irwin in, The Romance of Writing, p. 125
says: "The Italian libbra (from the old Latin word libra, "balance")
represented a weight almost exactly equal to the avoirdupois pound of
England. The Italian abbreviation of lb with a line drawn across the
letters was ... used for both weights. The business clerk's hurried
way of writing the abbreviation appears to have been responsible for
the # sign used for pound."
http://home.swipnet.se/PharmHist/Frsvar/lbsign.html
has some nice pictures of old handwritten lb signs.
cheers
------------------------------
Date: Sun, 01 Feb 2004 15:08:05 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: "edgrsprj" <edgrsprj@ix.netcom.com>
Subject: Re: Perl For Amateur Computer Programmers
Message-Id: <8eeb3be9cde69001f97e2d14f769ca91@news.teranews.com>
>>>>> "edgrsprj" == edgrsprj <edgrsprj@ix.netcom.com> writes:
edgrsprj> It appears that I am near the center of an informal effort
edgrsprj> to get a variety of international earthquake forecasting
edgrsprj> procedures coordinated.
Then do us all a favor. Stick to your domain of expertise. If you
want to nudge other people toward Perl, just point them at
http://learn.perl.org, where people with an expertise in *Perl* are
organizing references and pointers, far better than you will ever have
the time to do.
Please.
The most thing I've learned about writing tutorials is that I have to
know about ten times as much as what I'm trying to teach, so that I
can know what *not* to say as well as what to say. "What to leave
out" is a very important decision.
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sun, 01 Feb 2004 17:48:32 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: Perl For Amateur Computer Programmers
Message-Id: <Xns9482824C73591dkwwashere@216.168.3.30>
"edgrsprj" <edgrsprj@ix.netcom.com> wrote:
> "David K. Wall" <dwall@fastmail.fm> wrote in message
> news:Xns9481978B1775Bdkwwashere@216.168.3.30...
>> "edgrsprj" <edgrsprj@ix.netcom.com> wrote:
>>
>> I don't consider myself an expert at programming or Perl, but even so I
>> can see numerous incorrect, incomplete, and misleading statements on
>> that page.
>
> Those short sections of code are what is important at my Web site. I
> have Perl up and running. It is possible that some errors might have
> gotten into those codes during copy operations. But I ran each of them
> on my own computer. And they all appeared to work fine.
It's not only possible that there are errors, it's certain.
* There's code there that uses open() without a comma after the
filehandle, which will not compile.
* Whatever HTML editor you used apparently uses Microsoft's so-called
"smart quotes". If someone cuts and pastes code with "smart quotes" in it,
that code will not compile even if it is otherwise syntactically correct.
(Yes, I tried it.)
* '$char = getc <STDIN>;' ? That's just wrong. It doesn't "work fine". It
won't even compile.
Even when the syntax is okay, there are other problems.
For example, here are a few things that jumped out at me from just skimming
the page:
* you use open() without mentioning that you should always check to see if
the open() succeeded.
* $a and $b are special variables, but you'd never guess it from this web
page.
* 'print localtime Generates a lengthy number representing the local
time.' That is not what is happening. (and where is the semicolon ending
the statement?) localtime() is in list context because of the print(), so
it returns a list of numbers, which are then printed without anything in
between them because *that's what you told perl to do*. Sigh.
We here in c.l.p.m could go over every word in that page and point out all
the flaws, but we're not going to. It's a waste of time. Besides, we might
miss something subtle or just not mention it because it's so obviously
wrong. Then you might think the code is okay because no-one said anything
about it.
A number of people whose opinions I respect have told you that this web
page is a bad idea and that the information on it is flawed at best. If
you're going to ignore their opinions, why did you even bother to ask?
Here's a thought experiment: I get interested in earthquakes, think
they're really cool, and enthusiastically write a web page about them and
post to alt.earthquake (or whatever) asking for opinions. You write back
telling me the page is inaccurate because, among other things, earthquakes
aren't caused by rock trolls having sex. I respond by saying, ok, I have a
few mistakes, but I still want to tell people about earthquakes, I'm
leaving the page on the server. Do you help me correct my page, or write me
off as an ignorant but well-intentioned crank and go on to more interesting
things?
--
David Wall
------------------------------
Date: Sun, 01 Feb 2004 17:58:07 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Perl For Amateur Computer Programmers
Message-Id: <x74quan0ls.fsf@mail.sysarch.com>
>>>>> "DKW" == David K Wall <dwall@fastmail.fm> writes:
DKW> Here's a thought experiment: I get interested in earthquakes,
DKW> think they're really cool, and enthusiastically write a web page
DKW> about them and post to alt.earthquake (or whatever) asking for
DKW> opinions. You write back telling me the page is inaccurate
DKW> because, among other things, earthquakes aren't caused by rock
DKW> trolls having sex. I respond by saying, ok, I have a few
DKW> mistakes, but I still want to tell people about earthquakes, I'm
DKW> leaving the page on the server. Do you help me correct my page,
DKW> or write me off as an ignorant but well-intentioned crank and go
DKW> on to more interesting things?
i was taught that it was because we didn't appease the gods and they
were stomping around doing polkas. and that we can stop them by offering
up perl virgins in sacrifice. i should put this up in a web page
too. does anyone who knows how to *program* in html wanna help me?
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 1 Feb 2004 18:30:35 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Perl For Amateur Computer Programmers
Message-Id: <bvjgkb$10s$1@canopus.cc.umanitoba.ca>
In article <Pine.LNX.4.53.0401311940400.7469@ppepc56.ph.gla.ac.uk>,
Alan J. Flavell <flavell@ph.gla.ac.uk> wrote:
:On Sat, 31 Jan 2004, Walter Roberson wrote:
:> [Last time I posted mentioning that I'd seen it used in the UK, someone
:> replied to the effect of "No, it isn't used here!". Gee, I guess my
:> eyes must have been playing tricks on me...]
:Sorry, but I think you've been seeing a cursively-handwritten "lb".
:They do look very similar.
It was definitely # I saw, not a cursive "lb" (with or without a line
across it.) In the UK, it was mostly in small stores that I saw it,
but occasionally in places like Safeway.
--
Aleph sub {Aleph sub null} little, Aleph sub {Aleph sub one} little,
Aleph sub {Aleph sub two} little infinities...
------------------------------
Date: Sun, 1 Feb 2004 17:37:23 +0100
From: "Pete" <nospam@gobotherverisign.com>
Subject: Re: Upgrading
Message-Id: <SZSdnRz4WoH0toDdRVn-jw@giganews.com>
"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:bvi7rv$2rs$1@wisteria.csv.warwick.ac.uk...
> "Pete" <nospam@gobotherverisign.com> wrote:
> > If I want to upgrade from Perl 5.8.0 to 5.8.2_2, will I have
> > to recompile/reinstall everything based on xs? I rather not.
>
> No. Binary compatability broke between 5.6 and 5.8, but not
> between 5.8 versions.
Thanks, Ben.
I compiled a new Perl, v5.8.2_3, changed the shebang line of a major program
(threaded daemon), and added a BEGIN {} section:
#!/usr/local/perlthreaded/bin/perl
BEGIN {
push (@INC, "/usr/local/threadedperl/lib/perl5/site_perl/5.8.0/mach");
push (@INC, "/usr/local/threadedperl/lib/perl5/site_perl/5.8.0");
push (@INC, "/usr/local/threadedperl/lib/perl5/site_perl");
push (@INC, "/usr/local/threadedperl/lib/perl5/5.8.0/BSDPAN");
push (@INC, "/usr/local/threadedperl/lib/perl5/5.8.0/mach");
push (@INC, "/usr/local/threadedperl/lib/perl5/5.8.0");
}
(I thought I'd do a push, instead of an unshift, so it will only look for my
existing modules if they cannot be found in the original @INC).
To my surprise, the program started up without any problem. But, upon closer
examination, it seemed to leak quite a bit of memory (quite excessively,
actually), and caused unusual long wait times between threads. Finally, I
had to use the old 5.8.0 binary again. :(
Weird. Especially since the program, running with the 5.8.2 binary, reports
no problems. I wonder what I did wrong. Can I even do a BEGIN {} in a
threaded daemon?
- Pete
------------------------------
Date: Sun, 1 Feb 2004 17:08:41 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Upgrading
Message-Id: <bvjbqp$nbt$2@wisteria.csv.warwick.ac.uk>
"Pete" <nospam@gobotherverisign.com> wrote:
> I compiled a new Perl, v5.8.2_3, changed the shebang line of a major program
> (threaded daemon), and added a BEGIN {} section:
>
> #!/usr/local/perlthreaded/bin/perl
>
> BEGIN {
> push (@INC, "/usr/local/threadedperl/lib/perl5/site_perl/5.8.0/mach");
> push (@INC, "/usr/local/threadedperl/lib/perl5/site_perl/5.8.0");
> push (@INC, "/usr/local/threadedperl/lib/perl5/site_perl");
> push (@INC, "/usr/local/threadedperl/lib/perl5/5.8.0/BSDPAN");
> push (@INC, "/usr/local/threadedperl/lib/perl5/5.8.0/mach");
> push (@INC, "/usr/local/threadedperl/lib/perl5/5.8.0");
> }
>
> (I thought I'd do a push, instead of an unshift, so it will only look for my
> existing modules if they cannot be found in the original @INC).
You shouldn't need to do that: Configure will look for older
(compatible) versions of perl installed and ask if you want to add
their @INCs to the default for the new perl.
> To my surprise, the program started up without any problem. But, upon closer
> examination, it seemed to leak quite a bit of memory (quite excessively,
> actually), and caused unusual long wait times between threads. Finally, I
> had to use the old 5.8.0 binary again. :(
>
> Weird. Especially since the program, running with the 5.8.2 binary, reports
> no problems. I wonder what I did wrong. Can I even do a BEGIN {} in a
> threaded daemon?
I should think so... what happens if you take it out?
Ben
--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk
------------------------------
Date: Sun, 01 Feb 2004 18:26:42 +0100
From: Steven Mocking <ufo.removethisspamnote@quicknet.nl>
Subject: Re: {ipc - windows} -| no such command?
Message-Id: <101qdmpsh1n06ea@corp.supernews.com>
Ben Morrow wrote:
>
> Steven Mocking <ufo.removethisspamnote@quicknet.nl> wrote:
>> Ben Morrow wrote:
>> > open STDOUT, ">&=", $TMP or die "dup2 failed: $!";
>>
>> That gives me:
>>
>> Unknown open() mode '>&='
>
> Sorry, stupid mistake. I meant just ">&".
Same problem.
Unknown open() mode '>&'
That only works for expressions. Hence no LIST may be specified.
Perhaps
open STDOUT, ">", $TMP
?
--
Love thy neighbor as thyself, but choose your neighborhood.
-- Louise Beal
------------------------------
Date: Sun, 01 Feb 2004 18:42:50 +0100
From: Steven Mocking <ufo.removethisspamnote@quicknet.nl>
Subject: Re: {ipc - windows} -| no such command?
Message-Id: <101qeks52oeah57@corp.supernews.com>
Steven Mocking wrote:
> Ben Morrow wrote:
>
>>
>> Steven Mocking <ufo.removethisspamnote@quicknet.nl> wrote:
>>> Ben Morrow wrote:
>>> > open STDOUT, ">&=", $TMP or die "dup2 failed: $!";
>>>
>>> That gives me:
>>>
>>> Unknown open() mode '>&='
>>
>> Sorry, stupid mistake. I meant just ">&".
>
> Same problem.
> Unknown open() mode '>&'
>
> That only works for expressions. Hence no LIST may be specified.
> Perhaps
> open STDOUT, ">", $TMP
> ?
pipe $handle[$i-30], TMP;
open STDOUT, ">&TMP"
Works fine.
--
Girls marry for love. Boys marry because of a chronic irritation that
causes them to gravitate in the direction of objects with certain
curvilinear
properties.
-- Ashley Montagu
------------------------------
Date: Sun, 1 Feb 2004 17:59:23 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: {ipc - windows} -| no such command?
Message-Id: <bvjepr$q2s$1@wisteria.csv.warwick.ac.uk>
Steven Mocking <ufo.removethisspamnote@quicknet.nl> wrote:
> Ben Morrow wrote:
> > Steven Mocking <ufo.removethisspamnote@quicknet.nl> wrote:
> >> Ben Morrow wrote:
> >> > open STDOUT, ">&=", $TMP or die "dup2 failed: $!";
> >>
> >> That gives me:
> >>
> >> Unknown open() mode '>&='
> >
> > Sorry, stupid mistake. I meant just ">&".
>
> Same problem.
> Unknown open() mode '>&'
>
> That only works for expressions. Hence no LIST may be specified.
> Perhaps
> open STDOUT, ">", $TMP
Nonononono.
Which Perl are you using? Both these forms (open STDOUT, '>&=', $FH
and open STDOUT, '>&', $FH) work for me with 5.8.2.
What you *actually* want, of course, if only I had been thinking, is
my $kid = open $handle[$i], '-|' or die "can't fork child: $!";
if ($kid) {
# parent
}
else {
# child
}
, which does it all for you...
Ben
--
And if you wanna make sense / Whatcha looking at me for? (Fiona Apple)
* ben@morrow.me.uk *
------------------------------
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 V10 Issue 6063
***************************************