[17944] in Perl-Users-Digest
Perl-Users Digest, Issue: 104 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 20 03:05:38 2001
Date: Sat, 20 Jan 2001 00:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979977912-v10-i104@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 20 Jan 2001 Volume: 10 Number: 104
Today's topics:
Re: Associative Array of Arrays (Tad McClellan)
Re: Associative Array of Arrays (Martien Verbruggen)
Re: Associative Array of Arrays (Martien Verbruggen)
Re: Associative Array of Arrays <rick.delaney@home.com>
Re: Associative Array of Arrays (Martien Verbruggen)
Re: Associative Array of Arrays <uri@sysarch.com>
Can't get ActiveState's GUI Perl Debugger to work on Wi psu22377@odin.pdx.edu
Counting elements in an array (foreach) <me@jp1.co.uk>
Re: Counting elements in an array (foreach) <monty@primenet.com>
Database connection pool with Perl Object Environment? <carfield@my-deja.com>
Re: FAQ 9.10: How do I redirect to another page? (Chris Fedde)
Re: FAQ 9.15: How do I decode a CGI form? <nospam@nospam.com>
GD.pm/ImageMagick - Any thing better? <smullett@omeninc.com>
help me (fetching pages from net) <bidash@cisco.com>
Re: how to send a big file pipeing to sendmail (Cameron Laird)
Re: overload not autogenerating as expected (Ilya Zakharevich)
Re: Perl - Bytecode, Compile to C, Perl2EXE (Tad McClellan)
Re: Perl - Bytecode, Compile to C, Perl2EXE jgore@home.com
Re: Perl - Bytecode, Compile to C, Perl2EXE jgore@home.com
Re: Perl - Bytecode, Compile to C, Perl2EXE <nospam-abuse@[127.0.0.1]>
Re: Perl Style Guide - uncuddled elses <nospam@nospam.com>
Re: PWS - perl (ATTN: cwrites) <>
Spawning Parallel Processes arkconfused@hotmail.com
Re: Spawning Parallel Processes (Tad McClellan)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 20 Jan 2001 02:47:56 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Associative Array of Arrays
Message-Id: <slrn96hns3.8jq.tadmc@tadmc26.august.net>
Srdjan Sobajic <srdjans@digitalpersona.com> wrote:
>
>I am trying to create an associative array where a particular key would
>reference an array.
Nobody calls them "associative array" anymore. If you learned
that from a book, then it is either really old, or really poor.
They are called "hashes" nowadays.
You are playing fast and loose with technical terms which will
be confusing, so let me recast your statement:
I am trying to create a hash with array references as the hash values
>Something like:
>
>$a{$b}[$c] = $d;
>
>What I would like to do is sort on the keys of %a (the $b's above),
I assume you can already do that part?
>find the length of the array stored at $a{$b}.
$length_of_the_array = @{$a{$b}};
>Using the foreach syntax below doesn't seem to work, and neither will
>scalar($a{$b}) or $#a{$b}.
The general rule paraphrased from:
perldoc perlreftut
is:
Where you would normally put the "name" of an array, instead
put a block returning a reference to an array.
$length_of_the_array = @array; # normal
$length_of_the_array = @{ }; # replace with block...
$length_of_the_array = @{ $a{$b} }; # ... that returns an array ref
>If anybody has any ideas (I've searched through the articles on deja and my
>newsserver)
You seem to have missed the best possible resource for all Perl questions!
Namely, the standard docs that are shipped with the perl distribution:
perldoc perlreftut
perldoc perlref
perldoc perllol
perldoc perldsc
>open(CAPTURE, @ARGV[0]) || die "Cannot open file!";
^
^
You should enable warnings (and then fix your code so that
it does not make any warning messages).
You should give the name of the file in the diagnostic message.
You should include the $! special variable in the diagnostic message.
open(CAPTURE, $ARGV[0]) || die "Cannot open '$ARGV[0]' $!";
>while(<CAPTURE>) {
> chop;
^^^^
*Another* outdated-five-year ago term (or is it six years now?).
Uh oh. You seem to have learned from one of the many bad Perl books :-(
Beware of what it tells you.
chomp; # remove line endings in perl 5
> @line = split(';');
Pattern matches should _look like_ pattern matches:
@line = split( /;/ );
> for($i=0; $i<scalar(@nodes); $i++) {
> $curnet{@line[0]}[$i] = @nodes[$i];
^ ^
^ ^ yet more warnings...
> }
># This Doesn't Work! (probably obviously)
>foreach (sort keys(%curnet)) {
> print($_, "\n");
> foreach $el ( [@$] curnet{$_}) {
foreach my $el ( @name ) { # normal
foreach my $el ( @{ } ) { # replace with block...
foreach my $el ( @{ curnet{$_} } ) { # ... returning a reference
> print($curnet{$_}[$el]," ");
print "$el ";
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 20 Jan 2001 13:45:31 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Associative Array of Arrays
Message-Id: <slrn96huub.bgr.mgjv@martien.heliotrope.home>
On Fri, 19 Jan 2001 16:39:32 -0800,
Srdjan Sobajic <srdjans@digitalpersona.com> wrote:
You should use the -w flag to Perl if you need to be compatible with
5.005_03. Otherwise you should use the warnings pragma. In either case,
you should use the strict pragma:
use warnings;
use strict;
Both of these can help tremendously when debugging a program. Many
people here will not even bother to check your submitted code unless it
runs under these, because a lack of these means that you have not asked
Perl to help you find your problems. Instead, you are asking people to
do what Perl could do for you.
I'll comment anyway on some things.
> open(CAPTURE, @ARGV[0]) || die "Cannot open file!";
warnings would have been enormously helpful to you. It would have
pointed out that you should refer to an element of an array with
$ARGV[0] and NOT @ARGV[0]. The latter is an array slice. Often that will
work out to be the same, but sometimes it won't. You won't know what hit
you unless you understand the difference.
You are checking the return value of open(). That's good. But to help
yourself, you should include the $! variable in the error message, as
well as the file name:
open(CAPTURE, $ARGV[0]) or die "Can't open '$ARGV[0]': $!";
I also tend to use 'or' for flow control, and limit the use of || to
logical expressions, but that's more a style thing.
A forward reference to scope %curnet should go here:
my %curnet;
> while(<CAPTURE>) {
> chop;
Don't use chop if you mean to use chomp. You intend to remove the
newline from the end of that variable (or whatever $/ is set to), not
just simply the last character. There's a difference. Read the
documentation on chop and chomp in the perlfunc manual page.
> @line = split(';');
A regular expression should _look_ like one. Otherwise, some day, you
will run into the situation where something that looks like a string
acts like a RE, and your code just doesn't reflect that. Soemthing like
that can be a real time waster. The first argument to split is a RE:
my @line = split /;/;
I would also pick a more meaningful name for that array.
my @fields = split /;/;
> @nodes = split(' ', @line[1]);
Again: An array element is $line[1].
And here you have such a special case. if the first argument to split is
the literal string ' ', split splits on any amount of whitespace, and
will not give you initial empty fields. If that's what you want, and you
knew what you were doing:
my @nodes = split ' ', $line[1];
If you mean to split on a single space only, and retain leading empty
fields:
my @nodes = split / /, $line[1];
More information in the perlfunc documentaiton, under split.
> for($i=0; $i<scalar(@nodes); $i++) {
> $curnet{@line[0]}[$i] = @nodes[$i];
> }
What are you trying to do here? I think you meant to create a hash
(%curnet) that contains array references to an array with the nodes?
If you take my advice, and you lexically scope, with my, the @nodes
array to this block:
$curnet{$line[0]} = \@nodes;
otherwise you will have to make copies:
$curnet{$line[0]} = [@nodes];
Of course, you don't really need the temporary @nodes:
$curnet{$fields[0]} = [split ' ', $fields[1]];
There is no need for any looping.
> }
> # This Doesn't Work! (probably obviously)
When you say "Doesn't work" we expect you to state HOW it doesn't work.
Errors? Unexpected output? Daemons flying out of your nose? You have to
specify what you expect, and what actually happens. Then we know what
you're looking for. Now, with all the other errors and oddities, we have
to guess.
> foreach (sort keys(%curnet)) {
> print($_, "\n");
print "$_\n";
> foreach $el ( [@$] curnet{$_}) {
Where did you come up with this syntax? Did you mean
foreach my $el (@{$curnet{$_}})
{
The perlref documentation goes into the syntax for referencing and
dereferencing variables quite extensively. I suggest you read it.
> print($curnet{$_}[$el]," ");
> }
> print("\n");
That whole loop is more or less equivalent to
print "@{$curnet{$_}}\n"
And you can actually contract all those print statements into one:
foreach (sort keys %curnet)
{
print "$_: @{$curnet{$_}}\n";
}
And since that last bit is one statement only, you can write it as
print "$_: @{$curnet{$_}}\n" for sort keys %curnet;
Summarising, the program running under strict and warnings would look
something like:
#!/usr/local/bin/perl -w
use strict;
my %curnet;
open(CAPTURE, $ARGV[0]) or die "Cannot open $ARGV[0]: $!";
while(<CAPTURE>) {
chomp;
my @fields = split /;/;
$curnet{$fields[0]} = [split ' ', $fields[1]];
}
close CAPTURE;
print "$_: @{$curnet{$_}}\n" for sort keys %curnet;
I tend to explicitly close file handles I explicitly open as soon as I
don't need them anymore. Not necessary, but a good thing once you start
expanding your program. It prevents surprises.
You could probably learn one or two things from reading the
documentation already mentioned, as well as perldsc and perllol.
Martien
--
Martien Verbruggen |
Interactive Media Division | Can't say that it is, 'cause it
Commercial Dynamics Pty. Ltd. | ain't.
NSW, Australia |
------------------------------
Date: Sat, 20 Jan 2001 13:50:21 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Associative Array of Arrays
Message-Id: <slrn96hv7d.bgr.mgjv@martien.heliotrope.home>
On Fri, 19 Jan 2001 20:46:52 -0500,
James Richardson <time4tea@monmouth.com> wrote:
[Good comments, just some additional information on split. You might
know this, but your post doesn't make it clear enough to prevent
misunderstandings]
> "Srdjan Sobajic" <srdjans@digitalpersona.com> wrote in message
> news:94amo5$1j8o$1@nntp1.ba.best.com...
>
>> @line = split(';');
>
> Split with a string is almost never what you want. Use a regular expression.
Of course, split with a string is never what happens. The first argument
to split is a regular expression (exceptions for some special ones, see
the doucmentation). Even if you format it as a string, it still is a
regex.
> my ( $key, $rest ) = split (/\;/);
No need to escape the semicolon. It's not special.
>> @nodes = split(' ', @line[1]);
>> for($i=0; $i<scalar(@nodes); $i++) {
>> $curnet{@line[0]}[$i] = @nodes[$i];
>> }
>
> $curnet{$key} = [ split(/ /,$rest) ];
This is one of the exceptions for split. The result of a split with / /
or ' ' as its first argument is different. It's explicitly mentioned in
the documentation for anyone who wants to know.
Martien
--
Martien Verbruggen |
Interactive Media Division | Freudian slip: when you say one thing
Commercial Dynamics Pty. Ltd. | but mean your mother.
NSW, Australia |
------------------------------
Date: Sat, 20 Jan 2001 03:23:30 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Associative Array of Arrays
Message-Id: <3A690896.FBDF7C8@home.com>
James Richardson wrote:
>
> "Srdjan Sobajic" <srdjans@digitalpersona.com> wrote in message
> news:94amo5$1j8o$1@nntp1.ba.best.com...
> > open(CAPTURE, @ARGV[0]) || die "Cannot open file!";
> open ( CAPTURE, $filename ) || die "Can't open $filename $!\n";
>
> I actually prefer FileHandles over FILEHANDLES (see perldoc FileHandle )....
Why?
> > @line = split(';');
>
> Split with a string is almost never what you want. Use a regular expression.
>
> my ( $key, $rest ) = split (/\;/);
He is using a regular expression; there is no such thing as "split with
a string". However, you are right that you should quote the pattern
with delimiters that make it look like a pattern, if only to prevent
this common misconception. Spurious backslashes add nothing, however.
> > @nodes = split(' ', @line[1]);
> > for($i=0; $i<scalar(@nodes); $i++) {
> > $curnet{@line[0]}[$i] = @nodes[$i];
> > }
>
> $curnet{$key} = [ split(/ /,$rest) ];
split / / is not the same as split ' '.
perldoc -f split
> or replacing that last line
>
> my $ref = $curnet{$key};
> print join(" ", @$ref),"\n";
or with
print "@$ref\n";
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Sat, 20 Jan 2001 15:00:51 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Associative Array of Arrays
Message-Id: <slrn96i3bj.bgr.mgjv@martien.heliotrope.home>
On Sat, 20 Jan 2001 02:47:56 GMT,
Tad McClellan <tadmc@augustmail.com> wrote:
\begin[typo]{correction}
> foreach my $el ( @{ curnet{$_} } ) { # ... returning a reference
^
$
\end{correction}
Martien
--
Martien Verbruggen |
Interactive Media Division | Never hire a poor lawyer. Never buy
Commercial Dynamics Pty. Ltd. | from a rich salesperson.
NSW, Australia |
------------------------------
Date: Sat, 20 Jan 2001 05:09:21 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Associative Array of Arrays
Message-Id: <x7elxyyflu.fsf@home.sysarch.com>
>>>>> "JR" == James Richardson <time4tea@monmouth.com> writes:
JR> use strict;
JR> my %curnet;
JR> my $filename = shift;
JR> die "No args Usage is blahblah\n" unless defined($filename);
JR> open ( CAPTURE, $filename ) || die "Can't open $filename $!\n";
JR> I actually prefer FileHandles over FILEHANDLES (see perldoc FileHandle )....
don't use FileHandle as it is deprecated. all it does is load IO::File
anyway.
>>
>> while(<CAPTURE>) {
>> chop;
JR> Use chomp in preference to chop. Its nicer to your input.
then tell him why. it is safer as it only removes $/ (usually \n) if it
is found at the end of the line.
>> @line = split(';');
JR> Split with a string is almost never what you want. Use a regular
JR> expression.
it is a regular expression. split always uses regexes. it is better to
use // to demark it as a regex for us hyoomans.
JR> my ( $key, $rest ) = split (/\;/);
and no need to escape ;. it is not special in regexes.
JR> print join(" ", @{$curnet{$key}}),"\n";
JR> my $ref = $curnet{$key};
JR> print join(" ", @$ref),"\n";
simple interpolation of an array will do that for you.
print "@{$ref}\n" ;
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 20 Jan 2001 02:14:59 GMT
From: psu22377@odin.pdx.edu
Subject: Can't get ActiveState's GUI Perl Debugger to work on Windows 2000 / IIS 5
Message-Id: <94asav$kfp$1@nnrp1.deja.com>
I am having trouble getting the perl GUI debugger in PerlDev kit to
launch from a an IIS 5.0 site.
I have a win2k box running IIS 5.0 with CGI perl pages setup and I
would like to debug them while I am logged in at the console on that
box.
IIS is configured with an ISAPI applicaiton mapping like
E:\Perl\bin\Perl.exe "%s" %s for .pl files
I changed the ISAPI mapping to
E:\Perl\bin\Perl.exe -d "%s" %s to trigger the debugging
and setup for local debugging.
The problem is that the perldb.exe launches but not on the console.
I made sure that IISAdmin service, MSFTPSvc, and IIS (and any other IIS
type service) all run as System with interact with console checked in
the services area.
The problem is that IIS always runs under another users context like
IUSR_machinename then it launches PerlDB.exe as that account not in the
same console.
I also tried do it remotely off another server, changing the ISAPI
mapping again to perl.exe -d "%s" %s and configuring it to try to
connect TCP on port 2000 to another box that was set up as the listener
with that perlsocket service, and I also configured that service to run
as system with "allow to interact with console checked". Set the
PERLDB_OPTS environment variable as specified in the documentation.
And it does connect and lauch PerlDB - i.e. when I go to a .pl page in
the web browser, the browser appears paused - on the debug listening
box a connection is made to the debugging port 2000. And PerlDB
appears in the process list on the remote machine doing the debugging.
However, the PerlDB does not come up with a window.
I believe it is because of the ability of the Perlsocket listener to
interact with the desktop, but I already set that service to run as
system with ability to interact with the desktop.
Just wondering if you had any tips. Could not find much on the
newsgroups or in your FAQs. I was going to try the whole thing with
Apache on Win32 next.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sat, 20 Jan 2001 05:03:23 -0000
From: "Jerry Pank" <me@jp1.co.uk>
Subject: Counting elements in an array (foreach)
Message-Id: <94b663$2ul$1@neptunium.btinternet.com>
Perl special variable for counting elements in an array (foreach etc)
If I wish to count elements whilst looping through an array, I resort to $i
as below.
I would have thought perl would have had a `special' variable for this.
There probably is but I can't find one in my reference material.
#!bin/perl5 -w
use strict;
my @array=(1..100);
my $i;
foreach my $element(@array) {
$i++;
# do stuff
print "Done element $i\n";
}
-- Jerry Pank:wq me@jp1.co.uk
------------------------------
Date: 20 Jan 2001 06:32:37 GMT
From: Jim Monty <monty@primenet.com>
Subject: Re: Counting elements in an array (foreach)
Message-Id: <94bbe5$sqq$1@nnrp2.phx.gblx.net>
Jerry Pank <me@jp1.co.uk> wrote:
> Perl special variable for counting elements in an array (foreach etc)
>
> If I wish to count elements whilst looping through an array, I resort to $i
> as below.
>
> I would have thought perl would have had a `special' variable for this.
> There probably is but I can't find one in my reference material.
There's no need for a 'special' loop counter variable in Perl. The
number of elements in the array @array is given by @array in a scalar
context. For example:
my $number_of_elements = @array;
You can force a scalar context using the scalar function. For
example:
print scalar @array; # print number of elements of @array
And the last index of the array @array is given by $#array.
So...
> #!bin/perl5 -w
Shouldn't that be '#!/bin/perl5 -w'?
> use strict;
> my @array=(1..100);
> my $i;
> foreach my $element(@array) {
> $i++;
> # do stuff
> print "Done element $i\n";
> }
You're simply using the wrong idiom.
foreach (0 .. $#array) {
# $_ is index of @array, $array[$_] is corresponding element
}
foreach my $i (0 .. $#array) {
# $i is index of @array, $array[$i] is corresponding element
}
for (my $i = 0; $i <= $#array; $i++) {
# $i is index of @array, $array[$i] is corresponding element
}
foreach (@array) {
# $_ is element of @array, index is unknown
}
foreach my $element (@array) {
# $element is element of @array, index is unknown
}
Any of those foreach's can be (and often are) abbreviated to for.
"for" example:
for (0 .. $#array) { ... }
--
Jim Monty
monty@primenet.com
Tempe, Arizona USA
------------------------------
Date: Sat, 20 Jan 2001 07:25:07 GMT
From: Carfield Yim <carfield@my-deja.com>
Subject: Database connection pool with Perl Object Environment?
Message-Id: <94begj$1au$1@nnrp1.deja.com>
Can I implement a database connection pool with Perl Object Environment
(POE)?? Seen to me that it can, as it can implement any kind of service, it
is right?
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sat, 20 Jan 2001 04:01:00 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: FAQ 9.10: How do I redirect to another page?
Message-Id: <048a6.1139$B9.194601472@news.frii.net>
In article <Pine.LNX.4.30.0101181609580.3033-100000@lxplus003.cern.ch>,
Alan J. Flavell <flavell@mail.cern.ch> wrote:
>On 18 Jan 2001, Anno Siegel wrote:
>
>> >writing some new text based on some very helpful discussions here with
>> >the regulars, it seemed to fly like a lead balloon when I tried to
>> >raise it with the Perlbugs folks, so I got dispirited.
>>
>> Don't be. In my experience doc patches are silently incorporated
>> in one release or another (not necessarily the earliest possible).
>
>Thanks, that was a helpful response. I'm afraid I blasted off in a
>rather negative frame of mind yesterday.
>
>Maybe I _will_ try opening a doc bug on the other issues, and see how
>it goes.
>
You do realize that patches get included much more quickly than
discriptions to problems. This is especially for documentation.
Unless what you write is just plain wrong or missleading they usualy
get encorporated. The output of 'diff -c old.pod new.pod' is a realy good
format since it works well with that other venerable Larry Wall program,
patch.
chris
--
This space intentionally left blank
------------------------------
Date: 20 Jan 2001 03:00:19 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: FAQ 9.15: How do I decode a CGI form?
Message-Id: <94av03$iir$1@216.155.32.222>
In article <Cc6a6.1624$ZB2.254493@paloalto-snr1.gtei.net>, "Joe C.
Hecht" <joehecht@code4sale.com> wrote:
| > Writing your own read and parse routine for handling
| > form action input data is infinitely superior to
| > this cgi.poopmaker, which is a well documented source
| > of problems and has a history of continuous upgrades
| > to compensate for these endless problems.
|
| Too true!
|
| Joe
you're dreaming. my "time-elapsed from cold-start knowing NO perl at
all, to having a finished heavily complex perldsc/perllol-using cgi +
crontab-run perl script pair" was 3 weeks. I'd never have gotten it as
far as I did, as fast as I did, without CGI.pm.
Bear in mind there's 'lite' versions as well.
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Sat, 20 Jan 2001 07:31:58 GMT
From: Sterling <smullett@omeninc.com>
Subject: GD.pm/ImageMagick - Any thing better?
Message-Id: <3A693F0A.F4E4C62E@omeninc.com>
H-
I'm currently using GD.pm to create png files on the fly. But the
resolutions (circles for instance) aren't that great and have a lot of
pixelation.
I had looked into using Magick but it really doesn't do all the drawing
things that I'll need.
I was wondering if anyone knew of any other more robust graphics
packages that plug in easily with Perl that might provide better
resolutions and image creations?
Thanks.
Thoughts, Comments, Anecdotes?
-Sterling
------------------------------
Date: Sat, 20 Jan 2001 12:47:07 +0530
From: "Biswajit Dash" <bidash@cisco.com>
Subject: help me (fetching pages from net)
Message-Id: <979974687.159255@sj-nntpcache-3>
Hi ,
I am new to perl & also to this newsgroup. Please help me.
I use the following code to fetch pages from internet & store it locally.
My program runs as a process and fetches pages every 30 min interval.
$req = new HTTP::Request 'GET' => $urlname;
$req->header('Accept' => 'text/html');
$res = $ua->request($req);
if ($res->is_success) {
@data = $res->content;
open (FILE, ">>$filename") || die $!;
print FILE @data;
close(FILE);
} else {
print "Error: " . $res->status_line . "\n";
}
My problem is, I am behind a proxy, and my page always gets a cached page,
instead of the recent one.
How can I fetch the recent copy of the page, from behind proxy ??
please reply to biswajitind@yahoo.com
Thanks
Biswajit
------------------------------
Date: 19 Jan 2001 21:55:44 -0600
From: claird@starbase.neosoft.com (Cameron Laird)
Subject: Re: how to send a big file pipeing to sendmail
Message-Id: <CA524741A36548A3.F779B1F72B63612F.31E190122927C28F@lp.airnews.net>
In article <94abki$647$1@nnrp1.deja.com>, <metamp@my-deja.com> wrote:
>I can not load a huge file to a $scalar
>and I do not know a different way to send a big file useing send mail
>the cat command would work I belive but do not know how to use itcan
>anybody help with the syntax
>
>this does not work
>
>
>$sendmail ="/usr/lib/sendmail";
>$myemail = 'henry@ttiorg.com';
>
>open (dfile, "<file.txt");
>flock (dfile,2);
>$mail_body =<dfile>;
>flock (dfile,8);
>close dfile;
>
>open (MAIL,"|$sendmail -oi -t") or die "Can't open pipe to $sendmail: $!
>\n";
>print MAIL "To: $myemail\n";
>print MAIL "From: $sender\n";
>print MAIL "Subject: the CGI datafile\n\n";
>print MAIL "$mail_body";
>close(MAIL) or die "Can't close pipe to $sendmail: $!\n";
>
>the file is too large to by loaded to $scalar
.
.
.
Unpolished version:
$header_name = "/tmp/header";
open(header, ">".$header_name);
print header "To: $myemail
From: $sender
Subject: the datafile
";
$command = "cat ".$header." file.txt | sendmail -oi -t";
system($command);
--
Cameron Laird <claird@NeoSoft.com>
Business: http://www.Phaseit.net
Personal: http://starbase.neosoft.com/~claird/home.html
------------------------------
Date: 20 Jan 2001 06:19:35 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: overload not autogenerating as expected
Message-Id: <94baln$lko$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Uri Guttman
<uri@sysarch.com>],
who wrote in article <x7ely522yb.fsf@home.sysarch.com>:
> m> In order to get around the problem I have had to specify a 'cmp'
> m> overload function something like...
>
> m> cmp => sub { "$_[0]" cmp "$_[1]" }
>
> m> ...which explicitly stringifies both operands (to be safe) before
> m> performing the comparison.
> as those values are inside your overloaded class, you can do whatever
> you want to them. i don't think the extra "" is needed. cmp should
> stringify them just by itself as it is perl's cmp and not your
> overloaded one.
There is no such thing as "Perl's cmp" as opposed to "something". All
cmp's are equal. So omiting quotes will make cmp call the above sub,
which does cmp, which will trigger the same sub, etc etc etc.
Ilya
------------------------------
Date: Sat, 20 Jan 2001 02:47:55 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl - Bytecode, Compile to C, Perl2EXE
Message-Id: <slrn96hllm.8jq.tadmc@tadmc26.august.net>
[ Please limit your line lengths to the customary 70-72 characters ]
jgore@home.com <jgore@home.com> wrote:
>
>I have two problems:
>1) I would like to distribute the program but not the source.
Rewriting your program in a different programming language
is an option. But compiled programs are not "secret" either.
>2) I would like to run it on my ISP 's server (simplehost.com).
>PERL2EXE:
>It would keep the source secret
No it wouldn't (but you might _think_ it would, increasing
your shock and horror when it was found out).
>Do most ISP's allow bytecode?
You should ask WWW-related questions in one of the newsgroups
related to WWW stuff. This is not one of those newsgroups,
we discuss Perl here.
>I'm just looking for the best way to distribute my program and run it on a standard ISP site that
>allows perl.
The best way to distribute your program and run it on a standard ISP
site (I didn't know there were standards for that) that allows perl
would be to distribute the source, but you said you don't want to
do that.
So you cannot use the _best_ way. You need one of the inferior ways.
Perl FAQ, part 3:
"How can I hide the source for my Perl program?"
You are expected to check the Perl FAQ *before* posting to
the Perl newsgroup.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 20 Jan 2001 04:52:50 GMT
From: jgore@home.com
Subject: Re: Perl - Bytecode, Compile to C, Perl2EXE
Message-Id: <3a6914eb.158014296@24.14.77.6>
>On 20 Jan 2001 00:49:33 GMT, abigail@foad.org (Abigail) wrote:
>
>jgore@home.com (jgore@home.com) wrote on MMDCXCVIII September MCMXCIII in
><URL:news:3a68d192.140770597@24.14.77.6>:
>@@ Perl - Bytecode, Compile to C, Perl2EXE
>@@
>@@ I'm confused!
>@@ I have a perl (CGI) program which uses many other modules.
>@@ I can run it on my own server just fine.
>@@
>@@ I have two problems:
>@@ 1) I would like to distribute the program but not the source.
>
>I've a solution, but just as you, I like to keep it hidden.
What is your solution? you didn't say.
>
>@@ 2) I would like to run it on my ISP 's server (simplehost.com).
>
>That's not a Perl problem.
Didn't say it was. But, most ISP's won't let you run EXE's.
I thought there might be other alternatives .
>
>@@ PERL2EXE:
>@@ I could use PERL2EXE and make an executable but my ISP doesn't allow EXE's i
>
>Very sensible. I wouldn't allow any user to run any CGI program, so
>consider yourself lucky.
You wouldn't get my business.
>
>@@ It would keep the source secret but people could only run it on their own sev
>
>You lost me here.
If I compiled the code into an EXE then you could only run it on
your own server (at your home or business) like I do, because most ISP's won't let you run EXE's.
>@@ ByteCode:
>@@ I can't find a lot info about this. The module doesn't say much about how to
>@@ Do most ISP's allow bytecode? Does bytecode include all the other modules my
>@@ uses (like an EXE) ? Any tutorial pages on this besides what comes with per
>
>How should we know what the majority of the ISP's have for policies?
If Bytecode is built-in to perl then I would assume most ISP's allow it.
The docs don't say much about anything, which is why I was asking
if anyone knew of a tutorial.
>
>@@
>@@ Compile to C:
>@@ Does this work? Any tutroial pages on it anywhere?
>
>Did you try?
Should I waste my time on it?
>
>@@ I'm just looking for the best way to distribute my program and run it on a st
>@@ allows perl. Any help appreciated!
>
>Use the source, Luke!
Source code is not an alternative. It's too hard for newbies to set up
and we shouldn't have to "give away" something we worked hard on.
>Abigail
Thanks for trying anyways.................Anyone else?
------------------------------
Date: Sat, 20 Jan 2001 05:23:58 GMT
From: jgore@home.com
Subject: Re: Perl - Bytecode, Compile to C, Perl2EXE
Message-Id: <3a691a7b.159438080@24.14.77.6>
>On Sat, 20 Jan 2001 02:47:55 GMT, tadmc@augustmail.com (Tad McClellan) wrote:
>
>[ Please limit your line lengths to the customary 70-72 characters ]
Fixed it. Sorry.
>jgore@home.com <jgore@home.com> wrote:
>>
>>I have two problems:
>>1) I would like to distribute the program but not the source.
>
>
>Rewriting your program in a different programming language
>is an option. But compiled programs are not "secret" either.
Rewriting Perl to something else sorta defeats writing it in Perl
in the first place, heh.
>>2) I would like to run it on my ISP 's server (simplehost.com).
>
>
>>PERL2EXE:
>>It would keep the source secret
>
>No it wouldn't (but you might _think_ it would, increasing
>your shock and horror when it was found out).
I would just like to make it harder for people to rip me off. I know
there is no way to make it completely safe. I just thought some
old-timers here might point me in the right direction.
>>Do most ISP's allow bytecode?
>
>
>You should ask WWW-related questions in one of the newsgroups
>related to WWW stuff. This is not one of those newsgroups,
>we discuss Perl here.
Chill Bro ! It is a question about Perl.
I had assumed that some perl programmers had experience running their
programs on an ISP. I thought they might have some good advice about
running Perl there.
>>I'm just looking for the best way to distribute my program and run it on a standard ISP site that
>>allows perl.
>
>
>The best way to distribute your program and run it on a standard ISP
>site (I didn't know there were standards for that) that allows perl
>would be to distribute the source, but you said you don't want to
>do that.
>So you cannot use the _best_ way. You need one of the inferior ways.
>
>Perl FAQ, part 3:
>
> "How can I hide the source for my Perl program?"
>
>You are expected to check the Perl FAQ *before* posting to
>the Perl newsgroup.
I did read it. It didn't say a great deal.
I was hoping Perl programmers with more experience could
point me to some better tutorials. You will notice I asked that
several times.
Or, did you see something in those two short paragraphs in the
FAQ that would help me with my dilemma, cause I must have missed it.
The "How can I hide the source for my Perl program?" and
"How can I compile my Perl program into byte code or C?" is not a
tutorial, doesn't show you how to do it, doesn't talk about the Pros
and Cons. It mainly just says there is such a thing. I was just
seeking better advice and perhaps a lead on a tutorial somewhere.
> Tad McClellan SGML consulting
I'm prescribing Lithium and Valium for everyone here!
Everyone sure seems hostile.
------------------------------
Date: Sat, 20 Jan 2001 02:35:18 -0500
From: "James Kauzlarich" <nospam-abuse@[127.0.0.1]>
Subject: Re: Perl - Bytecode, Compile to C, Perl2EXE
Message-Id: <9dba6.6541$d25.40444@newsfeed.slurp.net>
jgore, you started off in this newsgroup all wrong. Let me try to point out
some of your errors and give a bit of advice.
Read and go in peace...
<jgore@home.com> wrote in message news:3a691a7b.159438080@24.14.77.6...
> >On Sat, 20 Jan 2001 02:47:55 GMT, tadmc@augustmail.com (Tad McClellan)
wrote:
(snip)
> >>I have two problems:
> >>1) I would like to distribute the program but not the source.
First, I don't expect that you are going to find too much support for
closed-source programming in a Newsgroup. I think you can safely assume
that this is going to be pretty much a pro open-source community here.
Hence Abigail's responce "I've a solution, but just as you, I like to keep
it hidden."
> >>Do most ISP's allow bytecode?
> >
> >
> >You should ask WWW-related questions in one of the newsgroups
> >related to WWW stuff. This is not one of those newsgroups,
> >we discuss Perl here.
>
> Chill Bro ! It is a question about Perl.
> I had assumed that some perl programmers had experience running their
> programs on an ISP. I thought they might have some good advice about
> running Perl there.
Second. Yes, this place is full of good advice about Perl. Writing Perl,
not neccicarily running it. Perl is more than a script that runs on web
servers, and asking what most ISP's do is deinatly a WWW question, not a
Perl question.
You might^H^H^H^H^H will find your question your question more warmly
responded to in the comp.infosystems.www.authoring.cgi newsgroup. This
group has people that MAY know the answer, but it's like busting into a Mac
lovers convetion, grabbing the mic and asking an MSDOS question to the
crowd. You'd be lucky to leave with only cold-stares.
> >You are expected to check the Perl FAQ *before* posting to
> >the Perl newsgroup.
>
> I did read it. It didn't say a great deal.
(snip)
> Or, did you see something in those two short paragraphs in the
> FAQ
Third, evidently you did NOT read the FAQ. The Perl FAQ is huge. It sounds
like you may have read one porrtion of the FAQ, but it is so large that it
is posted in parts over several days (which, incidently is why it said FAQ
X.XX. Each part incliding a link to a cpan.org which has the whole FAQ. It
would be nice if they included an url directly to the FAQ, so here one is
http://www.cpan.org/doc/manual/html/pod/perlfaq.html
> I'm prescribing Lithium and Valium for everyone here!
> Everyone sure seems hostile.
>
Fourth and lastly taking an attitude with two of the community leaders (and
most knowledgable people) here is NOT a good way to get advice, though it is
a good way to have your name and email address put into the killfiles of the
best sources of information in this newsgroup. They have paid their dues
here. You have not.
Live and learn. 8-)
jmk
--
do NOT remove the nospam from the repy to address above,
instead send email to o1tech(at)skyenet(dot)net
JAPN 8_(
------------------------------
Date: 20 Jan 2001 03:08:56 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: Perl Style Guide - uncuddled elses
Message-Id: <94avg8$iir$2@216.155.32.222>
In article <u9ae8nctf1.fsf@wcl-l.bham.ac.uk>, nobull@mail.com wrote:
| > I am reading the Perl Style Guide and don't understand what the meaning
| > of "uncuddled elses" is. What is meant by "uncuddled" ?
[snippage]
| else { # This is an uncuddled else!
| bar;
| }
| }
| else # This is also an uncuddled else!
| {
interesting.. my subconscious seems to have already figured it out
(looking at my earlier code post) even though the realization hadn't
reached the forebrain yet. lol! ahh, well. It did make more sense and
make the code more legible to write them that way, so I did. :) Nice to
know there's some perlish wisdom behind doing so.. I'm used to seeing
the cuddled form from my brief forays into Tcl/tk.
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Fri, 19 Jan 2001 23:25:02 -0600
From: Jerry McEwen <>
Subject: Re: PWS - perl (ATTN: cwrites)
Message-Id: <248i6t8n8qjsq1nj8tuioo04u0tqtanudt@4ax.com>
Sven, have you gotten this to work with PWS or did you go another
route? I am running Win98SE with th NT 4.0 Option pack. I read the
Active State stuff, but it is wrong; the options they mention in MMC
are not correct.
I found a place in the PWS 3.0 section that talks about the registry
and that is wrong as well (probably a typo), but I figured out where
they were talking about. I cannot, however, determine how to make the
extension in the registry. An example would be very handy, do you have
one? TIA.
------------------------------
Date: Sat, 20 Jan 2001 02:45:27 GMT
From: arkconfused@hotmail.com
Subject: Spawning Parallel Processes
Message-Id: <94au46$lrp$1@nnrp1.deja.com>
I have been trying to look at away to have a perl script spawn off 7
processes and to have them run at the same time. Each process telnets
into a different server. Any ideas?
--
ARKConfused
arkconfused@hotmail.com
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Fri, 19 Jan 2001 20:43:09 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Spawning Parallel Processes
Message-Id: <slrn96hr9d.8o9.tadmc@tadmc26.august.net>
arkconfused@hotmail.com <arkconfused@hotmail.com> wrote:
>I have been trying to look
Where have you been looking?
If you tell us where you have already looked we won't point
you to where you have already been.
The first place to look for _any_ Perl problem is the docs
that come with the perl distribution.
perldoc -q process
"How do I start a process in the background?"
"How do I close a process's filehandle without waiting
for it to complete?"
"How do I fork a daemon process?"
perldoc -f fork
perldoc -f exec
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 V10 Issue 104
**************************************