[13414] in Perl-Users-Digest
Perl-Users Digest, Issue: 824 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 16 21:07:18 1999
Date: Thu, 16 Sep 1999 18:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <937530309-v9-i824@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 16 Sep 1999 Volume: 9 Number: 824
Today's topics:
(SOLUTION) Re: CONTEST: Range Searching (Kragen Sitaker)
Re: can i get a witness? (Martien Verbruggen)
Code examples of threads in Perl <brundlefly76@hotmail.com>
Re: CONTEST: Range Searching <perin@panix.com>
Re: CONTEST: Range Searching (Kragen Sitaker)
Re: Critique/comments for web board? (Eric Bohlman)
Re: Help needed about SENDMAIL! (Kragen Sitaker)
Re: Help needed about SENDMAIL! (David Efflandt)
Re: Help with a regular expression (Kragen Sitaker)
HELP: Inserting from text file to Database jbalatsas@my-deja.com
Re: HELP: Inserting from text file to Database (Kragen Sitaker)
Re: Homeworkers Needed! (John Stanley)
how to create (and ref) anonymous objects <ptrainor@bettyjo.downcity.net>
Re: NDBM_File problem. <flavell@mail.cern.ch>
Re: Output pipes to a browser <cassell@mail.cor.epa.gov>
Re: Parsing Tab Delimited File (Kai Henningsen)
Re: perl equivalent of a Unix command line sort? (Larry Rosler)
Re: perl prog for big/little indian conversion (Kragen Sitaker)
Re: Question on Hash of Hash (Larry Rosler)
Re: Searching subdirs with unknown names in known dirs. (Martien Verbruggen)
Re: slightly offtopic: who know ISPs with mod_perl supp (Abigail)
Re: slightly offtopic: who know ISPs with mod_perl supp (Abigail)
Re: slightly offtopic: who know ISPs with mod_perl supp <revjack@radix.net>
Re: Splitting a line and honoring "strings" (Neko)
Re: win32 disk formatting <clarked@hunterdon.csnet.net>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 16 Sep 1999 21:01:19 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: (SOLUTION) Re: CONTEST: Range Searching
Message-Id: <zUcE3.15011$N77.1113425@typ11.nn.bcandid.com>
In article <37e1043e@cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
>So here's the challenge: devise idiomatic solutions to the
>following problems.
>
> 1) Write a "patfore" program that prints out up to N lines
> before the match as well as the match itself. Here's
> the usage message:
>
> patfore [-B N] pattern [files ...]
#!/usr/bin/perl -w
use strict;
# Find a pattern and print lines before the pattern. By Kragen Sitaker,
# 1999-09-16.
# Number of lines to output.
my $n = 4;
my $pattern;
arg: while (@ARGV) {
$ARGV[0] eq '-B' and do {
shift;
$n = 1 + shift;
next arg;
};
do {
$pattern = shift;
last arg;
};
}
# This is probably a lousy way to determine whether we ran out of args.
die "Usage: patfore [-B N] pattern [files ...]\n" if not defined $pattern;
my @lines = ('') x $n;
while (<>) {
push @lines, $_;
shift @lines;
if (/$pattern/o) {
print @lines;
# If the next line contains the pattern again, we don't
# want to output this line again.
@lines = ('') x $n;
}
}
> 2) Write a "pataft" program that prints out up to N lines
> after the match as well as the match itself. Here's
> the usage message:
>
> pataft [-A N] pattern [files ...]
#!/usr/bin/perl -w
use strict;
# Print out lines matching a pattern and lines following them.
# Kragen Sitaker, 1999-09-16.
# Number of lines to print.
my $after = 4;
my $pattern;
arg: while (@ARGV) {
$ARGV[0] eq '-A' and do {
shift;
$after = 1 + shift;
next arg;
};
do {
$pattern = shift;
last arg;
};
}
# This is probably still a lousy way to determine whether we ran out of args.
die "Usage: pataft [-A N] pattern [files ...]\n" if not defined $pattern;
my $linestoprint = 0;
while (<>) {
$linestoprint = $after if /$pattern/o;
print if $linestoprint;
--$linestoprint if $linestoprint;
}
> 3) Write a "patba" program that prints out up to
> X lines before the match and Y lines after the match.
>
> patba [-A X] [-B T] pattern [files ...]
>
> or both N before and after:
>
> patba [-C N] pattern [files ...]
This program is *much* worse than the above programs. I am much less
confident in its correctness.
#!/usr/bin/perl -w
use strict;
# Print out lines matching a pattern, a certain number of lines preceding
# the match lines, and a certain number of lines following them.
# Kragen Sitaker, 1999-09-16.
# Number of lines to print starting at the match and continuing on.
my $after = 4;
# Number of lines to print up to and including the match.
my $before = 4;
my $pattern;
# write sensible output? Default is no.
# sensible output inserts a line saying ... in every place lines
# from the input file was left out, and prepends each output line copied
# from the input file with a space. It's not the default because it wasn't
# in tchrist's spec.
# It doesn't affect the choice of which lines to output, just how to output
# them.
my $sensible = undef;
arg: while (@ARGV) {
$ARGV[0] eq '-A' and do {
shift;
$after = 1 + shift;
next arg;
};
$ARGV[0] eq '-B' and do {
shift;
$before = 1 + shift;
next arg;
};
$ARGV[0] eq '-C' and do {
shift;
$after = $before = 1 + shift;
next arg;
};
$ARGV[0] eq '-s' and do {
shift;
$sensible = 'yes!';
next arg;
};
do {
$pattern = shift;
last arg;
};
}
# This is probably even now a lousy way to determine whether we ran out
# of args.
die "Usage: patba [-s] [-A X] [-B T] [-C N] pattern [files ...]\n"
if not defined $pattern;
# Every line goes exactly one place: either printed out or pushed on the
# preceding lines list.
my $linestoprint = 0;
# The first line of @preceding_lines is never printed. It is there only
# to determine if what we're printing out is contiguous with the last
# output text.
my @preceding_lines = ('') x ($before + 1);
while (<>) {
if ($linestoprint) {
print $sensible ? (" ", $_) : $_;
--$linestoprint;
} else {
push @preceding_lines, ($sensible ? " $_" : $_);
shift @preceding_lines;
}
if (/$pattern/o) {
# $preceding_lines[0] will be '' if @preceding_lines is
# not full.
print "...\n" if $sensible and $preceding_lines[0];
print @preceding_lines[1..$#preceding_lines];
# If the next line contains the pattern again, we don't
# want to output this line again.
@preceding_lines = ('') x ($before + 1);
$linestoprint = $after - 1;
}
}
# Did we read any lines we didn't print?
print "...\n" if $sensible and $preceding_lines[$#preceding_lines];
>For Extra Credit:
> Provide alternate solutions that also coalesce with overlapping
> ranges.
Oops, sorry -- didn't see that. I wouldn't want to try to use these
programs without that.
> * correctness: does it actually do the right thing? if not,
> nothing else matters. :-)
Well, I think that what I was hoping to do is the right thing. I'm
certain my patfore and pataft do what I was hoping to do. My patba
appears to do the right thing, but I have to go home now, so I am
posting this now :)
> * space efficiency: don't use more space than minimally needed
patba and pataft are probably perfect here. patba uses more space than
minimally needed, but not a huge amount -- it keeps around an extra
line of lookbehind when, with just a few more lines of code, it could
just keep a boolean. And it prepends a space to every line in
'sensible' mode.
> * time efficiency: is your solution fast?
Dunno. :)
> * test coverage: do you include test data to check all border cases?
Here's patba.test, which includes only input, not expected output. And
I don't think it's really complete, although it's not obvious to me
what I'm missing. (Well, I know I'm missing the non-sensible cases,
but I'm confident those are at least as correct as the sensible ones.)
#!/bin/sh
../patba
read foo
../patba -C 3
read foo
../patba -s -C 0 pattern patba | less
../patba -s -C 1 pattern patba | less
../patba -s -C 2 pattern patba | less
patfore and pataft I tested by hand.
> * conciseness: keep it short. no frills. just a few lines.
True of patfore and pataft. Probably not true of patba. You'll
probably think $sensible is a frill, but I think it's a necessity to
understand the output.
> * clarity: is this understandable to a native perl speaker?
I've never met one. And don't you mean Perl, not perl?
> * idiom: does this look like natural perl? does it use cool
> perl features absent in other languages?
I don't know. :)
> * creativity: is your solution cleverly different from those
> of others?
Probably not.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Fri, 17 Sep 1999 00:27:55 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: can i get a witness?
Message-Id: <fWfE3.95$je2.7108@nsw.nnrp.telstra.net>
In article <Pine.SUN.3.91.990915213855.8387A-100000@si.ucsc.edu>,
Jonathan Cooper Weiss <jcweiss@cats.ucsc.edu> writes:
> benifits of the preloaded code and DB connections), i find it hard to
> believe that a C solution (which is the only "superior" alternative i can
> imagine he was talking about) would be incomparably better. not having a
I wouldn't be too sure about C being the only alternative here. PHP
comes to mind. I don't suggest that I know what your followup meant,
or even that PHP is inherently better than perl for this, but I could
probably come up with a few alternative
languages/environments/toolsets when given the project outline and
brief. Together with the requirements for speed, coding time,
maintenance costs, scalabitlity, etc., perl may very well come out on
top, but it may also end up being not the best solution. C may win,
PHP may win, even Java may win (depending on who needs to maintain the
code), although that's unlikely.
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: Thu, 16 Sep 1999 23:18:29 GMT
From: Brundle <brundlefly76@hotmail.com>
Subject: Code examples of threads in Perl
Message-Id: <7rrtrr$5ad$1@nnrp1.deja.com>
Does anyone have any good code examples in Perl of thread usage?
I need to multithread a TCP/IP client in order to saturate a remote
server.
Right now I open 5 socket connections to the server and send to them
round-robin, but this does not work as it is still serial.
Given a list of messages to deliver, I need to send the list to all 5
and not wait for the response on each before moving to the next.
I am open to alternative reccommendations or suggestions as well.
Thanks
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 16 Sep 1999 16:48:20 -0400
From: Lewis Perin <perin@panix.com>
Subject: Re: CONTEST: Range Searching
Message-Id: <pc7906637mz.fsf@panix6.panix.com>
Tom Christiansen <tchrist@mox.perl.com> writes:
> [...]
> # Print all line pairs where the first one ends
> # in YIN and the next starts with YANG.
> while (<DATA>) {
> $n = /YIN$/ ... $n or next;
> $pair .= $_;
> 1 - $n || next;
> /^YANG/ && print $pair;
> $pair = '';
> }
Perhaps it was deliberate, but the above code doesn't snag the second
pair if it overlaps with the first, as in
YIN
YANGYIN
YANG
Cheers, Lew
------------------------------
Date: Fri, 17 Sep 1999 00:54:06 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: CONTEST: Range Searching
Message-Id: <OigE3.15240$N77.1145605@typ11.nn.bcandid.com>
In article <7rrrc9$dj8@cocoa.brown.edu>, Don Blaheta <dpb@cs.brown.edu> wrote:
> # pataft
> while (<>) {
> $aftleft = $aft + 1 if /$pat/o;
> print and $aftleft-- if $aftleft;
> }
Very nice! Exactly the same method I used.
> #patfore
> while (<>) {
> shift @forelines if @forelines > $fore;
> push @forelines, $_;
> print @forelines and @forelines = () if /$pat/o;
> }
Also very nice; slightly different approach than my code, but very
similar.
Both of these programs avoid printing the same line more than once.
> #patba
> while (<>) {
> shift @forelines if @forelines > $fore;
> push @forelines, $_;
> print and $aftleft-- and @forelines = () if $aftleft;
> print @forelines and $aftleft = $aft if /$pat/o;
> }
This is the one I had the most trouble with, mostly avoiding the
overlap.
What happens here if $aft is 0 and we get two sequential input lines
with the pattern?
> use Getopt::Std;
>
> getopt('ABC', \%opt);
> $fore = $opt{B} || $opt{C} || 3;
> $aft = $opt{A} || $opt{C} || 3;
> $pat = shift;
Damn. I need to learn more about the standard modules!
I notice you're not using strict.
I also notice you picked the same default number of lines as I did!
>> * time efficiency: is your solution fast?
>
>Hard to say until I have something to test it against. I think I at
>least avoided anything excruciatingly _slow_.
I'll test it against mine when I have the time :)
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 17 Sep 1999 00:35:46 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Critique/comments for web board?
Message-Id: <7rs2d2$b24@dfw-ixnews6.ix.netcom.com>
Mark-Jason Dominus (mjd@op.net) wrote:
: # grab the message fields and put them in their own variables
: # so I don't have to type so much when maintaining this code
: my %f;
: foreach $fieldname ( keys %{$Messages{$id}} ) {
: $f{$fieldname} = $Messages{$id}{$fieldname};
: }
:
: Now you have to write $f{SUBJECT} or whatever. That is only three
: characters extra, and you no longer run the risk of smashing variables
: in distant parts of the program.
:
: Also, when you write it like this, it becomes immediately apparent
: that you can make it shorter and simpler at the same time:
:
: # grab the message fields and put them in their own variables
: # so I don't have to type so much when maintaining this code
: my %f = %{$Messages{$id}};
:
: This is shorter, simpler, safer, and more efficient. That is a couple
: of big wins and a medium-sized win, and the cost in return is that you
: have to write
:
: $f{SUBJECT}
:
: instead of
:
: $SUBJECT
But at the cost of typing one extra character, it can be even shorter,
simpler and more efficient if you remember how multidimensional hashes
are implemented:
my $f = $Messages{$id};
and then write $$f{subject} which avoids the need to mass-copy the fields.
------------------------------
Date: Fri, 17 Sep 1999 00:33:22 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Help needed about SENDMAIL!
Message-Id: <m%fE3.15214$N77.1142511@typ11.nn.bcandid.com>
In article <37E14DFC.90363DA7@chat.carleton.ca>,
Young-Soo Roh <ysroh@chat.carleton.ca> wrote:
>Is anybody know how to attach the file(ex. postscript) using sendmail?
>I am trying to send email using sendmail in Perl.
>ex)
>open(MAIL, "|/usr/lib/sendmail -t");
>print MAIL "To: xxx";
>print MAIL "Subject:xxx";
>
>But I don't know how to attatch the file.
MIME::something? See CPAN.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 17 Sep 1999 00:49:59 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Help needed about SENDMAIL!
Message-Id: <slrn7u341u.kb.efflandt@efflandt.xnet.com>
On 16 Sep 1999 20:02:32 GMT, Young-Soo Roh <ysroh@chat.carleton.ca> wrote:
>Hello everyone?
>
>Is anybody know how to attach the file(ex. postscript) using sendmail?
>I am trying to send email using sendmail in Perl.
>ex)
>open(MAIL, "|/usr/lib/sendmail -t");
>print MAIL "To: xxx";
>print MAIL "Subject:xxx";
>
>But I don't know how to attatch the file.
It is easy with the MIME::Lite module, but you probably have to install it
yourself. If you don't have root access you can simply create a dir for
your own perl modules, put a dir called MIME there and put Lite.pm in
MIME. You point to the directory that MIME is in with a 'use lib'
statement. Then 'use MIME::Lite;' will search there for MIME/Lite.pm.
--
David Efflandt efflandt@xnet.com http://www.xnet.com/~efflandt/
http://www.de-srv.com/ http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/
------------------------------
Date: Fri, 17 Sep 1999 00:57:21 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Help with a regular expression
Message-Id: <RlgE3.15245$N77.1145900@typ11.nn.bcandid.com>
In article <lq1vh9ali9b.fsf@bmers31f.ca.nortel.com>,
Mark Mielke <markm@nortelnetworks.com> wrote:
>It's not a bad habit, it's just unnecessary. . . .
>
>It's not a bad habit, it's just unnecessary. If you prefer to write
>it out in full, then by all means go right ahead. . . .
Agreed.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Thu, 16 Sep 1999 23:46:22 GMT
From: jbalatsas@my-deja.com
Subject: HELP: Inserting from text file to Database
Message-Id: <7rrvgc$6hg$1@nnrp1.deja.com>
Cant use include statement because cant use variable as filename
Cant use scripting.filesystemobject because permission denied
Cant use extra filedsn since only allowed 1 dsn on site
* Can I Read a csv text file in perl/cgi (that has been uploaded onto
server)
* append the records into my database
* and delete the text file
Sound easy?
But how?
Thanks in advance
JB
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 17 Sep 1999 00:32:08 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: HELP: Inserting from text file to Database
Message-Id: <c_fE3.15211$N77.1142256@typ11.nn.bcandid.com>
In article <7rrvgc$6hg$1@nnrp1.deja.com>, <jbalatsas@my-deja.com> wrote:
>Cant use include statement because cant use variable as filename
>Cant use scripting.filesystemobject because permission denied
>Cant use extra filedsn since only allowed 1 dsn on site
Are these error messages? I don't understand them.
>* Can I Read a csv text file in perl/cgi (that has been uploaded onto
>server)
Yes.
>* append the records into my database
Presumably.
>* and delete the text file
Yes.
>Sound easy?
Yes.
>But how?
Which part are you having trouble with? Can you post your code?
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 16 Sep 1999 23:48:33 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Homeworkers Needed!
Message-Id: <7rrvkh$sg3$1@news.NERO.NET>
In article <37E15B3B.5893BC03@mail.cor.epa.gov>,
David Cassell <cassell@mail.cor.epa.gov> wrote:
>Anyone else who saw this should feel free to write to
> abuse@nero.net
>and complain, as I already did.
Don't bother. The spam was cancelled when I became aware of it. The
gateway through which the spam was posted has been shut down.
The real source of the spam, however, is still open and, I presume,
dumping the garbage out into the world's mailboxes.
At least we got one mail to news gateway shut off. That's all that's
important. Complaining someplace that can close the spammer's account
isn't.
------------------------------
Date: Thu, 16 Sep 1999 19:15:50 -0400
From: Pat Trainor <ptrainor@bettyjo.downcity.net>
Subject: how to create (and ref) anonymous objects
Message-Id: <Pine.LNX.3.96.990916190404.31910C-100000@bettyjo.downcity.net>
Greets
I need to create objects anonymously, and have been frustratingly
unsuccessful. Given:
#!/usr/bin/perl
#
use Module;
for ($fred=1;$fred<10;$fred++) {
${$fred} = Pluckit->new;
${$fred}->obj_id("$fred");
}
print "id is: ", ${1}->obj_id, "\n";
failure on compile is:
Most public domain software is free, at least at first glance.
lisa:~# telnet betyjo.downcity.net
betyjo.downcity.net: Unknown host
lisa:~# telnet bettyjo.downcity.net
Trying 199.105.120.6...
Connected to bettyjo.downcity.net.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
lisa:~# ssh -l ptrainor bettyjo.downcity.net
Received signal 2. (no core)
lisa:~# ssh -l ptrainor aura
ptrainor's password:
Linux 2.0.34.
7:44pm up 42 days, 2:20, 8 users, load average: 0.00, 0.07, 0.11
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
latraino tty6 5Aug99 42days 5:28 0.12s
startx
xuser ttyp0 :0.0 5Aug99 21days 1:29 1:28 ssh -l
nobody m
latraino ttyp1 jenny.title14.co12:48pm 34:52 0.66s 0.53s pine
ptrainor ttyp2 206.34.180.228 7:44pm 2:20m 0.23s 0.17s w
xuser ttyp3 :0.0 27Aug99 9days 0.55s 0.45s -su
xuser ttyp4 :0.0 6Aug99 3days 0.89s 0.50s tail -n
300 -f
ptrainor ttyp6 206.34.180.228 2:46pm 20:27 4.97s 4.79s pine
latraino ttyp7 jenny.title14.co 2:55pm 2:40m 0.22s 0.16s -su
ptrainor[/home/ptrainor]> telnet bettyjo
Trying 199.105.120.6...
Connected to bettyjo.downcity.net.
Escape character is '^]'.
Linux 2.0.30 (bettyjo.downcity.net) (ttyp1)
bettyjo login: ptrainor
Password:
Linux 2.0.30.
Last login: Thu Sep 16 10:31:58 on ttyp1 from daecfp01.sprint..
No mail.
Welcome to
| __ | __ | | | | | ___ | |__ __ | |
| | | | | | | \ | | | | \ /
| | | | | / | | \ | | | | |
|_____ |_____ |_ \_ |_ \__ |____ |_ |_ |_
bettyjo:~$ ls -alrt
PINE 3.96 COMPOSE MESSAGE <News on news.> comp.lang.perl.misc 3,953
Msgs
Newsgrps: comp.lang.perl.misc
Attchmnt:
Subject : how to create (and ref) anonymous objects
----- Message Text -----
Greets
I need to create objects anonymously, and have been frustratingly
unsuccessful. Given:
#!/usr/bin/perl
#
# file: testfred
#
use Module;
for ($fred=1;$fred<10;$fred++) {
${$fred} = Pluckit->new;
${$fred}->obj_id("$fred");
}
print "id is: ", ${5}->obj_id, "\n";
failure on compile is:
Modification of a read-only value attempted at ./testfred line 6.
Module.pm is a stock store and retrive module, excerpt:
package Module;
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {};
$self->{obj_id} = undef; # there are more than just this..
bless($self, $class);
return $self;
}
sub obj_id {
my $self = shift;
if (@_) { $self->{obj_id} = shift }
return $self->{obj_id};
}
-----------------
I'm using numbers here, but it doesn't matter what is used for
$fred. It seems that the literal '$fred' is being used to make the objects
and not what $fred is carrying at the time.
So as the example script at the top shows, the desired result is
that an object's identity (and therefore attributes) should be accessible
via a scalar value representing the object's identity.
Any suggestions?
TIA!
------------------------------
Date: Fri, 17 Sep 1999 01:28:44 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: NDBM_File problem.
Message-Id: <Pine.HPP.3.95a.990917012555.28707A-100000@hpplus03.cern.ch>
On Thu, 16 Sep 1999, Joseph A. DiVerdi wrote:
> In article <37E10B1B.A2FA6F8C@mcs.drexel.edu>, Justin Smith
<jsmith@mcs.drexel.edu> wrote:
> >Time blows wildly against my door | Justin R. Smith
> >Stirring discarded sorrows | Department of Mathematics and
> >Like dead leaves of summers past | Computer Science
> >Memories of forgotten lore | Drexel University
[...]
> I agree with your thinking.
I have this feeling of deja vu
> My ISP's sys admin has been looking into the problem
That's helpful. I think(?)
------------------------------
Date: Thu, 16 Sep 1999 16:55:22 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Output pipes to a browser
Message-Id: <37E1836A.D58C48DB@mail.cor.epa.gov>
Makarand Kulkarni wrote:
>
> [ Carlo Mantini wrote:
>
> > When I run the script from a command line, the output is
> > sent to my screen. No error messages are being written to the log by the
> > web server.
>
> Do you see lines like
> Content-Type:text/html\n\n
> which tell the browser the content type, printed out when you run
> your programs on the command line. If not, then you have
> to add this HTTP header.
Or even add a line like this instead:
Content-Type: text/html\n\n
since some browsers are insistent on that space after the colon.
:-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 17 Sep 1999 01:15:00 +0200
From: kaih=7P1Eu2r1w-B@khms.westfalen.de (Kai Henningsen)
Subject: Re: Parsing Tab Delimited File
Message-Id: <7P1Eu2r1w-B@khms.westfalen.de>
tchrist@mox.perl.com (Tom Christiansen) wrote on 16.09.99 in <37e0f584@cs.colorado.edu>:
> In a sane world, where "comma-separated values" actually happens to mean
> the remarkably surprising "comma-separated values", this is all it takes:
>
> @fields = split(/,/, $line, -1);
>
> You'll notice that this approach also suffices for the passwd file, etc.
> Those were designed for simplicity.
Which is fine as long as you can sure your delimiters won't occur in your
data.
Of course, *that* assumption is often unacceptable.
> However, programmer-hostile systems seem riddled with programmer-hostile
> files mis-designed by evil and stupid sado-masochistic programmers who
> should have all their fingernails torn out, very slowly. No thought
> is given to simplicity of parsing, which means you get something
> that is *not* simple to parse. Do not call things so-called "CSV
> files" simple, because if they were, then a split would suffice.
Well, often a split *does* suffice, you just need to put more thought into
the regex.
I once wrote a Pascal lexer (including strings and comments) using split.
Of course, the regex went over several lines. But I could slurp the whole
file into one string, and use one split to convert it into a token-and-
whitespace array just fine.
You can do the same with CSV files, *if* they are designed to allow for
(near-)arbitrary data - that is, they use some sort of escaping for the
delimiters.
If they weren't defined that way, though, you get a mess that only a human
can parse.
> It doesn't, so they aren't. And they're hardly "comma-separated".
> They're "quasi-comma-separated with inane hacks and idiosyncrasies
> bearing only a superficial and conquently deceptive resemblance to actual
> comma-separated data".
Only for people who can't program.
Too many of which are around. I just recently ripped apart and rewrote a
DDE Execute string parser written in Pascal that had the exact same
problem of being unable to cope with delimiters inside data. Bloody
amateurs! If I don't do everything myself ...
It boiled down to writing a FindCharOutsideString function and applying it
at about four different places. Would have been much easier with regexes,
too, but not every language can be Perl.
Just in case you're curious, the syntax I wanted was
[name(arg,arg)][name(arg,arg)] where arg, if it contained interesting
chars, would be quoted with "...", and could contain \x for any x and "".
That's essentially the union of the C and Pascal string syntax, except
Pascal uses single quotes. Easy enough to parse.
Kai
--
http://www.westfalen.de/private/khms/
"... by God I *KNOW* what this network is for, and you can't have it."
- Russ Allbery (rra@stanford.edu)
------------------------------
Date: Thu, 16 Sep 1999 16:21:44 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: perl equivalent of a Unix command line sort?
Message-Id: <MPG.124b1b66d7e393ae989f95@nntp.hpl.hp.com>
In article <37e15ade.2235549512@24.64.2.57> on Thu, 16 Sep 1999 21:21:53
GMT, Jim Hutchison <jimhutchison@metronet.ca> says...
> On Mon, 30 Aug 1999 15:46:49 -0700, lr@hpl.hp.com (Larry Rosler)
> wrote:
> >In article <h67ogfo29ty.fsf@baynetworks.com> on 30 Aug 1999 18:16:25 -
> >0400, Paul L. Lussier <plussier@baynetworks.com> says...
> >> I'm trying sort a lists of ip addresses in a script, and thought there
> >> must be a perl way of doing it. I'm can get exactly what I want from
> >> the command line using this:
> >>
> >> sort -n -t. -k 1,1 -k 2,2 -k 3,3 -k 4,4
> >...
> >> ... I've tried various ugly and cpu intensive
> >> ideas with hashes and for loops that seem to just take forever.
...
> >How would a paper whose primary example is sorting a list of strings
> >acccording to an embedded IP address suit you?
...
> ><URL:http://www.hpl.hp.com/personal/Larry_Rosler/sort/>
...
> According to your paper, the Unix sort is much better for huge files,
> which is too bad 'cause I prepfer to use just Perl. I've had to
> resort to it on a Sun E-450 box with 786 mb of memory!!
That's a lot of memory. I'm surprised you can't do a Perl sort.
How much data do you have? (How many strings in the array, how many
bytes per string on average?) It is possible that an index sort may
enable you to halve the amount of memory needed.
Please post the details or send me e-mail.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 17 Sep 1999 00:39:23 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: perl prog for big/little indian conversion
Message-Id: <%4gE3.15223$N77.1143348@typ11.nn.bcandid.com>
In article <37e14772@glitch.nildram.co.uk>, <nwsread@cloudband.com> wrote:
> Hi i am looking for a perl program to convert some
>big indian ultra sparc gdbm files, to little indian 32bit
>gdbm files. Does someone have something in perl that does
>byte conversion?
o/~ Ten little, nine little, eight little Indians o/~
:)
perldoc -f pack
perldoc -f unpack
HTH
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Thu, 16 Sep 1999 16:13:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Question on Hash of Hash
Message-Id: <MPG.124b196892be407e989f94@nntp.hpl.hp.com>
In article <7rrkk4$3pd@news.acns.nwu.edu> on Thu, 16 Sep 1999 15:37:40 -
0500, Chao Fang <cfang@nwu.edu> says...
> <namnan@my-deja.com> wrote in message news:7rr8v7$ku3$1@nnrp1.deja.com...
> > I am trying to print my hash of hash of the following code. It is not
> > printing anything.
> Common phenomina when playing with hash of hash. there is problem with
> dereference.
>
> > foreach $cookie (keys (%hash))
> > {
> > print "$cookie, $hash->{$cookie}";
> > }
> Try to use print "$cookie, $$hash{$cookie}";
> I am not sure it works, but I think it is how it will be solved. when
> playing with hash of hash, you need more layers of $, @, % also.
Or perhaps you could try waving a chicken around over your head and then
sacrificing it. That is as likely to produce good results as your
advice is.
In the snippet above, %hash and $hash refer to different variables --
'different' as in 'they have nothing whatever to do with each other,
other than that the identifier part of the names is the same'. 'Nuff
said?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 17 Sep 1999 00:34:19 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Searching subdirs with unknown names in known dirs.
Message-Id: <f0gE3.98$je2.7108@nsw.nnrp.telstra.net>
In article <7rplf4$8v4$1@schbbs.mot.com>,
"Nicholas Dragotas" <Nicholas.Dragotas@Motorola.com> writes:
While it is very nice of you to provide code for this, a few comments
need to be added:
You should use the strict pragma.
> opendir(SOMEHANDLE, '.');
You should check for success here.
> @FilesInDir = readdir(SOMEHANDLE); # Dir contents loaded in this
Of course, this list will now also contain the current and (depending
on platform and location) parent directory. A grep could have fixed
that, as per documentation.
> foreach $file (@FilesInDir) { # Go over each element
> if (-d $file) {
In this specific case this will work, because you open the current
directory. For completeness, however you should have probably made
sure that you look for the _full_ pathname of the file. The contents
of @FilesInDir will not be full paths, and that cannot be stressed
enough, especially when introducing people to the concept of readdir.
A reference to the documentation might also be helpful, since that
will tell people about all the things you left out, doubtless just for
brevity's sake:
# perldoc -f opendir
# perldoc -f readdir
# perldoc -f closedir
Martien
--
Martien Verbruggen |
Interactive Media Division | Unix is user friendly. It's just
Commercial Dynamics Pty. Ltd. | selective about its friends.
NSW, Australia |
------------------------------
Date: 16 Sep 1999 18:16:53 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: slightly offtopic: who know ISPs with mod_perl support?
Message-Id: <slrn7u2uo4.vd4.abigail@alexandra.delanet.com>
Joern Reder (joern@netcologne.de) wrote on MMCCVII September MCMXCIII in
<URL:news:37E1549E.C5DEDF3F@netcologne.de>:
//
// Does anyone know ISPs who offer this features:
And your Perl question is?
Abigail
--
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 16 Sep 1999 18:22:46 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: slightly offtopic: who know ISPs with mod_perl support?
Message-Id: <slrn7u2v35.vd4.abigail@alexandra.delanet.com>
Elaine -HFB- Ashton (elaine@chaos.wustl.edu) wrote on MMCCVII September
MCMXCIII in <URL:news:37E16BBF.C7F399F3@chaos.wustl.edu>:
{} Joern Reder wrote:
{}
{} > - virtual account with full ftp/telnet/ssh access
{} virtual account or server? at the bare minimum you will need an IP bound
{} to either a physical or logical device.
{}
{} > - min. 200 MB disk space
{}
{} 200mb is a lot but not unheard of.
{}
{} > - no additional charge for data transfer
{} > (actually about 10-15GB / month, 30GB peak)
{}
{} DREAM ON. I'd like to see anyone offer this. Everything is ala carte.
Uhm, well, I happened to get this piece of junk email yesterday offering
20GB of traffic/month. With 250 Mb of disk space. With most of the other
requirements as well. For less than a third Joern is willing to pay.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 17 Sep 1999 00:02:41 GMT
From: revjack <revjack@radix.net>
Subject: Re: slightly offtopic: who know ISPs with mod_perl support?
Message-Id: <7rs0f1$385$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight
Abigail explains it all:
: sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
: h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
: c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
: print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");
Abigail, you are a mutant.
------------------------------
Date: Fri, 17 Sep 1999 00:14:12 GMT
From: tgy@chocobo.org (Neko)
Subject: Re: Splitting a line and honoring "strings"
Message-Id: <37e26883.441084573@news.supernews.com>
On Thu, 16 Sep 1999 12:50:31 GMT, kragen@dnaco.net (Kragen Sitaker) wrote:
>In article <slrn7u1dur.95k.scarblac-spamtrap@flits104-37.flits.rug.nl>,
>Remco Gerlich <scarblac-rt@pino.selwerd.cx> wrote:
>>Lokesh Setia <nospam@hss.hns.com> wrote:
>>> yellow brown black green blue
>>>
>>> What I want is to honor the quotes "" and '' withing the user line
>>> so that the user can embed spaces in the values: like,
>>>
>>> blue "light pink" "dark blue" green 'navy blue'
>>
>>See perlfaq4, "How can I split a [character] delimited string except
>> when inside [character]? (Comma-separated files)".
>
>Not to dis the standard solution from the FAQ, which I have confidence
>is quite good, but you can do this:
>
>#!/usr/bin/perl -w
>use strict;
>my $str = q(blue "light pink" "dark blue" green 'navy blue' 'Hogan\'s color');
>print $1, "\n" while $str =~ /
> ([^\ "'\\]+|
> "(?:\\"|[^\\"]|\\\\)*"|
> '(?:\\'|[^\\']|\\\\)*')/gx;
Here's a version with less backslashing:
print "$1\n" while $str =~ /(
[^"'\\ ]+ |
"(?:\\.|[^"])*" |
'(?:\\.|[^'])*'
)/gx;
--
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=
------------------------------
Date: Thu, 16 Sep 1999 23:19:36 GMT
From: "David Clarke" <clarked@hunterdon.csnet.net>
Subject: Re: win32 disk formatting
Message-Id: <cWeE3.112$sa1.30491@news.goodnet.com>
Michael Nguyen wrote in message ...
>I'm trying to get an application I am writing to allow a user to format a
>disk in the floppy drive on a win 95/98 . I thought of using the system
>command 'format a:' but how do I know if the formatting resulted in a
>clean disk (w/o bad sectors)?
open (INPUT, '>c:/input.txt');
# First line, Enter to begin formatting
# Second Line, Disk label (can be just newline for none)
# Third line, N)o to format another
# Fourth line, exit to Command.com
print INPUT <<"END_INPUT";
LABEL
N
EXIT
END_INPUT
close INPUT;
$results = `type c:\input.txt | command.com /c format a:`;
$results =~ m/what_your_looking_for/;
# Yeah, it's ugly, but what do you expect for a Windoze shell?
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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: The mail to news gateway, and thus the ability to submit articles
through this service to the newsgroup, has been removed. I do not have
time to individually vet each article to make sure that you aren't
abusing the service, and I no longer have any desire to waste my time
dealing with the campus admins when some fool complains to them about an
article that has come through the gateway instead of complaining
to the source.
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 V9 Issue 824
*************************************