[11523] in Perl-Users-Digest
Perl-Users Digest, Issue: 5123 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 12 20:07:17 1999
Date: Fri, 12 Mar 99 17:00:19 -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 Fri, 12 Mar 1999 Volume: 8 Number: 5123
Today's topics:
Re: Are negative array indeces allowed? <emschwar@mail.uccs.edu>
automate electronic publishing <flanker@sonnet.ru>
Re: CGI Images <jamesht@idt.net>
Re: Deletion of a List Array Entry <jamesht@idt.net>
Re: Deletion of a List Array Entry (G.IM)
Re: Deletion of a List Array Entry <jglascoe@giss.nasa.gov>
Re: does perl discourage obfuscated code? (was Re: Perl <emschwar@mail.uccs.edu>
Re: Error Message Mystery <jamesht@idt.net>
Incorporating UPS shipping cost automatically <dimensions@dialaccess.com>
Re: Learn the truth - In Dear Recruiter we establish ex <emschwar@mail.uccs.edu>
Multiple Users Corrupting File <epatterson@dese.com>
newbie <kimbrough.gray@amd.com>
Re: newbie <jglascoe@giss.nasa.gov>
Perl acting different when run as CGI? <awallace@insweb.com>
Re: Perl acting different when run as CGI? <jglascoe@giss.nasa.gov>
Re: perl installation need help <jglascoe@giss.nasa.gov>
Re: perl interpreter for windows 95 ? <jamesht@idt.net>
Re: Regex $1 behavior <jamesht@idt.net>
Re: Regex $1 behavior <cassell@mail.cor.epa.gov>
Re: Regex $1 behavior <ebohlman@netcom.com>
Re: Regex $1 behavior (Erik Huelsmann)
Re: Regex $1 behavior <jglascoe@giss.nasa.gov>
Re: Shopping cart Problem of configuration of the cgi-s <jamesht@idt.net>
SSI query <fightace@gamestats.com>
suid problem <shenk@math.gatech.edu>
Re: The Meta-problem: helping others with Perl problems (Nicholas Carey)
Re: The Meta-problem: helping others with Perl problems <cassell@mail.cor.epa.gov>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 12 Mar 1999 17:14:36 -0700
From: Eric The Read <emschwar@mail.uccs.edu>
Subject: Re: Are negative array indeces allowed?
Message-Id: <xkfn21ikzyr.fsf@valdemar.col.hp.com>
John Chambers <john.chambers@gte.com> writes:
> (Perhaps it would also help the supplicant^Wposter to observe that
> negative subscripts work just fine with hashes; aka associative
> arrays.
Er, can hashes actually have negative subscripts? That same first
paragraph of perldata says they're indexed by string. Unless you mean
that you can use "-1" as an index to a hash, which is true enough, I
suppose.
> Of course, these beasties don't behave quite the same
> as plain vector-style arrays, and performance isn't as good. But
> in many programs, you can get the desired effect by simply using
> {} rather than [] around the array subscripts.)
except that foreach() over a hash will behave very differently than
foreach() over an array-- and I do the latter almost daily. In general,
it's better to let hashes be hashes, and arrays be arrays, and I'll get
to Scotland afore ye. :)
-=Eric
------------------------------
Date: Sat, 13 Mar 1999 03:01:06 +0300
From: "Michael Yevdokimov" <flanker@sonnet.ru>
Subject: automate electronic publishing
Message-Id: <7cc9p1$kq9$1@bison.rosnet.ru>
Hello!
Can anybody consult me? I heard that such publisher as Ziff-Davis (ZD.COM)
provide a way to publish author's articles on its sites using automation
scripts.. They can convert Word's text into HTML extracting pictures from
source, insert a link to sites' database and also to worldwide search
engines.
I was searching a Perl script to convert RTF files into HTML for a long
time.. But have not any result up to this time.... :-( Could you advice me
what to ask my authors what file format to use to translate it into HTML
later?
May be you have any Perl scripts to convert the most useful word processor's
file formats into HTML?
Thanks in advance.
--
Best wishes,
Michael Yevdokimov
Email: flanker@sonnet.ru
ICQ: 30874618
-------------------------------------------------
>> Developers Support Site <<
Web: http://developer.tsx.org
http://www.basicnet.sonnet.ru
-------------------------------------------------
------------------------------
Date: Fri, 12 Mar 1999 18:52:06 -0500
From: James Tolley <jamesht@idt.net>
To: Rajan Alexander <raj@nyct.net>
Subject: Re: CGI Images
Message-Id: <36E9A8A6.D8CEACB4@idt.net>
It's a piece of cake with the CGI module. Look at the documention, but
keep in mind that you've got to call binmode on the read and write
filehandles to store it without corrupting it:
use CGI;
$fh = param('file_upload');
binmode($fh); # <-- use binmode
open(NEW, "+>image.gif") or print "oops: $!" and exit;
binmode(NEW); # <-- use binmode
while(<$fh>) {
print NEW $_;
}
close(NEW);
Also, keep in mind the enctype for the html form.
hth,
James
Rajan Alexander wrote:
> I saw a CGI based database which allowed the upload of local images to
> the site. Does anyone know how this is accomplished or where I may
> obtain more information?
>
> --
> Rajan Alexander
------------------------------
Date: Fri, 12 Mar 1999 18:05:19 -0500
From: James Tolley <jamesht@idt.net>
To: "G.IM" <noone@home.com>
Subject: Re: Deletion of a List Array Entry
Message-Id: <36E99DAF.8DF462D6@idt.net>
> Is it possible to delete an entry of a list array? I know it is possible to
> delete an entry in an associative array through the use of its key and its
> corresponding value, but how about an @list?
There's no single command to do this, but you can do it this way:
@list = ('one','two','three');
# we want to delete the middle entry.
$index_to_delete = 1;
@lists[$index_to_delete..$#lists-1] = @lists[$index_to_delete+1..$#lists]
$lists[$#lists] = undef;
hth,
James
------------------------------
Date: Fri, 12 Mar 1999 23:09:38 GMT
From: noone@home.com (G.IM)
Subject: Re: Deletion of a List Array Entry
Message-Id: <S8hG2.17617$5e5.4092@news.rdc1.sdca.home.com>
In article <36E999EA.5EAB9725@docent.com>, Joel Bremson <joelb@docent.com> wrote:
>This is a multi-part message in MIME format.
>--------------B2A27844FA6CD67EDD690F81
>Content-Type: text/plain; charset=iso-8859-1
>Content-Transfer-Encoding: 8bit
>
>Use splice. For simply removing elements the syntax is:
>
>splice ARRAY, OFFSET (starting point in array), LENGTH ( how many to
>remove
>starting at the starting point)
>
>Example:
>
> #!/usr/bin/perl
>
> @a = ('h','i','k');
>
> splice @a, 1, 1;
>
> print "@a\n";
>
>OUTPUT: h k
>
>HTH,
>-Joel
>
Thank you very much! It worked perfectly!
------------------------------
Date: Fri, 12 Mar 1999 18:03:54 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: =?iso-8859-1?Q?G=AEIM?= <noone@home.com>
Subject: Re: Deletion of a List Array Entry
Message-Id: <36E99D5A.A233CB77@giss.nasa.gov>
[courtesy copy of post sent to cited author]
"G=AEIM" wrote:
> =
> Is it possible to delete an entry of a list array? I know it is possibl=
e to
> delete an entry in an associative array through the use of its key and =
its
> corresponding value, but how about an @list?
funny you should ask, I was just reading
perldoc -f splice
# delete entry at index "$n" from "@list"
splice @list, $n, 1;
# example
@list =3D (1 .. 5)
splice @list, 3, -1;
print "@list\n" # prints "1 2 3 5"
Jay Glascoe
-- =
"Just say 'Narf!'"
--Pinky
------------------------------
Date: 12 Mar 1999 17:59:08 -0700
From: Eric The Read <emschwar@mail.uccs.edu>
Subject: Re: does perl discourage obfuscated code? (was Re: Perl evangelism)
Message-Id: <xkfhfrqkxwj.fsf@valdemar.col.hp.com>
Mark <admin@asarian-host.org> writes:
> But I think there are two scales here that we should consider: "useless to
> powerful" vs. "terse and legible".
A scale that runs from "terse" to "legible" is worthless. Consider my
current favourite bit of perl (don't ask me why, it's just come up a lot
lately): foreach.
foreach(@array) {
print;
}
is a lot terser than
int i;
for(i=0; i < arraylen; i++) {
printf("%s", array[i]);
}
but it's also a lot more legible (to me).
> For instance, very powerful instructions tend to be more terse than
> easier ones.
I'd like to see some evidence for this that's not APL.
This would also depend a lot on what you mean by "powerful". I'm not
sure it has any inherent meaning, as applied to programming languages, so
I'd like to understand what you mean by it.
> Since Perl is extremely powerful, it can pack a multitude of operations
> into a single line.
That doesn't follow.
> Now, you can look at this from the "terse and legible" scale, and
> conclude that Perl promotes obfuscate coding.
Only if you believe the scale has any validity; I don't believe it does.
By the way, paragraphs are *really* useful for people trying to read what
you write.
> My point being still, that you cannot look at one very dense line of
> code and call it obfuscate just because your mind is being dazzled by
> the amount of things that happen in this one line: one is the result of
> the other.
I'm not sure I understand this sentence. Are you saying that calling
something obfuscated is the result of your mind being dazzled by the
amount of things happening in one line? If so, that would go a long way
towards explaining what you mean by "powerful" above.
But perl doesn't encourage this. Nor does it discourage it. It's simply
there.
> In fact, perl regexs are so powerful that to the
> newbie mind they will appear to be magical. But if you were to "unroll" such
> a powerful regex and rewrite it in C, your code would grow by an order of
> magnitude and would not necessarily be more clear.
More like several orders of magnitude.
I think my main point of disagreement is you seem to be saying perl is
confusing because you can put many things on a line, but that's okay,
because it's powerful. The problem is, you can do that in C, Java, C++,
heck, probably ANY language but Fortran and (from what I hear) python. I
don't think that it's a good model of complexity.
-=Eric
------------------------------
Date: Fri, 12 Mar 1999 18:18:24 -0500
From: James Tolley <jamesht@idt.net>
To: bmonti@my-dejanews.com
Subject: Re: Error Message Mystery
Message-Id: <36E9A0C0.E7075F90@idt.net>
> Anybody know what causes this error:
>
> "Out of memory! Attempt to free unreferenced scalar. "
I imagine that you have objects which contain references to one another.
When you're no longer interested in them they still stick around because
their ref-counts are not zero; even though you don't have a reference to
them, they reference each other, and so they're never garbage-collected.
There's mention of this in the pod of (I think) HTML::Element.
Does this sound like a likely explanation?
Let me know,
James
------------------------------
Date: Fri, 12 Mar 1999 17:45:37 -0600
From: "Dimensions" <dimensions@dialaccess.com>
Subject: Incorporating UPS shipping cost automatically
Message-Id: <9GhG2.3$R13.337@newsfeed.slurp.net>
Hi:
I am an aficionado perl programmer (I don't sell scripts, and I just write
program for fun).
I discovered that UPS is offering a way to calculate SHIPPING cost WITHIN a
script, and Id like to integrate this feature to my scripts (more is
avaliable at ups.com about this).
I have not been able to figure out how to make the thing work. I just do not
receive any data back. UPS does not provide help.
I dont know too much about communication parameters either!!
Help would be welcome!
Etal
dimensions@dialaccess.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++
Here is the example from UPS...
The following is an example of a CGI script to integrate basic UPS package
rating capabilities into your system. This request asks for rating a simple
request only sending the required information. If a more detailed package
rating request is needed simply add the preceding information into the
$workString.
NOTE: The approach used in the example below is to open a communication
socket, submit a datastream, and receive a datastream. The total charge can
then be extracted from the received string through further programming.
The example is written in PERL 5.000 and is specific to UPS internal systems
configurations. Any programming language can be used. Communication
parameters will need to be changed based on your system configuration.
Code:
$AF_INET = 2;
$SOCK_STREAM = 2;
$sockaddr = "S n a4 x8";
$port = 80;
$them = "www.ups.com";
$function = "GET"; #Type of HTTP
$workFile = "/using/services/rave/qcostcgi.cgi";
$versionInfo = "HTTP/1.0\n\n";
$workString = "?";
$workString .= "accept_UPS_license_agreement=yes";
$workString .= "&";
$workString .= "10_action=$upsAction";
$workString .= "&";
$workString .= "13_product=$upsProduct";
$workString .= "&";
$workString .= "15_origPostal=$OriginPostalCode";
$workString .= "&";
$workString .= "19_destPostal=$DestZipCode";
$workString .= "&";
$workString .= "23_weight=$PackageWeight";
$request = "$function $workFile$workString $versionInfo";
#
# Initialize communications to the server
#
if (!&InitCommunications()) # This is a function to establish a socket
connection
{
# send request to server
#
print S "$request\n";
#
# retrieve answer sent back from the server
#
$resultlist = '';
while (<S>)
{
$resultlist .=$_;
}
close(S);
}
#
# Initialize Inter-process communications
#
sub InitCommunications
{
$errmsg = "";
#
# get info for socket open
#
($name, $aliases,$proto) = getprotobyname('tcp');
($name, $aliases,$port) = getservbyport($port,'tcp') unless $port
=~/^\d+$/;
($tname, $aliases,$type, $len, $thisaddr) = gethostbyname($hostname);
($name, $aliases,$type, $len,$thataddr) = gethostbyname($them);
#
# pack information into structure for socket open
#
$this = pack($sockaddr, $AF_INET, 0, $thisaddr);
$that = pack($sockaddr, $AF_INET, $port, $thataddr);
#
# Create the socket filehandle
#
eval
{
alarm($connect_timeout);
if (socket(S, $AF_INET, $SOCK_STREAM, $proto) < 0)
{
$raveServer = 0;
return 0;
}
#
# disable buffering, flush after each write/print
#
select(S);
$| = 1;
select(STDOUT);
if (bind(S, $this) < 0)
{
$raveServer = 0;
return 0;
}
if (!connect(S, $that))
{
$raveServer = 0;
return 0;
}
alarm(0);
};
return $raveServer;
}
Receiving Rating Information:
Rating information is returned in newline terminated strings, with each
piece of information separated by a percent sign, as follows:
3%$product%$orig_postal%$orig_country%$dest_postal%$dest_country%$zone
%$weight%$productchrg%$accs_surcharge%$totalchrg%$time%$\n
Rating information for a single product, specified by $product.
$product UPS product code
$orig_postal Shipment origin postal code
$orig_country Shipment origin country code
$dest_postal Shipment destination postal code
$dest_country Shipment destination country code
$zone UPS zone identifier
$weight Package weight (empty if package is UPS Letter)
$productchrg Charge for base service without additional charges
$accs_surcharge Charge for accessories and surcharges
$totalchrg Total charge for shipping package
$time Commit time (-1 if no commit time, EOD if end-of-day commit)
4%$product%$orig_postal%$orig_country%$dest_postal%$dest_country%$zone
%$weight%$productchrg%$accs_surcharge%$totalchrg%$time%$\n
Rating information for all UPS products, starting with specified product.
Information as above for each UPS procuct rated.
5%$errmsg%$errorCode%\n or 5%$errmsg%\n
Error message if package could not be rated. No rating information follows.
$errmsg Error message
$errorCode Error code
6%$message%[followed by 3 or 4, as above]
Warning message if UPS product, specified by $product, might not be valid
for this particular shipment. Rating information follows immediately.
$message Warning message
Required Parameters
a) "accept_UPS_license_agreement=yes"
b) "10_action=3 or 4"
Specifies level of service detail:
3 Price a single product.
4 Shop entire UPS product range, starting with the selected product.
"13_product=UPS Product Code"
This parameter defines the type of UPS shipping. The following table lists
the UPS services with the UPS product code for this application.
Next Day Air Early AM = 1DM
Next Day Air = 1DA
Next Day Air Saver = 1DP
22nd Day Air A = 2DM
2nd Day Air = 2DA
3 Day Select = 3DS
Ground = GND
Canada Standard = STD
Worldwide Express = XPR
Worldwide Express Plus = XDM
Worldwide Expedited = XPD
c)"14_origCountry= Origin Country"
Specifies origin country (US for United States or PR for Puerto Rico).
d)"15_origPostal= Ship from Postal Code"
The five digit postal code for the shipment origin.
e)"19_destPostal= Ship to Postal Code "
The one to six alphanumeric-character postal code of the destination
country, if the destination country uses postal codes.
f)"22_destCountry= Ship to Country Code"
The country code of the shipment destination. For a complete list of country
codes, see Country Codes on page 30.
g) "23_weight= weight of package"
The weight of the package. If Shipment is a UPS letter, no weight is
needed.
h)"47_rate_chart=Regular Daily Pickup, On Call Air, One Time Pickup, Letter
Center, Customer Counter"
Rates vary depending on package origin and destination address.
i) "48_container=00, 01, 03, 21, 24, or 25"
00 Your Packaging
01 UPS Letter Envelope
UPS Tube
UPS Express Box
UPS Worldwide 25KG Box
UPS Worldwide 10KG Box
Container allows the type of shipping container to be specified.
j)"49_residential=1 or 0"
1 Residential
0 Commercial
This option allows shipment to be designated as a residential or commercial
delivery.
OTHER OPTIONS ARE AVAILABLE
------------------------------
Date: 12 Mar 1999 17:23:45 -0700
From: Eric The Read <emschwar@mail.uccs.edu>
Subject: Re: Learn the truth - In Dear Recruiter we establish exactly what a recruiter does.
Message-Id: <xkfk8wmkzji.fsf@valdemar.col.hp.com>
QualifiedConsultant <computer_consultant7@my-dejanews.com> writes:
> This is the first in a series of documents I will be writing to educate the
> computer consulting industry as a whole.
<snip>
And your perl question is...?
followups set to misc.test (please, folks, no more replies)
-=Eric
------------------------------
Date: Fri, 12 Mar 1999 18:45:15 -0600
From: "Eric Patterson" <epatterson@dese.com>
Subject: Multiple Users Corrupting File
Message-Id: <7ccca7$jjj$1@polo.advicom.net>
I've run into a problem that I can't figure out. I hope someone here
has an answer. I'm running a Perl bulletin board script that is accessible
from the internet. Anytime two internet users execute the script within
a small period of time files get corrupted. Specifically a file
is opened and written too by the first user. The same file is opened
by the second user before the first has finshed writing to the file. This
is causing loss of data.
Is there a way to combat this problem? Is there some way of restricting
access to file that is currently open? Or perhaps another way alltogether.
Any help would be greatly appreciated. I'm getting very tired of losing
data and repairing damaged files.
Eric Patterson
------------------------------
Date: 13 Mar 1999 00:07:29 GMT
From: "Kimbrough Gray" <kimbrough.gray@amd.com>
Subject: newbie
Message-Id: <01be6ce5$7c195c60$6bb1b5a3@tuffy>
I have a line
system ("more /etc/group group sysadmin")
I could save the output in a file. Instead, I want to save the output
in a variable called $var. Is this possible.
------------------------------
Date: Fri, 12 Mar 1999 19:44:35 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Kimbrough Gray <kimbrough.gray@amd.com>
Subject: Re: newbie
Message-Id: <36E9B4F3.F62E965A@giss.nasa.gov>
Kimbrough Gray wrote:
>
> I have a line
> system ("more /)
>
> I could save the output in a file. Instead, I want to save the output
> in a variable called $var. Is this possible.
open PIPE, "/bin/foo /usr/biz |" or die "can't open pipe: $!";
my $var = do { local $/ = undef; <PIPE>; };
close PIPE or die "pipe failed: $!";
err, maybe the "my $var ..." line is a bit too gratuitous ;^)
my @lines = <PIPE>;
my $var = join '', @lines;
Jay Glascoe
--
"That which does not kill me makes me stranger."
--Larry Wall
------------------------------
Date: Fri, 12 Mar 1999 14:52:02 -0800
From: Andy Wallace <awallace@insweb.com>
Subject: Perl acting different when run as CGI?
Message-Id: <36E99A92.CE98B874@insweb.com>
Hey there -
I have a pretty simple PERL CGI script that I am trying to get to
run at my ISP. It works just great in my home test environment (Linux,
Apache, Perl5), but fails strangely at my ISP. But, running from the
command line at the ISP, it works fine, just when run as a CGI program.
The script is below - basically, the @allborders array is empty when
this thing runs as a CGI program, so the output looks like
Content-type: text/html
<BODY BACKGROUND="../images/" LINK=#ff005f VLINK=#4915e0 ALINK=#ff0000>
instead of what it's supposed to. Does anyone have an explanation? Like I
said, it runs great from the command line at my ISP, just not as a CGI script.
Help!
thanks
andy
=========start of script==========
#!/usr/bin/perl5
#
# Get the list of filenames...
#
# opendir(THISDIR, "../images");
opendir(THISDIR, "/home/andyw/public_html/images");
@allborders = grep(/border/, readdir(THISDIR));
closedir(THISDIR);
#
# Get the random number to index into the array of filenames.
# initialize the random number generator first.
srand(time);
print "Content-type: text/html\n\n";
print "<BODY BACKGROUND=\"../images/$allborders[$WhichOne]\" LINK=#ff005f VLINK=
#4915e0 ALINK=#ff0000>\n\n";
=========end of script==========
--
Andy Wallace (650) 817-0230 (Internal:x2230)
awallace@i n s w e b .com (no spaces) http://www.insweb.com
Got SCROOM? http://www.scroom.com http://www.operasoftware.com
I worry that the person who thought up Muzak may be
thinking up something else." --Lily Tomlin
------------------------------
Date: Fri, 12 Mar 1999 19:27:24 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Andy Wallace <awallace@insweb.com>
Subject: Re: Perl acting different when run as CGI?
Message-Id: <36E9B0EC.C4C58EFF@giss.nasa.gov>
[courtesy copy of post sent to cited author]
Andy Wallace wrote:
>
> Hey there -
>
> The script is below - basically, the @allborders array is empty when
> this thing runs as a CGI program, so the output looks like
>
> Content-type: text/html
> <BODY BACKGROUND="../images/" LINK=#ff005f VLINK=#4915e0 ALINK=#ff0000>
>
> instead of what it's supposed to. Does anyone have an explanation? Like I
> said, it runs great from the command line at my ISP, just not as a CGI script.
<snip>
> # Get the list of filenames...
> #
> # opendir(THISDIR, "../images");
> opendir(THISDIR, "/home/andyw/public_html/images");
Check the return value of all system calls ("opendir" is
a system call). I suspect the browser, "nobody", doesn't
have read access to "/home/andyw/public_html/images".
opendir THISDIR, "/foo/bar" or die "can't open dir: $!";
> # Get the random number to index into the array of filenames.
> # initialize the random number generator first.
> srand(time);
> print "Content-type: text/html\n\n";
> print "<BODY BACKGROUND=\"../images/$allborders[$WhichOne]\" LINK=#ff005f VLINK=
> #4915e0 ALINK=#ff0000>\n\n";
make sure "$WhichOne" is defined (do you have the -w flag set?).
Finally, I shall now nit-pick your print statements ;^)
print qq{
<BODY BACKGROUND="../images/$allborders[$WhichOne]"
LINK=#ff005f VLINK=#4915e0 ALINK=#ff0000>
};
OR
print << "EOHTML";
<BODY BACKGROUND="../images/$allborders[$WhichOne]"
LINK=#ff005f
VLINK=#4915e0
ALINK=#ff0000>
EOHTML
;
Jay Glascoe
--
"Just say 'Narf!'"
--Pinky
------------------------------
Date: Fri, 12 Mar 1999 19:07:51 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: vliaw@aa-net.com
Subject: Re: perl installation need help
Message-Id: <36E9AC57.3D6F0EFD@giss.nasa.gov>
[courtesy copy of post sent to cited author]
vliaw@aa-net.com wrote:
>
> Hi,
hi.
> System : FreeBSD 3.1, newly installed with full source code and bin
> Version : Perl5.004_04 Steps : rm config.sh sh Configure (using defaults)
Maybe you should try a more recent Perl?
The latest [stable] Perl is 5.005_02
ftp://www.perl.com/pub/perl/CPAN/src/perl5.005_02.tar.gz
Jay Glascoe
--
"I have not passed through fire and death
to bandy crooked words with a serving man
until the lightning falls."
--Gandalf the White, (to Wormtongue)
------------------------------
Date: Fri, 12 Mar 1999 18:19:25 -0500
From: James Tolley <jamesht@idt.net>
To: Marcel de Haan <haantje@multiweb.nl>
Subject: Re: perl interpreter for windows 95 ?
Message-Id: <36E9A0FD.C8015C0@idt.net>
> does anyone know if a perl excuting engine exists for windows 95/nt ?
> i want to be able to test my perl scripts under this operating system.
See http://www.activestate.com
------------------------------
Date: Fri, 12 Mar 1999 17:59:18 -0500
From: James Tolley <jamesht@idt.net>
To: Jeff Lovell <jalovel@orl.ilstu.edu>
Subject: Re: Regex $1 behavior
Message-Id: <36E99C46.418D20BE@idt.net>
Jeff,
You can use $1 outside the regex operation, but you should use \1 within it:
#!/usr/bin/perl -w
3:$address = "127.0.0.1";
4:$address =~ s/((\d+\.)*)/\1/; # NOT '$1'
5:print $address, "\n"; # eq "127.0.0.1" <- I don't want this.
6:print $1, "\n"; # eq "127.0.0." <- I want this.
use \1 on line 4 and $1 on line 6.
That should do it.
hth,
James
------------------------------
Date: Fri, 12 Mar 1999 15:15:13 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
To: Jeff Lovell <jalovel@orl.ilstu.edu>
Subject: Re: Regex $1 behavior
Message-Id: <36E9A001.CD2D89B2@mail.cor.epa.gov>
[courtesy cc: sent to author]
Jeff Lovell wrote:
> Ok, I'm sure I must be missing something fairly obvious here, but I can't
> seem to find it. When I use the $1 backreference in s/// it doesn't seem
> to work. Here is the code I am working with:
>
> #!/usr/bin/perl -w
Good! Always use -w here. I also always stick 'use strict;' as my 2nd line,
in part because I'm a lousy typist. So.. if you say
use strict;
you would also want to say
my $address = "127.0.0.1";
instead of your next line.
> $address = "127.0.0.1";
> $address =~ s/((\d+\.)*)/$1/;
Okay. I love regexes. I always forget *something*. A couple things.
You don't want to make a backreference from the inner parens, so use
the new, ultra-cool (?:regex) discussed in perlre. And your '*' is probably
eating everything up in there, so add another \d+ to deal with that:
$address =~ s/((?:\d+\.)*)\d+/$1/;
> print $address, "\n"; # eq "127.0.0.1" <- I don't want this.
> print $1, "\n"; # eq "127.0.0." <- I want this.
You asked for it, you got it, [car brand name here]...
> Any help would be appreciated. If you could CC via mail I would be greatful
> too. My news server is on the fritz here, and posts are lost left and right.
Done and done. My news server has exploded once already this year, so I
sympathize.
--
David
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Fri, 12 Mar 1999 23:12:08 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Regex $1 behavior
Message-Id: <ebohlmanF8I8G8.AIs@netcom.com>
James Tolley <jamesht@idt.net> wrote:
: Jeff,
: You can use $1 outside the regex operation, but you should use \1 within it:
: #!/usr/bin/perl -w
: 3:$address = "127.0.0.1";
: 4:$address =~ s/((\d+\.)*)/\1/; # NOT '$1'
The second part of s/// is *not* a regex. It's treated as a
double-quoted string. Using '\<number>' is deprecated in this context.
The problem is that the regex says "match some text, and then replace the
matched text with a copy of itself. This doesn't change the original
text at all.
------------------------------
Date: 12 Mar 1999 23:16:53 GMT
From: erikh@nospam.com (Erik Huelsmann)
Subject: Re: Regex $1 behavior
Message-Id: <wzgSQd1pdrdd-pn2-jNKh8oqo1vdg@localhost>
[I don't normally do this, but also cc-mailed]
On Fri, 12 Mar 1999 21:21:34, jalovel@orl.ilstu.edu (Jeff Lovell)
wrote:
> Ok, I'm sure I must be missing something fairly obvious here, but I can't
> seem to find it. When I use the $1 backreference in s/// it doesn't seem
> to work. Here is the code I am working with:
>
> #!/usr/bin/perl -w
>
> $address =3D "127.0.0.1";
> $address =3D~ s/((\d+\.)*)/$1/;
> print $address, "\n"; # eq "127.0.0.1" <- I don't want this.
Which is quite logical, when you think about it: You tell perl to
match some string within another string and then replace the matched
string with itself. Seems logical that the string *per definition*
remains the same.
In other words, if you want the 1 to be "replaced away" you will have
to make sure it is in your match pattern, but outside of the brackets,
so that it is not included in $1.
> print $1, "\n"; # eq "127.0.0." <- I want this.
This means that your program is exactly doing what it should and the
pattern matched is indeed found. The s/// does what it should do, but
on the wrong part of the string, by your description.
HTH.
bye, Erik
--
ICQ# 23883733 | Want to link your Psion to OS/2? Check out
http://www.oprit.rug.nl/hulsmann/PSI.html
Using Sibyl for OS/2 RAD development (http://www.ndrh.de/~speed/)
[Don't mail posts, I will see them here just fine]
------------------------------
Date: Fri, 12 Mar 1999 18:44:41 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: James Tolley <jamesht@idt.net>
Subject: Re: Regex $1 behavior
Message-Id: <36E9A6E9.BD79266D@giss.nasa.gov>
James Tolley wrote:
>
> Jeff,
>
> You can use $1 outside the regex operation, but you should use \1 within it:
no. Actually, perl prefers you to use "$1" over "\1".
> :$address = "127.0.0.1";
> :$address =~ s/((\d+\.)*)/\1/; # NOT '$1'
this doesn't do what Jeff wants either.
> :print $address, "\n"; # eq "127.0.0.1" <- I don't want this.
> :print $1, "\n"; # eq "127.0.0." <- I want this.
# replace address with the first matching, longest
# series of these things: "\d+\."
$address =~ s/.*?((\d+\.)*).*/$1/;
^^^ ^^
these bits throws away the unwanted stuff.
# better style:
$address =~ /((:?\d+\.)*)/;
$address = $1;
Jay Glascoe
--
The software required "Windows 95 or better",
so I installed Linux.
------------------------------
Date: Fri, 12 Mar 1999 17:56:48 -0500
From: James Tolley <jamesht@idt.net>
To: Julen Ludovic <shogun@tvs2net.ch>
Subject: Re: Shopping cart Problem of configuration of the cgi-script... Could you help me..
Message-Id: <36E99BAF.E45A6080@idt.net>
You might have more luck in comp.infosystems.www.authoring.cgi, as this is a
perl newsgroup.
------------------------------
Date: Fri, 12 Mar 1999 23:52:37 GMT
From: "Mike Cardosa" <fightace@gamestats.com>
Subject: SSI query
Message-Id: <01be6cda$d35cd7a0$0264a8c0@mike9729>
This is a multi-part message in MIME format.
------=_NextPart_000_01BE6CB0.EA86CFA0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Is it possible to use a query string while calling an SSI? I need this to
work!
EX:
<!--#exec cgi="scriptname.cgi?this=should&work=nicely"-->
I know that when you call the html file that calls the ssi, you can use the
query string there, but that is not efficient in my case. For example, I
don't want to rename all of the links to index.html to
index.html?variable=something.
ANY help would be greatly appreciated!
-Mike
------=_NextPart_000_01BE6CB0.EA86CFA0
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<html><head></head><BODY bgcolor=3D"#FFFFFF"><p><font size=3D2 =
color=3D"#000000" face=3D"Arial">Is it possible to use a query string =
while calling an SSI? I need this =
to<br>work!<br><br>EX:<br><!--#exec =
cgi=3D"scriptname.cgi?this=3Dshould&work=3Dnicely"--><br=
><br>I know that when you call the html file that calls the ssi, you can =
use the<br>query string there, but that is not efficient in my case. =
For example, I<br>don't want to rename all of the links to =
index.html to<br>index.html?variable=3Dsomething.<br><br>ANY help would =
be greatly appreciated!<br>-Mike<br><br></p>
</font></body></html>
------=_NextPart_000_01BE6CB0.EA86CFA0--
------------------------------
Date: Fri, 12 Mar 1999 23:36:44 GMT
From: ron shenk <shenk@math.gatech.edu>
Subject: suid problem
Message-Id: <36E9A586.BC13F929@math.gatech.edu>
Simple 3 line suid perl script on two machines A and B (sun
workstations,
solaris 2.5.1).
#!/usr/local/bin/perl
$ppphost = "jaguar";
die "start-ppp must be run from $ppphost\n" if ( `hostname` ne
"$ppphost\n" );
On machine A runs without complaint; on machine B gives the following
Insecure $ENV{PATH} while running setuid at /dev/fd/3 line 3.
The PATH can even be just /usr/bin.
------------------------------
Date: Sat, 13 Mar 1999 00:08:30 GMT
From: ncarey@harlequin.com (Nicholas Carey)
Subject: Re: The Meta-problem: helping others with Perl problems
Message-Id: <36e9a098.163084032@cnn.cam.harlequin.co.uk>
On Fri, 12 Mar 1999 14:56:49 -0800, "David L. Cassell"
<cassell@mail.cor.epa.gov> wrote:
> To all those who answer Perl questions:
>
> Today I received an e-mail from someone to whose post I had
> replied. It was a thank-you, rather than a flame. But..
> in the middle of the post, the user mentioned that he was
> able to find on the Net the answer, based on what I had said,
> since he _did_not_know_what_perldoc_was_and_couldn't_find_it_.
>
> Uh-oh. What good does it do to tell people 'perldoc perlfaq4'
> if they have no idea what we are talking about? How do we help
> people who are on systems other than their own, and are stymied
> by the.. umm.. how can I put this.. the lack of Perlishness of
> their ISP or their network administrator?
There comes a point at which you have to give up on people. This
sounds something like the canard where the TV repairman is called to
fixed a television set and it works out that the TV is unplugged.
If they can't be troubled to read at least *some* documentation, an
overview perhaps, before hollering for help, be it a Perl book, a FAQ,
perldoc, a man page or a web page (am I missing any other sources of
info on Perl?), you can't do much for them. A certain amount of
foreknowledge *has* to be assumed on the part of the user.
Most ISP's (the ones I'm familiar with anyway) have shell access --
how else are you going to write/test your perl script if you don't
have perl on your own machine? If you have access to perl, you should
have access to the documentation. How hard is it to say something
clever like 'man perl' or 'man perldoc'? I just tried using a couple
of web searches -- a search for 'perl' and <function-name> almost
always comes up with appropriate or near-appropriate documentation out
on the web. It's not as if the information is readily available. The
problem is that there are a lot of people who have no interest in
doing the research themselves. FWIW, though, I did notice that at
least with perl 5.004_04, there's no mention of perldoc in the perl
man pages -- the perl man page perhaps should point to perldoc right
upfront where it can be easily found be people that might not read the
entire thing.
[Confession: I had a problem similiar to the unplugged TV set happen
with my dishwasher. The detergent compartment was failing to open and
the detergent wasn't dissolving. It worked out, $US 50 later :-(, that
the bottom basket had been removed to clean the strainer and put back
in backwards, which reduced the clearance between the basket and the
detergent compartment, which prevented the lid of the detergent
compartment. In my defense, I didn't know that the basket had been
removed, and, once the door is closed, you can't see what's going on
inside the dishwasher]
> gnat sends out e-mails to people (who haven't munged up their
> addresses for fear of canned meat byproducts) using a Perl bot.
> (Or so I have assumed.) Is it feasible to launch a copy of his
> e-mail to each new poster? If so, this could be sent from some
> set point of origin which could then be put in everyone's
> killfiles so the rest of us wouldn't see such a message. Or
> is this total overkill? His mini-FAQ may or may not help to
> an extensive degree. But it is of course impossible to evaluate
> the extent of such help based only on those people who post to
> c.l.p.m. Basic sampling theory on the problem of non-response.
>
> So. Am I wasting my time thinking about this? Am I wasting
> *your* time posting this? Am I wishing I had a snappy joke for
> the last part of this triple?
Comp.lang.perl.moderated has a policy like that -- you must
acknowledge receipt/reading of the FAQ before the moderation 'bot
allows you to post. This policy, as I remember, engendered no small
amount of heated flames^wdiscussion during the news.group discussion
preceding the creation of clpmod. See dejanews if you're interested. I
can't imagine it flying in this group.
------------------------------
Date: Fri, 12 Mar 1999 16:48:23 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: The Meta-problem: helping others with Perl problems
Message-Id: <36E9B5D7.26760365@mail.cor.epa.gov>
Nicholas Carey wrote:
> [lots of good stuff snipped]
> Comp.lang.perl.moderated has a policy like that -- you must
> acknowledge receipt/reading of the FAQ before the moderation 'bot
> allows you to post. This policy, as I remember, engendered no small
> amount of heated flames^wdiscussion during the news.group discussion
> preceding the creation of clpmod. See dejanews if you're interested. I
> can't imagine it flying in this group.
Oh no, I didn't want to go that far. I just suggested an intermediate
stage. An autobot *posted* reply to new posters, which could be
killfiled by everyone else. Of course it would be a hit on the
signal to noise ratio...
--
David
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
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 5123
**************************************