[16576] in Perl-Users-Digest
Perl-Users Digest, Issue: 3988 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 11 14:10:33 2000
Date: Fri, 11 Aug 2000 11:10:23 -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: <966017422-v9-i3988@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 11 Aug 2000 Volume: 9 Number: 3988
Today's topics:
Re: Perl code for a newbie!! <aqumsieh@hyperchip.com>
Re: Perl code for a newbie!! ()
Re: Perl code for a newbie!! (Keith Calvert Ivey)
Re: Perl code for a newbie!! <craig.pugsley@mimesweeper.com>
Re: Perl code for a newbie!! <craig.pugsley@mimesweeper.com>
Re: Perl code for a newbie!! <craig.pugsley@mimesweeper.com>
Re: Perl code for a newbie!! <lr@hpl.hp.com>
Re: Perl code for a newbie!! <lr@hpl.hp.com>
Re: Perl DBI question (Nobody)
Re: perl program running with cgi extension <drawbridge@home.com>
Re: perl program running with cgi extension <lr@hpl.hp.com>
Re: perl program running with cgi extension <flavell@mail.cern.ch>
Re: Perl/CGI suitable for this? <smcintyre@xrce.SPAM.xerox.com>
Re: Pipe on WinNT (Robert Hallgren)
Re: Pipe on WinNT <pgunreben@lucent.com>
Posting to an secure server <ravi@[remove_this]indigostar.com>
PPM Parser.pm errors <rgparker@west.net>
Re: problems with ^= toddbe@my-deja.com
Re: problems with ^= <lr@hpl.hp.com>
Regex help <Jodyman@usa.net>
Re: s/// and symbolic references (Keith Calvert Ivey)
Re: s/// and symbolic references <daniel@blackomega.com>
Re: s/// and symbolic references nobull@mail.com
Re: Sending back HTTP info before script ends...... nobull@mail.com
Re: Tutorial for Perl/Sybase (Nobody)
Re: Uploading Images <lr@hpl.hp.com>
Re: warning/var weirdness (or is it?) <bkennedy99@home.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 11 Aug 2000 15:17:22 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Perl code for a newbie!!
Message-Id: <7aaeejddz0.fsf@merlin.hyperchip.com>
"Christopher M. Jones" <christopher_j@uswest.net> writes:
> delete ($file[$linenum]);
Perhaps you should have a look at the perlfunc entry for delete(). It is
used to delete a key-value pair from a hash.
I think what you intended to use is splice():
splice @file, $linenum - 1, 1;
--Ala
------------------------------
Date: Fri, 11 Aug 2000 15:19:40 GMT
From: sjs@yorku.ca ()
Subject: Re: Perl code for a newbie!!
Message-Id: <slrn8p86bd.ck.sjs@john.sympatico.ca>
Craig Pugsley <craig.pugsley@mimesweeper.com> wrote:
>"TANSTAAFL"? - please, explain...
http://www.tuxedo.org/~esr/jargon/html/entry/TANSTAAFL.html
HTH.
Steve
------------------------------
Date: Fri, 11 Aug 2000 14:24:01 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Perl code for a newbie!!
Message-Id: <39970bb5.43096018@news.newsguy.com>
"Craig Pugsley" <craig.pugsley@mimesweeper.com> wrote:
>I keep getting this error message:
>
>delete argument is not a HASH element or slice at linecutter.pl line 17.
And? Do you have a suggestion for how the error message could
be made any clearer? Presumably it's referring to this line:
>> > > delete ($file[$linenum]);
And (surprise!) it's complaining that the argument to delete
there is not a hash element or slice (it's an array element).
Read the documentation for the delete() function. Then try the
splice() function.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Fri, 11 Aug 2000 16:21:57 +0100
From: "Craig Pugsley" <craig.pugsley@mimesweeper.com>
Subject: Re: Perl code for a newbie!!
Message-Id: <sSUk5.1188$iE4.12780@news2-win.server.ntlworld.com>
Thanks mate. I'll give it a go as soon as I can sort my Perl installation...
As a point of interest, what does the extra "-w" mean?
CraigP
"Rajeev" <rajeev@faircomm.net> wrote in message
news:8n13gu$4ip$1@news.icl.se...
> Hi Craig
>
> I tried the following code and it works. I added -w to the first line, $
was
> missing in ARGV[0] in the third line and line 15 now has $linenum -1.
>
> Cheers
>
> Rajeev
> ++++++++
> #!/usr/bin/perl -w
>
> $basedir = $ARGV[0];
> $searchpattern = "*.txt";
> $linenum = $ARGV[1];
>
> while(<$basedir/$searchpattern>)
> {
> $filename = $_;
> unless ( open (FILE, "<$filename") )
> { print "Unable to open '$filename' for reading.\n"; next; }
> @file = <FILE>;
> close (FILE);
>
> delete ($file[$linenum -1]);
>
> unless ( open (FILE, ">$filename") )
> { print "Unable to open '$filename' for writing.\n"; next; }
> print FILE @file;
> close (FILE);
> }
>
>
>
------------------------------
Date: Fri, 11 Aug 2000 16:39:26 +0100
From: "Craig Pugsley" <craig.pugsley@mimesweeper.com>
Subject: Re: Perl code for a newbie!!
Message-Id: <R6Vk5.1221$iE4.13297@news2-win.server.ntlworld.com>
Erm... Thanks (I think) for that advice. I'm a newbie - don't forget.
"Keith Calvert Ivey" <kcivey@cpcug.org> wrote in message
news:39970bb5.43096018@news.newsguy.com...
> "Craig Pugsley" <craig.pugsley@mimesweeper.com> wrote:
>
> >I keep getting this error message:
> >
> >delete argument is not a HASH element or slice at linecutter.pl line 17.
>
> And? Do you have a suggestion for how the error message could
> be made any clearer? Presumably it's referring to this line:
>
> >> > > delete ($file[$linenum]);
>
> And (surprise!) it's complaining that the argument to delete
> there is not a hash element or slice (it's an array element).
> Read the documentation for the delete() function. Then try the
> splice() function.
>
> --
> Keith C. Ivey <kcivey@cpcug.org>
> Washington, DC
------------------------------
Date: Fri, 11 Aug 2000 16:40:38 +0100
From: "Craig Pugsley" <craig.pugsley@mimesweeper.com>
Subject: Re: Perl code for a newbie!!
Message-Id: <Z7Vk5.1228$iE4.12709@news2-win.server.ntlworld.com>
I feel so enlightened it hurts...
<sjs@yorku.ca> wrote in message news:slrn8p86bd.ck.sjs@john.sympatico.ca...
> Craig Pugsley <craig.pugsley@mimesweeper.com> wrote:
> >"TANSTAAFL"? - please, explain...
>
> http://www.tuxedo.org/~esr/jargon/html/entry/TANSTAAFL.html
>
> HTH.
>
> Steve
------------------------------
Date: Fri, 11 Aug 2000 10:20:37 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl code for a newbie!!
Message-Id: <MPG.13fdd5c09a654fd198ac69@nntp.hpl.hp.com>
In article <ZIRk5.17$WW5.35151@news.uswest.net> on Fri, 11 Aug 2000
04:47:11 -0700, Christopher M. Jones <christopher_j@uswest.net> says...
...
> #!/usr/bin/perl
No '-w', no 'use strict;' => no quality.
> $basedir = ARGV[0];
> $searchpattern = "*.txt";
> $linenum = $ARGV[1];
>
> while(<$basedir/$searchpattern>)
> {
> $filename = $_;
> unless ( open (FILE, "<$filename") )
> { print "Unable to open '$filename' for reading.\n"; next; }
Diagnostic should include $!.
> @file = <FILE>;
> close (FILE);
>
> delete ($file[$linenum]);
It took half a dozen subsequent posts before this blatant error was
revealed.
Evidently you don't believe in testing code before you post it.
> unless ( open (FILE, ">$filename") )
> { print "Unable to open '$filename' for writing.\n"; next; }
Diagnostic should include $!.
> print FILE @file;
> close (FILE);
> }
>
> print "Done.\n";
Though your intentions were pure, the best way to respond to this FAQ is
simply:
perlfaq5: "How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the beginning of a
file?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 11 Aug 2000 10:36:41 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl code for a newbie!!
Message-Id: <MPG.13fdd9884d8a7bcb98ac6a@nntp.hpl.hp.com>
[In the future, please use the Subject to describe your problem, not
yourself. Using 'newbie' in the Subject has already caused innumerable
newsreaders to filter you away.]
In article <7gQk5.570$iE4.5307@news2-win.server.ntlworld.com> on Fri, 11
Aug 2000 11:08:03 +0100, Craig Pugsley <craig.pugsley@mimesweeper.com>
says...
> I'm looking for some Perl code to chop the first line off a large collection
> of separate text files. The code should be give the path of a directory
> containing the (large number of) files, it should then strip the nth line
> out of the file, and replace the original file. It shouldn't copy the file
> (if this can be helped!), as I'm going to be dealing with in excess of 600
> separate text files!!!
>
> Thanks to all who can help.
I already pointed to perlfaq5: "How do I change one line in a
file/delete a line in a file/insert a line in the middle of a
file/append to the beginning of a file?"
Tucked in there is a way to do this job with a single command:
perl -i -ne 'print unless $. == 5' /home/user/directory/*
which strips the fifth line out of every file in the directory.
(Replace the single-quotes by double-quotes for Windows/DOS.)
As warned in the FAQ (but not in the Perl documentation!),
Note that -i may require a suffix on some non-Unix systems;
see the platform-specific documentation that came with your port.
In which case you'll have to delete all the backup files.
And you don't even have to pay me a million dollars. TISATAAFL.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 11 Aug 2000 17:30:48 GMT
From: nobody@contract.East.Sun.COM (Nobody)
Subject: Re: Perl DBI question
Message-Id: <8n1d88$2q$1@eastnews1.east.sun.com>
In article <39907A51.A908C270@attglobal.net>,
Drew Simonis <care227@attglobal.net> wrote:
>kj0 wrote:
>>
>> I'm learning about the Perl DBI (and about SQL, etc.) as I comb
>> through some legacy code at my company. My understanding is that the
>> rationale behind the Perl DBI design is to make database access as
>> uniform as possible, independent of the type (Oracle, Sybase, etc.) of
>> database being accessed.
>
>That is correct, concerning DBI, but you also have to use a DBD
>portion, which allows connections to specific databases. This is
>where syntax may shift and sway, and that is what we see in your
>example.
Yep. DBI lets you use the same methods/functions to access your
database, like 'prepare', 'execute', and 'fetchrow_hashref'. The
actual SQL code and connect strings may be different for different
databases, since they don't all support the same features. The DBD
part is specific to each database, since it interfaces directly to
that particular database's libraries. This way, all you have to do
is change the DBD "underwear" for whatever db you're using :-) (sorry,
it's Friday :-) and minimize the number of changes in your db code.
Anita
------------------------------
Date: Fri, 11 Aug 2000 15:28:31 GMT
From: DM <drawbridge@home.com>
Subject: Re: perl program running with cgi extension
Message-Id: <39941BF9.8BE94762@home.com>
Yes, I also had this problem. If you are creating HTML, you need to
print:
print "HTTP/1.0 200 OK\n";
print "Content-type: text/html\n\n";
Without the HTTP header, Netscape doesn't know to send the output to the
browser window, and instead you get the HTML file to save on your
system. The above lines will fix your problem. It is not a Netscape
setting.
___James
"John P. Crisci" wrote:
>
> I have perl installed on a windows nt4.0. - using ActiveState. The cgi
> program extension is associated with perl. The program works fine from
> the command line and Internet Explorer. When I try to run it using
> Netscape 4.x I get the pop-up window that asks if I want to save the
> file to disk or run it from where it is at.
>
> Does anyone know what settings Netscape might need to run this perl app?
>
> TIA
>
> John
------------------------------
Date: Fri, 11 Aug 2000 09:31:24 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: perl program running with cgi extension
Message-Id: <MPG.13fdca3aec805d4798ac64@nntp.hpl.hp.com>
[Rearranged in order of logical flow -- question before answer.]
In article <39941BF9.8BE94762@home.com> on Fri, 11 Aug 2000 15:28:31
GMT, DM <drawbridge@home.com> says...
> "John P. Crisci" wrote:
> >
> > I have perl installed on a windows nt4.0. - using ActiveState. The cgi
> > program extension is associated with perl. The program works fine from
> > the command line and Internet Explorer. When I try to run it using
> > Netscape 4.x I get the pop-up window that asks if I want to save the
> > file to disk or run it from where it is at.
> >
> > Does anyone know what settings Netscape might need to run this perl app?
>
> Yes, I also had this problem. If you are creating HTML, you need to
> print:
>
> print "HTTP/1.0 200 OK\n";
> print "Content-type: text/html\n\n";
>
> Without the HTTP header, Netscape doesn't know to send the output to the
> browser window, and instead you get the HTML file to save on your
> system. The above lines will fix your problem. It is not a Netscape
> setting.
The question is off-topic for this newsgroup, with deals with Perl, not
with CGI.
The answer is incorrect. Unless the program is running with 'non-parsed
headers', you should not send the HTTP status line shown above.
The Perl answer is this:
#!perl -w
use strict;
use CGI ':standard';
print header;
...
If that doesn't work, there is a server configuration problem, which is
equally off-topic here.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 11 Aug 2000 19:28:59 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: perl program running with cgi extension
Message-Id: <Pine.GHP.4.21.0008111915570.14931-100000@hpplus03.cern.ch>
On Fri, 11 Aug 2000, DM demonstrated the usual properties of those who
post upside-down to usenet. It's off-topic for this group too, though
there are some details that fall into Perl's bailliewick...
> Yes, I also had this problem. If you are creating HTML, you need to
> print:
>
> print "HTTP/1.0 200 OK\n";
Please review the CGI specification before offering further answers of
this nature. This CGI response is invalid from normal (parsed-header)
scripts. Non-parsed-header (nph) scripts on the other hand are
required to return a complete and accurate HTTP response, for which
your HTTP part would be correct: but then, "\n" is in general wrong,
since the HTTP specification mandates precisely a carriage return
followed by a linefeed, whereas "\n" stands for Perl's platform-
dependent newline representation, which isn't necessarily the same
thing. It just so happens that if you are working in text mode on MS
Windows, the result will come out right, but there are better (i.e
more portable) ways to work - specifically, using CGI.pm instead of
trying to hand-knit it.
------------------------------
Date: Fri, 11 Aug 2000 18:00:36 +0100
From: "Dr Stuart McIntyre" <smcintyre@xrce.SPAM.xerox.com>
Subject: Re: Perl/CGI suitable for this?
Message-Id: <966013237.21753.0.nnrp-12.d4f05889@news.demon.co.uk>
Thanks for your reply.
"jason" <elephant@squirrelgroup.com> wrote in message
news:MPG.13fe6e5b416dcb029896a1@localhost...
> correct me if I'm wrong .. but the Java part of things is essentially
> irrelevant to this Perl question .. because you're essentially asking
>
> "
> can a Perl program be called via an SSL encrypted HTTP request over CGI
> and retrieve a text file from the local filesystem and return the
> contents of that text file back to the client over the SSL encrypted
> HTTP socket
> "
>
> to which the answer is yes .. this is trivial
>
> if any part of that is incorrect - specifically the "from the local
> filesystem" ...
I meant an arbitrary (external) url.
I've been looking in cpan, and there's lots of stuff there along the same
line as I'm looking.
As people have said it's possible , I've just picked up a book on CGI and
Perl,
that has lots more on the same topic.
Thanks,
Stuart
------------------------------
Date: Fri, 11 Aug 2000 15:08:29 GMT
From: sandhall@swipnet.se (Robert Hallgren)
Subject: Re: Pipe on WinNT
Message-Id: <slrn8p8481.rv.sandhall@poetry.lipogram>
On Fri, 11 Aug 2000 13:34:15 +0200,
Peter Gunreben <pgunreben@lucent.com> wrote:
> I'm currently trying to port some perl scripts to WinNT
> (ActivePerl5.09). The mechanism to catch a pipe worked
> well under UNIX, but it seems that it doesn't work under
> WinNT. Does anyone know how to overcome this issue.
Win32::Pipe perhaps?
<URL: http://www.activestate.com/Products/ActivePerl/docs
/site/lib/Win32/Pipe.html >
Robert
--
Robert Hallgren <sandhall@swipnet.se>
PGP: http://www.lipogram.com/pgpkey.asc
5F1E 95C2 F0D8 25A3 D1BE 0F16 D426 34BD 166A 566C
------------------------------
Date: Fri, 11 Aug 2000 18:28:21 +0200
From: Peter Gunreben <pgunreben@lucent.com>
Subject: Re: Pipe on WinNT
Message-Id: <399429A5.3811238A@lucent.com>
> You should check the return of that close, it's where problems during
> the pipe are reported.
>
> perldoc -f close
I've detected a really funny thing:
After the open command, the error message ($!) is
set to "No such file or directory" but the return
code of the open is nonzero.
The return code of the close command is 1
as expected.
... seems to be an implementation problem ...
Thanks,
Peter
------------------------------
Date: Fri, 11 Aug 2000 17:25:30 GMT
From: "Ravi" <ravi@[remove_this]indigostar.com>
Subject: Posting to an secure server
Message-Id: <eGWk5.52015$07.1611254@news1.rdc1.on.wave.home.com>
I'm trying to post some information to a secure webserver (https://)
I've been able to accomplish this task when the server is unsecure, but I'm
having problems with SSL. In the header I receive back from the secure
server after trying to post some content, the following line is included:
Client-SSL-Warning: Peer certificate not verified
and the server didn't except my post. Do I have to encrypt my information
before sending? I think that maybe the Crypt::SSLeay module has something
to do with the solution, but I'm not sure what. Here's the code I used to
make the post:
my $request_url = 'https://www.somesite.com/cgi-bin/script.pl?';
my $request_ua = new LWP::UserAgent;
my $request_object = new HTTP::Request("POST", "$request_url");
$request_object->content_type("application/x-www-form-urlencoded");
$request_object->content('field1=value1&field2=value2');
my $request_response = $request_ua->request($request_object);
#gets the contents of the response
my $request_content = $request4_response->as_string;
#prints response
print $request_content;
------------------------------
Date: Fri, 11 Aug 2000 16:27:18 GMT
From: Randall Parker <rgparker@west.net>
Subject: PPM Parser.pm errors
Message-Id: <MPG.13fdca4e411f45ef9898c5@news.onlynews.com>
On NT4 SP6a I'm running Active State Perl 5.6.0.616 (ie the latest) and
am getting PPM errors.
When trying to install DBI I get an unclosed token error.
When trying to install libnet I get a no element found error.
Anyone have any suggestions for what to do about this?
Here's the MS DOS Command Prompt session:
Microsoft(R) Windows NT(TM)
(C) Copyright 1985-1996 Microsoft Corp.
C:\>set PPM_DAT=j:\prg\perl\site\lib
C:\>ppm
PPM interactive shell (2.0) - type 'help' for available commands.
PPM> install DBI
Install package 'DBI?' (y/N): y
Retrieving package 'DBI'...
unclosed token at line 18, column 34, byte 1336 at
J:/prg/Perl/site/lib/SOAP/Parser.pm line 73
C:\>ppm install libnet
Retrieving package 'libnet'...
no element found at line 30, column 27, byte 2175 at
J:/prg/Perl/site/lib/SOAP/Parser.pm line 73
C:\>
------------------------------
Date: Fri, 11 Aug 2000 16:22:59 GMT
From: toddbe@my-deja.com
Subject: Re: problems with ^=
Message-Id: <8n198s$pmq$1@nnrp1.deja.com>
The hp does return IOK. Does any one have an ide on how to make the
code work on 32 bit linux?
REFCNT = 1
FLAGS = (IOK,pIOK)
IV = 9804392444
SV = IV(0x800000010002eec0) at 0x8000000100045500
REFCNT = 1
FLAGS = (IOK,pIOK)
IV = 15433492645
SV = IV(0x800000010002eed0) at 0x8000000100049d20
REFCNT = 1
FLAGS = (IOK,pIOK,IsUV)
UV = 0
9804392444,15433492645,0
In article <3992FD4F.D2599CF7@ipac.caltech.edu>,
tim@ipac.caltech.edu wrote:
> toddbe@my-deja.com wrote:
> >
> > I'm running this bit of code on an HPUX 10.20 system and a linux
system
> > and get very different resaults. On the HP $h1 get the correct
value on
> > the linux box $h1 becomes 0. REFCNT = 1
> >
> > Is ^= not working under linux?
> >
> > $h0 += 9804392444;
> > $h1 += 15433492645;
> > $h2 += 2607314627;
> > $h3 += 859226588;
> > $h4 += 4989140090;
> >
> > $h1 ^= $h0; #$h1 goes to 0 on linux
> > $h2 ^= $h0;
> > $h3 ^= $h0;
> > $h4 ^= $h0;
>
> I don't really know what's going on on your HP box, but I suspect that
despite
> its 32 bitness, it's able to handle those large numbers as integers,
while Linux
> must treat them as floats. Use Devel::Peek on $h1 on the HP and see if
the "IOK"
> flag turns up. If so that means it can be treated as an integer. On my
Linux
> box, I get "NOK", meaning its numeric, but no IOK. See here:
>
> % perl -MDevel::Peek -wl \
> -e '$h0 = int(9804392444); $h1 = int(15433492645); $x=$h0^$h0;'
\
> -e 'Dump($h0); Dump($h1); Dump($x); print "$h0,$h1,$x"'
> SV = PVNV(0x80eb1e0) at 0x80ff294
> REFCNT = 1
> FLAGS = (IOK,NOK,pIOK,pNOK,IsUV)
> UV = 4294967295
> NV = 9804392444
> PV = 0
> SV = PVNV(0x80eb1f8) at 0x80ff1f8
> REFCNT = 1
> FLAGS = (NOK,pNOK)
> IV = 0
> NV = 15433492645
> PV = 0
> SV = IV(0x80f607c) at 0x810283c
> REFCNT = 1
> FLAGS = (IOK,pIOK,IsUV)
> UV = 0
> 9804392444,15433492645,0
>
> Why $h0 integerizes as 2^32-1 and $h1 as 0, I don't know. What happens
on HPUX?
>
> --
>
> -- Tim Conrow tim@ipac.caltech.edu 626-395-8435
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 11 Aug 2000 09:47:26 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: problems with ^=
Message-Id: <MPG.13fdcdf9ba1c52af98ac66@nntp.hpl.hp.com>
In article <8n0qk2$8gs$1@lublin.zrz.tu-berlin.de> on 11 Aug 2000
12:12:50 -0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> says...
> <nobull@mail.com> wrote in comp.lang.perl.misc:
> >toddbe@my-deja.com writes:
...
> >Bitwise operators force floating point numbers into integers.
>
> Yes, but I have often wondered[1] what this means in a case like 1E123,
> that is, a float that represents an integer number too big for the
> native integer format.
Presumably the perl C program casts or assigns the double to an integer.
The ANSI/ISO C Standard says this (3.2.1.3):
When a value of floating type is converted to integral type,
the fractional part is discarded. If the value of the integral
part cannot be represented by the integral type, the behavior
is undefined.
So in theory the result could be Global Thermonuclear War. But in
practice, one would get whatever the hardware decided to do.
> [1] Well, obviously I haven't wondered often enough to go and check.
Neither have I. Especially as the result is undefined.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 11 Aug 2000 11:51:42 -0400
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Regex help
Message-Id: <8n17bt$e5e$1@plonk.apk.net>
Hello,
I'm looking for some help on a regex to parse the sample data
below. There are always 2 spaces after the name or a cr and #.
I would like to eliminate all data between the name and phone number. I
want to keep the cr after the phone number but I don't want cr's in between
names and numbers.
The data exists in $listing. I've tried:
(each regex is done in this order)
$listing =~ s/\n\#/ /g; # Remove all cr & tabs
$listing =~ s/\s+\d+ \w+.*(\d\d\d\s\d\d\d-\d\d\d\d)/:$1/g; #any num of
spaces followed by any number of numbers and any words to area code and
phone number and replace with :phone number
$listing=~ s/\#+//g; # remove all #'s
It doesn't work on all lines but does work on most.
TIA
Jody
#-------------------- Sample Data ------------------------
A Affordable Septic Service
#PO Box 1130 Wilsonville 503 682-1929
A Better Spa Service Canby 503 263-7727
A To Z Rental Centers
#3362 Silverton Rd NE Salem 503 370-9303
#995 Commercial SE Salem 503 585-7782
Alluis Todd Excavation Inc
#Silverton 503 873-4347
Allstate Insurance Companies
#Sales Offices
##Woodburn
###1585-M N Pacific Hwy Woodburn 503 982-6619
###612 Glatt Cir Woodburn 503 981-9507
###983 Oregon Way Woodburn 503 981-3201
------------------------------
Date: Fri, 11 Aug 2000 14:38:55 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: s/// and symbolic references
Message-Id: <39990d37.43482263@news.newsguy.com>
"Daniel Foster" <daniel@blackomega.com> wrote:
>while (<$element_filehandle>) { #previously opened correctly
> my $testvar = 'test';
> s/(\$)(\w+)/$$2/g;
> print;
> print " $testvar";
>}
>
>Running this over a line in the text file like 'Testvar holds
>$testvar' produces the string 'Testvar holds 143572 test', with the
>143572 (I assume the memory address $2 is in) changing every time it's
>called (going up by 10) and the word 'test' being printed out by the
>second print.
You're missing the fact that my() variables don't have symbol
table entries, so symbolic references won't work. See perlfaq4,
"How can I expand variables in text strings?"
In addition, the $$2 isn't doing what you think. The number is
actually your process number ($$) with a 2 after it. For some
reason, although $$s in a double-quoted string is interpreted as
${$s}, $$2 is interpreted as ${$}2.
If you'd been using strict and -w (as frequently recommended on
this group), they would have given you a clue about what was
going on.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Fri, 11 Aug 2000 16:59:25 +0100
From: "Daniel Foster" <daniel@blackomega.com>
Subject: Re: s/// and symbolic references
Message-Id: <8n17sg$a98$1@newsg3.svr.pol.co.uk>
> You're missing the fact that my() variables don't have symbol
> table entries, so symbolic references won't work. See perlfaq4,
> "How can I expand variables in text strings?"
Thanks, read it, used it, loved it.
> In addition, the $$2 isn't doing what you think. The number is
> actually your process number ($$) with a 2 after it. For some
> reason, although $$s in a double-quoted string is interpreted as
> ${$s}, $$2 is interpreted as ${$}2.
Mad. I decided to go the way of the FAQ and do it all with a hash. I
now have the regex
s/\$(\w+)/$$dataref{$1}/g;
so why doesn't the $$ in that get interpreted as the process number?
> If you'd been using strict and -w (as frequently recommended on
> this group), they would have given you a clue about what was
> going on.
Fair point, and to be honest I thought they were already being used.
Mea culpa. This brings up an interesting point though. The code I
wrote is residing in a package, so there's no shebang line to put
the -w on. Does it inherit it from the script 'use'ing the package?
---
If Bill Gates had a nickel for every time Windows crashed...
..oh wait, he does.
Daniel Foster - daniel@blackomega.com
------------------------------
Date: 11 Aug 2000 17:28:15 +0100
From: nobull@mail.com
Subject: Re: s/// and symbolic references
Message-Id: <u9k8dnvk2o.fsf@wcl-l.bham.ac.uk>
"Daniel Foster" <daniel@blackomega.com> writes:
> s/(\$)(\w+)/$$2/g;
Please, always run your code with warnings enabled and look up the
meanings of the warnings _before_ posting to Usenet.
Use of "$$<digit>" to mean "${$}<digit>" is deprecated
(D) Perl versions before 5.004 misinterpreted any type
marker followed by "$" and a digit. For example,
"$$0" was incorrectly taken to mean "${$}0" instead of
"${$0}". This bug is (mostly) fixed in Perl 5.004.
However, the developers of Perl 5.004 could not fix
this bug completely, because at least two widely-used
modules depend on the old meaning of "$$0" in a
string. So Perl 5.004 still interprets "$$<digit>" in
the old (broken) way inside strings; but it generates
this message as a warning. And in Perl 5.005, this
special treatment will cease.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 11 Aug 2000 17:32:42 +0100
From: nobull@mail.com
Subject: Re: Sending back HTTP info before script ends......
Message-Id: <u9itt7vjv9.fsf@wcl-l.bham.ac.uk>
"Nullspace():" <nullspace@hotmail.com> writes:
> Can anyone point me in the right direction with regards to sending back my
> HTTP information before my script ends. Right now,(I believe) my header info
> does get returned to my browser until after my script is complete.
This probably means that either the HTTP client or the HTTP server is
pre HTTP/1.1. In HTTP/1.0 the length of the message body is in the
message headers. Clearly this prevents the headers being generated
until the body is complete.
> I want to send back the page, wait for 30 seconds, then perform a CHMOD on a
> file on the server. Any help would be appreciated.
Fork off and die.
(Oh, and close(STDOUT) too).
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 11 Aug 2000 16:48:00 GMT
From: nobody@contract.East.Sun.COM (Nobody)
Subject: Re: Tutorial for Perl/Sybase
Message-Id: <8n1ao0$s35$1@eastnews1.east.sun.com>
In article <39904288.C01863B3@dasburo.de>,
Alexander Knack <ak@dasburo.de> wrote:
>> Does anyone can suggest any tutorial/example for Perl/Sybase?
>> I'm going to write a simply web access database that use
>> CGI/Perl + Sybase.
>>
>> Thanks for your kindly help.
>
>a very good way to start is with:
>http://www.mbay.net/~mpeppler/
>
Check out the DBI FAQ and documentation (available via perl.com and CPAN).
Anita
>--
>+--------------------------------------------------------------------+
>| Alexander Knack ........Entropie erfordert keine Wartung .........|
>| dasburo.de ..................................................|
>+--------------------------------------------------------------------+
------------------------------
Date: Fri, 11 Aug 2000 10:05:17 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Uploading Images
Message-Id: <MPG.13fdd2245cfd53da98ac68@nntp.hpl.hp.com>
In article <8n0kav$nmu$1@supernews.com> on Fri, 11 Aug 2000 11:26:08
+0100, Stuart Moore <stumo@bigfoot.com> says...
> <centelec@my-deja.com> wrote in message news:8mv4sc$7uc$1@nnrp1.deja.com...
...
> > use CGI;
> > open (OUTFILE, ">$basedir$fileName") || die "Can't open photo
> > file!\n";
A 'good' diagnostic will include $!, which gives the reason for the
failure.
> > print "$basedir/$fileName<br>";
> > while (my $bytesread = read($file, my $buffer, 1024)) {
$bytesread is not used.
> > print OUTFILE $buffer;
Indentation would clarify the intentions of code.
> > }
> >
> > My server is using Windows NT.
>
> This is the key - you need to do
>
> binmode OUTFILE;
>
> before you start writing to it - otherwise it treats it as a text file, and
> because windows and unix handle new line characters differently, it'd
> convert from one to the other and mess up the file.
One needs to binmode() the input file also, though the chance of an
error is about 1/256 the chance of an error in the output file.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 11 Aug 2000 15:09:52 GMT
From: "Ben Kennedy" <bkennedy99@home.com>
Subject: Re: warning/var weirdness (or is it?)
Message-Id: <4HUk5.93621$A%3.1285424@news1.rdc2.pa.home.com>
"jason" <elephant@squirrelgroup.com> wrote in message
news:MPG.13fdd36f6a6b2b7c989692@localhost...
>
> that's a good guess .. but I still see it as a bug .. something like -
> in order to resolve the ambiguity imposed by the '[' Perl does the wrong
> thing with the '{}'s which results in them being evaluated in symbolic
> deref circumstances
I agree that the behavior is inconsistent - but seems to me that the first
case of ${a} interpreting to the lexical $a is more of a bug. If you insert
${'a'}, it will act as a symbolic reference, which seems more consistant.
As for strict complaining about vars, this seem like a strict bug, based on
the fact that strct sees ${a}[ as version of @a, while the perl interpreter
itself never assumes its an array at all.
--Ben Kennedy
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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 someone isn'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 3988
**************************************