[10886] in Perl-Users-Digest
Perl-Users Digest, Issue: 4487 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 23 13:07:23 1998
Date: Wed, 23 Dec 98 10:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 23 Dec 1998 Volume: 8 Number: 4487
Today's topics:
Re: $ troubles <r28629@email.sps.mot.com>
a nicer way? <marty@catnmoose.com>
Re: a nicer way? <che@debian.org>
Re: a nicer way? <tchrist@mox.perl.com>
Re: a nicer way? (Tad McClellan)
Re: Big-Endian to Little-Endian (Steffen Beyer)
Compiling perl scipts into bytecode? <markc@evsx.com>
Equivilent of C's is_alpha() function? aaron1@citizen.infi.net
How do you run Perl CGI scripts on AS400? <steve@grantps.net>
list of bundled modules <r28629@email.sps.mot.com>
Re: Need help with setting up Perl/cgi <r28629@email.sps.mot.com>
Re: Nested sorting (Bill Moseley)
Net::RawIP 0.02 <ksv@gw.al.lg.ua>
Newbie- Close error - Bad File Number jimrsmith@unn.unisys.com
Re: Newbie- Close error - Bad File Number <uri@ibnets.com>
Re: Newbie- Close error - Bad File Number <jeromeo@atrieva.com>
Re: Newbie- Close error - Bad File Number (Tad McClellan)
Please help if you can! <steved@neteffects.com>
Re: Please help me reading .csv textfiles <r28629@email.sps.mot.com>
Re: Please help me reading .csv textfiles (Mark-Jason Dominus)
Re: Please help me reading .csv textfiles (Bart Lateur)
Re: Regex question - removing HTML tags.... (Abigail)
SDBM_File (I'd like one FH to go...) <wells@cedarnet.org>
Re: sizeof() function? (Bart Lateur)
Re: sizeof() function? (Abigail)
trouble accessing arrays from C++ (Timothy C. Gion)
Re: Turning Variables into CAPS? (Tad McClellan)
Re: Turning Variables into CAPS? (Abigail)
webster-server perl script <stupakov@slac.stanford.edu>
Re: webster-server perl script <rra@stanford.edu>
Re: What's wrong with this code? (Abigail)
Re: Where can you get undump (Abigail)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 23 Dec 1998 10:24:19 -0600
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: $ troubles
Message-Id: <36811933.ADE8C500@email.sps.mot.com>
bl968@my-dejanews.com wrote:
>
> I am reading in a file which terminates with a $ to show the proper end of
> file.
>
> I am trying to read the file to verify that the $ is in the file and thus is
> valid.
>
> The problem i get is that perl seems not to recognize the fast that the $ is
> what i am looking for.
>
> Any help is appreciated.
first you need to post part of code that does what you said above, then
maybe someone will be able to help, rather than guess.
-TK
------------------------------
Date: Wed, 23 Dec 1998 11:49:06 -0500
From: Marty Landman <marty@catnmoose.com>
Subject: a nicer way?
Message-Id: <36811F02.736F8307@catnmoose.com>
I need help improving my Perl usage. Here's a routine I've written and
would like to know a nicer way to do the last three assignments (and any
other suggestions).
sub getinput {
read(STDIN,my $buffer,$ENV{'CONTENT_LENGTH'});
@namevalues = split(/&/,$buffer);
foreach $namevalue (@namevalues) {
(my $name,my $value) = split(/=/,$namevalue);
$name =~ tr/+/ /;
$value =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$INPUT{$name} = $value;
}
$id = $INPUT{'id'};
$name = $INPUT{'name'};
$info = $INPUT{'info'};
}
Thanks in advance.
--
_____ Marty Landman _______ http://www.catnmoose.com/ ______
Living Glass http://www.catnmoose.com/livinglass
Mountain Man http://www.catnmoose.com/mountainman
__________Cat 'n Moose Web Site Design & Development_________
------------------------------
Date: 23 Dec 1998 08:55:51 -0800
From: Ben Gertzfield <che@debian.org>
Subject: Re: a nicer way?
Message-Id: <ytt7lvihk6g.fsf@gilgamesh.cse.ucsc.edu>
>>>>> "Marty" == Marty Landman <marty@catnmoose.com> writes:
Marty> I need help improving my Perl usage. Here's a routine I've
Marty> written and would like to know a nicer way to do the last
Marty> three assignments (and any other suggestions).
Sure.
use CGI;
That's a much "nicer" way of doing all that work you've done there. :)
If you need docs on the CGI module, 'perldoc CGI' can help you, or see
www.perl.com. CGI.pm comes with every recent Perl installation.
Ben
--
Brought to you by the letters I and Z and the number 11.
"He's like.. some sort of.. non-giving up.. school guy!" -- Bart Simpson
Debian GNU/Linux -- where do you want to go tomorrow? http://www.debian.org/
I'm on FurryMUCK as Che, and EFNet and YiffNet IRC as Che_Fox.
------------------------------
Date: 23 Dec 1998 17:07:34 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: a nicer way?
Message-Id: <75r80m$18i$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Marty Landman <marty@catnmoose.com> writes:
:I need help improving my Perl usage. Here's a routine I've written and
:would like to know a nicer way to do the last three assignments (and any
:other suggestions).
:
:sub getinput {
: read(STDIN,my $buffer,$ENV{'CONTENT_LENGTH'});
This code is wrong. You forgot to verify the return value. You also
neglected to handle a HEAD or GET case. How about a valid QUERY_STRING on
a POST? And what about file uploads? What about <ISINDEX>? What about
malformed requests?
: @namevalues = split(/&/,$buffer);
You forgot to declare that @namevalues variable.
: foreach $namevalue (@namevalues) {
You forgot to declare that $namevalue variable.
: (my $name,my $value) = split(/=/,$namevalue);
: $name =~ tr/+/ /;
: $value =~ tr/+/ /;
: $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
: $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
That could have been more clearly written as:
for ($name, $value) {
tr/+/ /;
s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
}
: $INPUT{$name} = $value;
You forgot to declare the %INPUT variable. And why
is it in ALL CAPS?
: }
: $id = $INPUT{'id'};
: $name = $INPUT{'name'};
: $info = $INPUT{'info'};
You forgot to declare those three variables.
I suppose the syntax you were looking for was
($id, $name, $info) = @INPUT{ qw/id name info/ };
I'm concerned about all these global variables, however.
:}
:
:Thanks in advance.
There is a reason that the CGI.pm module is standard -- it
allows you to avoid making all these mistakes, and more.
What would be so wrong with using:
use CGI qw(:standard);
$who = param("Name");
$phone = param("Number");
@picks = param("Choices");
(that's from Recipe 19.1 of The Perl Cookbook, BTW.)
or in your case,
use CGI qw(:standard);
$id = param("id");
$name = param("name");
$info = param("info");
There's also the backwards-compatible interface:
use CGI;
CGI::ReadParse();
($id, $name, $info) = @in{ qw/id name info/ };
Isn't that all a lot easier?
--tom
--
English is a 5-tuple ... --dmr
------------------------------
Date: Wed, 23 Dec 1998 11:30:03 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: a nicer way?
Message-Id: <ra9r57.o9c.ln@magna.metronet.com>
Marty Landman (marty@catnmoose.com) wrote:
: I need help improving my Perl usage. Here's a routine I've written and
: would like to know a nicer way to do the last three assignments (and any
: other suggestions).
I would suggest *not making* the last three assignments ;-)
You can use $INPUT{id} anywhere you would use $id...
: $id = $INPUT{'id'};
: $name = $INPUT{'name'};
: $info = $INPUT{'info'};
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 23 Dec 1998 16:10:17 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: Big-Endian to Little-Endian
Message-Id: <75r4l9$c34$1@en1.engelschall.com>
Micha3 Rutka <rutka@lucent.com> wrote:
> sb@engelschall.com (Steffen Beyer) writes:
>> The module Bit::Vector has a built-in method for reversing bit-order...
>> And the module is internally written in C...
> The funny thing is that I know and use Bit::Vector! I just forgot it
> for a while because I am too much in pack/unpack stuff nowdays
> :-). Anyway, thx for info, and I have to admit that I like Bit::Vector
> (together with other your stuff) very much.
You're welcome, of course!
And thanks for your high esteem of my work!
I'm glad you like it and find it useful.
Regards,
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software
http://www.perl.com/CPAN/authors/id/STBEY/ for Download)
http://www.oreilly.de/catalog/perlmodger/bnp.html
New: Build'n'Play 2.1.0 (all-purpose Unix batch installation tool)
------------------------------
Date: Wed, 23 Dec 1998 10:50:27 -0600
From: Mark Clark <markc@evsx.com>
Subject: Compiling perl scipts into bytecode?
Message-Id: <36811F53.A1928AF@evsx.com>
Has anyone has any success packaging perl scripts
into compiled bytecode? To be more specific, perlTk
scrips...or scripts that require/use Tk modules.
Example:
Complile:
perl -MO=Bytecode,-O6,-o,foo.plc foo.pl
Run bytecode:
byteperl foo.plc
----------------
foo.pl script:
#!/usr/bin/perl
use Tk;
use strict;
my($top) = MainWindow->new;
my $button = $top->Button(-text => 'Hello World');
$button->pack();
Tk::MainLoop();
----------------
(perl, version 5.005_53 built for i586-linux)
markc
--
---------------------------------------------------
Mark Clark - markc@evsx.com EVSX, Inc. 512-421-2112
---------------------------------------------------
------------------------------
Date: Wed, 23 Dec 1998 17:17:02 GMT
From: aaron1@citizen.infi.net
Subject: Equivilent of C's is_alpha() function?
Message-Id: <75r8ia$p91$1@nnrp1.dejanews.com>
Hi,
I'm trying to parse a file, and I need to determine if the string variable
that I have the line in contains alphanumeric data or numeric data. So I'm
wondering if Perl has a function like C's is_alpha()?
Thanks,
Aaron
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 23 Dec 1998 11:00:12 -0500
From: "Steve Swett" <steve@grantps.net>
Subject: How do you run Perl CGI scripts on AS400?
Message-Id: <01be2e90$78f45780$21e6b0c7@techdir.grantps.net>
>From a browser, I can run Perl scripts (hello.pl) from the AS/400, but how
do you set it up to run CGI scripts (hello.cgi) that are written with Perl?
I have some experience writing CGI scripts on Unix. The first HTML
document the user encounters contains a form that is "submitted" to a CGI
program for processing -- using the POST method. What must I use as the
name of the CGI program in the POST phrase? How do I prepare the AS/400 to
deal with that?
------------------------------
Date: Wed, 23 Dec 1998 09:57:45 -0600
From: Tk Soh <r28629@email.sps.mot.com>
Subject: list of bundled modules
Message-Id: <368112F9.D0936D9F@email.sps.mot.com>
Does the perl installation come with a filelist (spececially the
standard library) somewhere? I was hoping it should be part of
perldoc's. I need to decide if I should advice my client on the minimum
requirement (versions) as I used some of the 'standard' pm came
installed with my v5.005_1, or if I should simply grab the pm's and sent
them together with my scripts.
In doing the latter, I am not sure if the libraries that I use will be
supported by these older versions. Doing a 'grep' with
'^\s*(use|require)\s+\d' may work, provided the pm's carry these lines
(shouldn't they?). Even so it still seem rather uncomfortable to me.
comment|advice ?
-TK
------------------------------
Date: Wed, 23 Dec 1998 10:22:04 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Shana Priwer <tech@aba-architects.com>
Subject: Re: Need help with setting up Perl/cgi
Message-Id: <368118AC.71AB5B1A@email.sps.mot.com>
[posted to clpm and copy emailed]
Shana Priwer wrote:
>
> Hi - I'm extremely new to CGi and Perl, and hope someone
> can help me set up my system.
>
> I'm running NT 4 Workstation on a P2 266 with about
> 200 megs RAM. We serve our website from this computer
> using IIS, and a modem connection to a local ISP. Our
> website is publicly accessible from anywhere on the net
> by typing in http://ipaddress/iisadmin/index.htm
>
> We want people to be able to upload files to this computer.
> I found a free upload cgi script. I downloaded Perl for
> Win32 and installed it to D:\Perl. When you go to the
> page called upload.cgi, browse for your file, and click
> "upload", you get an http 500 server error.
>
> I'm sure I don't have something set up right, but all
> the online FAQs I've read haven't been able to help
> me get this setup configured.
>
> Can anyone offer me some advice/instructions on what I
> need to do? I'm a 3d modeler/animator by trade so I do have
> some knowledge of certain things about computers, but I'm
> totally new to this.
while someone will be kind to help answer your question, it really isn't
related to Perl. Perhaps you should try the web-authoring newsgroups.
-TK
------------------------------
Date: 23 Dec 1998 16:49:31 GMT
From: moseley@best.com (Bill Moseley)
Subject: Re: Nested sorting
Message-Id: <36811f1b$0$9734@nntp1.ba.best.com>
In article <MPG.10e9f38adc9f640f9898ef@nntp.hpl.hp.com>, lr@hpl.hp.com says...
>But now @sorted is an array of references, not the original array of
>data. Your map needs to be to ${$_->[0]} which will probably change the
>timing considerably.
My point was to not make a duplicate set of data, which might be important
on really large data sets. I typically would just sort a smaller array with
references pointing to the actual data and just the keys. Then used the
sorted references to get at the data.
>Will you consider this, rerun the benchmarks, and let us know?
44) ~ %perl5 2.pl
Data Length = 10
Benchmark: timing 1000 iterations of store_data, store_reference...
store_data: 15 secs (14.34 usr 0.01 sys = 14.34 cpu)
store_reference: 16 secs (14.46 usr 0.00 sys = 14.46 cpu)
Data Length = 100
Benchmark: timing 1000 iterations of store_data, store_reference...
store_data: 17 secs (14.97 usr 0.02 sys = 14.98 cpu)
store_reference: 16 secs (14.71 usr 0.00 sys = 14.71 cpu)
Data Length = 1000
Benchmark: timing 1000 iterations of store_data, store_reference...
store_data: 27 secs (20.62 usr 4.28 sys = 24.90 cpu)
store_reference: 24 secs (18.90 usr 2.20 sys = 21.10 cpu)
Slows things down a bit having to copy the data once. Still better than
copying the data twice.
--------------
Bill Moseley
moseley@best.com
------------------------------
Date: Wed, 23 Dec 1998 19:07:10 +0200
From: "Sergey V. Kolychev" <ksv@gw.al.lg.ua>
Subject: Net::RawIP 0.02
Message-Id: <Pine.LNX.3.96.981223185617.2044A-100000@gw.al.lg.ua>
Good day.
Net::RawIP 0.02 uploaded to CPAN
Changes via version 0.01
0.01 Thu Dec 10 19:48:04 1998
- original version
Wed Dec 16 18:29:25 1998
- implemented udp and icmp packets
Mon Dec 21 18:40:11 1998
- implemented SOL_PACKET and manipulating eth headers
including discovering mac adresses
0.02b Tue Dec 22 15:32:51 1998
- documenting new ethernet related features
0.02 Wed Dec 23 17:59:30 1998
- some man fixes
Alternate download from
http://www.ic.al.lg.ua/~ksv/Net-RawIP-0.02.tar.gz
peace,
----------------------Alchevsk Linux User Group-----------------------
UNIX is user friendly. It's just selective who the friends are.
Linux is like wigwam - no windows, no gates, apache inside.
http://www.ic.al.lg.ua/~ksv | e-mail: ksv@gw.al.lg.ua
PGP key & Geekcode: finger ksv@gw.al.lg.ua
------------------------------
Date: Wed, 23 Dec 1998 16:07:28 GMT
From: jimrsmith@unn.unisys.com
Subject: Newbie- Close error - Bad File Number
Message-Id: <75r4ft$lq2$1@nnrp1.dejanews.com>
I open the output file.
I set autoflush to true.
I select the output file.
I print to the output file.
(loop runs 4 times, 4 records should be written)
I close the file, and STDERR gets Close error...Bad File Number
output file has size 0 bytes.
permissions look good.
Any suggestions ?
Thanks,
JimBob
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 23 Dec 1998 11:25:18 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Newbie- Close error - Bad File Number
Message-Id: <39zp8e3jwx.fsf@ibnets.com>
>>>>> "j" == jimrsmith <jimrsmith@unn.unisys.com> writes:
j> I open the output file.
j> I set autoflush to true.
j> I select the output file.
j> I print to the output file.
j> (loop runs 4 times, 4 records should be written)
j> I close the file, and STDERR gets Close error...Bad File Number
j> output file has size 0 bytes.
j> permissions look good.
j> Any suggestions ?
you post code.
when will they ever learn? we debug perl code, not pseudo code.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Wed, 23 Dec 1998 08:48:10 -0800
From: Jerome O'Neil <jeromeo@atrieva.com>
Subject: Re: Newbie- Close error - Bad File Number
Message-Id: <36811ECA.43F7D40E@atrieva.com>
jimrsmith@unn.unisys.com wrote:
>
> I open the output file.
> I set autoflush to true.
> I select the output file.
> I print to the output file.
> (loop runs 4 times, 4 records should be written)
> I close the file, and STDERR gets Close error...Bad File Number
> output file has size 0 bytes.
> permissions look good.
> Any suggestions ?
> Thanks,
> JimBob
Clearly you have a syntax error on line 17.
Jerome "Abigail's Line" O'Neil
------------------------------
Date: Wed, 23 Dec 1998 11:27:42 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Newbie- Close error - Bad File Number
Message-Id: <e69r57.o9c.ln@magna.metronet.com>
Jerome O'Neil (jeromeo@atrieva.com) wrote:
: jimrsmith@unn.unisys.com wrote:
: >
: > I open the output file.
: > I set autoflush to true.
: > I select the output file.
: > I print to the output file.
: > (loop runs 4 times, 4 records should be written)
: > I close the file, and STDERR gets Close error...Bad File Number
: > output file has size 0 bytes.
: > permissions look good.
: > Any suggestions ?
: > Thanks,
: > JimBob
: Clearly you have a syntax error on line 17.
Although the line reported is the line where the error
*was noticed*.
The actual error may be on some line before the one cited.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 23 Dec 1998 11:19:27 -0600
From: Steve Dunlap <steved@neteffects.com>
Subject: Please help if you can!
Message-Id: <3681261F.2F931FB6@neteffects.com>
I'm looking for a WWW Programmer with Perl, Javascript, HTML, SQL, CGI,
and HTTP. If you are interested or know anyone that might be please
contact me. We pay generous referral bonuses.
Best regards,
Steve Dunlap
steved@neteffects.com
------------------------------
Date: Wed, 23 Dec 1998 09:25:51 -0600
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Please help me reading .csv textfiles
Message-Id: <36810B7F.6BE665B1@email.sps.mot.com>
Bart Lateur wrote:
>
> Martien Verbruggen wrote:
>
> >#!/usr/local/bin/perl5.00404 -w
> >use strict;
> >use Text::ParseWords;
> >
> >while (<DATA>)
> >{
> > chomp;
> > my @words = quotewords(',', 1, $_);
> >
> > print join(" : ", @words),"\n";
> >}
> >
> >__DATA__
> >"field1","field2 has "quotes" in it",field 3,"field 4"
> >
> >__OUTPUT__
> >"field1" : "field2 has "quotes" in it" : field 3 : "field 4"
>
> That doesn't seem right. What would you do with a '",' sequence?
what do you mean with the '",' sequence?
> The ordinary approach seems to be to double the quotes, so the output
> should be:
>
> "field1" : "field2 has ""quotes"" in it" : field 3 : "field 4"
double the quotes? why? looks even more confusing to me. BTW, not sure
what you mean by 'ordinary approach'.
-TK
------------------------------
Date: 23 Dec 1998 11:52:15 -0500
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Please help me reading .csv textfiles
Message-Id: <75r73v$csl$1@monet.op.net>
In article <367fa36d.0@news.new-era.net>, <scott@softbase.com> wrote:
>This is a true story:
>
> I have a nameless-to-protect-the-guilty contact manager
> which exports CSV files -- *WITH EMBEDDED NEWLINES* in
> the quote-delimited fields. Seriously, it dumps an entire
> memo field in-between two quotes, and comma separates it.
What I normally do about this is to pass each physical line to
Text::CSV and see if the result looks the way I expect. If CSV fails
to parse, or returns fewer than the expected number of fields, I
assume that the lines was split in the middle, append the following
line, and try again. Code is something like this:
LINE:
while (<>) {
chomp;
unless ($csv->parse($_)) {
if ($total_lines > $MAX_LINES) {
warn "Lines from $start_line--$. were too confusing; skipping\n";
next LINE;
}
# Diagnose broken line here if you want
$_ .= <>; # Line is incomplete; append following line
$total_lines++;
redo LINE; # and try again.
}
@fields = $csv->fields;
if (@fields > $EXPECTED_FIELDS) {
warn "Accumulated too much in $start_line-$.; skipping.\n";
next LINE;
} elsif (@fields < $EXPECTED_FIELDS) {
# Diagnose broken line here if you want
$_ .= <>; # Line is incomplete; append following line
$total_lines++;
redo LINE; # and try again.
}
# Line is good and has corrent number of fields
process_fields(@fields);
} continue {
$total_lines = 1;
$start_line = $. + 1;
}
This is not exactly what I use, and I have not tested this code, so beware.
------------------------------
Date: Wed, 23 Dec 1998 17:45:01 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Please help me reading .csv textfiles
Message-Id: <36822af5.681838@news.skynet.be>
Tk Soh wrote:
>> That doesn't seem right. What would you do with a '",' sequence?
>
>what do you mean with the '",' sequence?
Look ma, a "quote comma sequence", in my string.
If you simply surround strings with quotes and join them with a comma,
the above sequence will appear to have a field break in it.
>> The ordinary approach seems to be to double the quotes, so the output
>> should be:
>>
>> "field1" : "field2 has ""quotes"" in it" : field 3 : "field 4"
>
>double the quotes? why? looks even more confusing to me. BTW, not sure
>what you mean by 'ordinary approach'.
The custom, as done by other programs. I think Excel does it this way.
At least, the result, though less readable, is unambiguus.
See also the code in the reply by Paul Makepeace in another branch of
this thread.
Message-ID: <75qo48$22g$1@statler.server.colt.net>
Bart.
------------------------------
Date: 23 Dec 1998 17:37:31 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Regex question - removing HTML tags....
Message-Id: <75r9or$ht4$1@client3.news.psi.net>
Gilly (mingtian@hanmail.net) wrote on MCMXL September MCMXCIII in
<URL:news:3680e767.1347834@usenet.kornet21.net>:
++ :To show how the above utterly fails what would it do to the following?
++ :
++ :--sample.html---
++ :<!-- Start of Page -->
++ :<script>Some script stuff</script>
++ :<P>Lots and lots of HTML goes here....</P>
++ :...
++ :<!-- End of Page -->
++ :--sample.html---
++
++ s/<!--.*?-->//gs;
<!-- So, what about this? --
>
Abigail
------------------------------
Date: Wed, 23 Dec 1998 17:39:33 +0000
From: Steve Wells <wells@cedarnet.org>
Subject: SDBM_File (I'd like one FH to go...)
Message-Id: <36812AD5.D0F4CD1F@cedarnet.org>
I've gone through the DB_File man pages
and found Tom's description on Locking
Databases within it. The method does
not seem to work with SDBM_File though
and I'm wondering if someone has found
a method to achieve this.
TIA,
STEVE
------------------------------
Date: Wed, 23 Dec 1998 15:56:54 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: sizeof() function?
Message-Id: <36811259.173617@news.skynet.be>
Andrew M. Langmead wrote:
>>>There is a
>>>length() function, which is like C's strlen()
>
>>Not really. Perl strings may contain null bytes.
>
>That means that Perl's strings are different than C's strings, not
>that the meaning of the function is different. Both functions return
>the length of the string, for its language's definition of a string.
>
>Also since you decided to start the nit-picking, the word "like"
>implies "similar to", not "feature and deficit identical to".
Yo! Hold your horses!
The main differecne is that in Perl, it is safe to use length() on a
binary string (structure). I would never think of doing that in C.
That's why I stressed that difference.
Bart.
------------------------------
Date: 23 Dec 1998 17:47:46 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: sizeof() function?
Message-Id: <75rac2$ht4$3@client3.news.psi.net>
Sean Hussey (sean@youknowwhattoremove.weblabs.com) wrote on MCMXXXIX
September MCMXCIII in <URL:news:367FD096.A46DC62@youknowwhattoremove.weblabs.com>:
++ Hi everyone,
++
++ I must be going crazy here. I could have sworn there was a sizeof()
++ function (or something like it) in Perl. Am I just confusing it with C
++ and JavaScript? Is there something in Perl that will do something like
++ sizeof() in these other languages?
If you want to use it to find out how many elements there are in
an array, just use the array in scalar context.
@foo = (0) x 10;
$foo = @foo;
print $foo, "\n";
Abigail
------------------------------
Date: 23 Dec 1998 16:31:00 GMT
From: tcg3j@cobra.cs.virginia.edu (Timothy C. Gion)
Subject: trouble accessing arrays from C++
Message-Id: <75r5s4$aum$1@murdoch.acc.Virginia.EDU>
I embedded Perl in a C++ program. My program calls a Perl subroutine and
passes a hash table to it. The Perl subroutine fills the hash table with
keys to arrays that looks like this:
int
2D array
2D array
The first 2D array may be empty. When I try to access the empty array from
my C++ program, I get either a seg fault or a bus error depending on the
method I use. When I try to use av_pop(), I get the seg fault. When I try
to check whether I'm getting a valid array reference via calls to
av_fetch() and SvTYPE(SvRV()), I get a bus error. What's the right way to
check if the array contains data?
Public replies preferred. Thanks in advance.
Tim
------------------------------
Date: Wed, 23 Dec 1998 07:26:31 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Turning Variables into CAPS?
Message-Id: <72rq57.gba.ln@magna.metronet.com>
Kai (kait@vacheron.ch) wrote:
: >
: > Why do you want to transliterate '[' to '[' and ']' to ']'? :-)
: >
: Those caracters are not transliterated, they serve as delimiters for the
: ranges a-z and A-Z.
You missed the point there (was it Larry's point? hard to tell.
you should leave in the attribution when you quote someone).
They _are_ transliterated. That is how tr/// works in Perl, which
is unlike how it works in other implementations of tr///.
The docs (in perlop.pod) for tr/// even give an example of
using ranges: tr/A-J/0-9/
no square brackets required...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 23 Dec 1998 17:55:57 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Turning Variables into CAPS?
Message-Id: <75rard$ht4$6@client3.news.psi.net>
Rick Delaney (rick.delaney@home.com) wrote on MCMXL September MCMXCIII in
<URL:news:3680F5C5.11F57F6F@home.com>:
++ [posted & mailed]
++
++ Kai wrote:
++ >
++ > >
++ > > Why do you want to transliterate '[' to '[' and ']' to ']'? :-)
++ > >
++ >
++ > Those caracters are not transliterated, they serve as delimiters for
++ > the ranges a-z and A-Z.
++
++ No they don't, hence the smiley in Larry's post. They would be
++ delimiters of a character class in a regex, but tr doesn't use regexes.
Well, you could use them as delimiters, but /'s was already used
for that. If you want to use [] as delimiters, use:
tr [a-z] [A-Z];
Abigail
------------------------------
Date: Wed, 23 Dec 1998 08:28:20 -0800
From: Gennady Stupakov <stupakov@slac.stanford.edu>
Subject: webster-server perl script
Message-Id: <36811A23.6CD2566A@slac.stanford.edu>
I would like to run a perl script from my NT box that connects to a
webster
server with a Webster dictionary available on our site. Right now I can
do that
only from my unix account using an executable (found on the web) for
which I have a source in C.
I found a couple of perl scripts, webster.pl, on the internet dated
before 1994, that are supposed to establish connection to such a server,
but they are too unixish to run on NT
(they do not run under unix too for me, though). My attempts to
establish a connection
using Net::Telnet usually result in an error with a message:
problem connecting to "webster-server.stanford.edu", port 2627: Unknown
error at line...
Does anybody there have a more recent script that can run on NT?
Or can you give me a hint of
what kind of protocol I have to use for such a connection (I am not a
socket programmer,
but I am familiar with perl Net modules). Any help will be greatly
appreciated.
Gennady.
------------------------------
Date: 23 Dec 1998 09:35:04 -0800
From: Russ Allbery <rra@stanford.edu>
To: Gennady Stupakov <stupakov@slac.stanford.edu>
Subject: Re: webster-server perl script
Message-Id: <ylhfumrcc7.fsf@windlord.stanford.edu>
[ Posted and mailed. ]
Gennady Stupakov <stupakov@slac.stanford.edu> writes:
> I would like to run a perl script from my NT box that connects to a
> webster server with a Webster dictionary available on our site. Right
> now I can do that only from my unix account using an executable (found
> on the web) for which I have a source in C. I found a couple of perl
> scripts, webster.pl, on the internet dated before 1994, that are
> supposed to establish connection to such a server, but they are too
> unixish to run on NT (they do not run under unix too for me, though). My
> attempts to establish a connection using Net::Telnet usually result in
> an error with a message: problem connecting to
> "webster-server.stanford.edu", port 2627: Unknown error at line...
> Does anybody there have a more recent script that can run on NT? Or can
> you give me a hint of what kind of protocol I have to use for such a
> connection (I am not a socket programmer, but I am familiar with perl
> Net modules). Any help will be greatly appreciated.
The one you have from Khun Yee Fung (clipper@csd.uwo.ca)? If so, you
should be able to get it to work by tearing out the socket.ph stuff and
replacing it with use Socket and the modern socket connection code.
Something like:
use Socket;
my $iaddr = inet_aton ('webster-server.stanford.edu');
my $paddr = sockaddr_in ($port, $iaddr);
my $proto = getprotobyname ('tcp');
socket (SERVER, PF_INET, SOCK_STREAM, $proto);
connect (SERVER, $paddr);
instead of all the stuff from $sockaddr to the setting of $SIG (which you
still want), except don't use the above code verbatim; instead, check each
of those calls for errors and die if they fail.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: 23 Dec 1998 17:49:55 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: What's wrong with this code?
Message-Id: <75rag3$ht4$4@client3.news.psi.net>
WL (will@localads.net) wrote on MCMXXXIX September MCMXCIII in
<URL:news:75p1f8$vd5$2@news8.svr.pol.co.uk>:
++ Hi,
++
++ The following code worked fine, when I ran it under Telnet using "perl
++ stf.cgi":
++ _______________________________________________
++ require 'configs.cfg'; # System configuration file
++
++ require 'subs.pl'; # System required sub-routines
++
++ $SendEmail = "yes";
++ $EmailAddress = "will\@localads.net";
++ $Locie = "Localads.net";
++
++ if ($SendEmail eq "yes") {
++ # Open The Mail program, send notice of new AD submittal to Webmaster
++ open(MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
++ print MAIL "To: $EmailAddress\n";
++ print MAIL "From: $Locie\n";
++ print MAIL "Subject: Test Message\n\n";
++
++ }
++ close (MAIL);
++ _______________________________________________
++ Then, I added this bit of code afer the print MAIL Subject line:
++
++ print MAIL "$in{'City'}";
++
++ This takes the text City variable from the web page - but it didn't, or
++ rather it returned a server error :(( I use the post statement, - could
++ this have been the problem?
Do you run using -w?
Do you run using -T?
Do you use 'use strict;'?
Do you check the return values of all system calls?
What error message is there in the servers error log?
Are all the permissions set correctly?
Did you read the FAQs?
Abigail
------------------------------
Date: 23 Dec 1998 17:54:03 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Where can you get undump
Message-Id: <75ranr$ht4$5@client3.news.psi.net>
Gary W. Propp (gary.w.propp@cdc.com) wrote on MCMXXXIX September MCMXCIII
in <URL:news:75oaj2$h6c$1@cdshub.cdc.com>:
++ I would like to improve the performance of some perl programs. I understand
++ that the
++ dump function produces a image core dump. The documentation I have indicates
++ you
++ need a program undump that is not part of the Perl distribution. Where can
++ you get undump?
In the TeX distribution.
However, I've heard of anyone getting this to work. I also seriously
doubt this will improve performance.
Perhaps you need a better algorithm. If your program is so time critical
that after writing the absolute best algorithm, you still want to use
draconian measurements like use dump, you might consider hiring a team
of crack coders, buying the best compiler for your platform and write
it in C and/or assembler.
Abigail
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4487
**************************************