[19896] in Perl-Users-Digest
Perl-Users Digest, Issue: 2091 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 8 06:05:36 2001
Date: Thu, 8 Nov 2001 03:05:09 -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: <1005217508-v10-i2091@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 8 Nov 2001 Volume: 10 Number: 2091
Today's topics:
Re: .cgi program (long) <c_clarkson@hotmail.com>
A Newbie's Question <JJSUSA2001@yahoo.com>
Re: A Newbie's Question <bernard.el-hagin@lido-tech.net>
Re: Best language for low IQ programmers? <kjs@stauffercom.com>
Re: Best language for low IQ programmers? <no_spam_eirik@stockpoint.no>
Re: Best language for low IQ programmers? <neskirneh_retep@hotmail.com>
Re: Can you help optimize this?? <c_clarkson@hotmail.com>
Re: Dealing with Data::Dumper (Rafael Garcia-Suarez)
Re: force stack dump after die (Villy Kruse)
Re: force stack dump after die (Matt Sergeant)
How to pass Perl objects into C++? (Alexander)
Impossible to store tied hash (MLMDB) in an object? <tassilo.parseval@post.rwth-aachen.de>
Need Help To Get Started <SEUSA2000@yahoo.com>
Re: Need Help To Get Started (Joe Smith)
Re: Need Help To Get Started <tassilo.parseval@post.rwth-aachen.de>
Re: Need Help To Get Started <edgue@web.de>
Re: passing array values from perl to javascript <geoff@REMOVETHISgeoffball.net>
Perl tool to grab websites (Xah Lee)
Re: Perl tool to grab websites <thepoet@nexgo.de>
Re: playing WAV file on unix and windows? <Laocoon@eudoramail.com>
Re: reg ex <bart.lateur@skynet.be>
Re: reg ex (Joe Smith)
Re: Simulating shell wildcards in perl (Rafael Garcia-Suarez)
Store an object reference as hash key? (Markus Dehmann)
Re: too late for -T? (Villy Kruse)
unexpected behaviour behind a protecte directory <google@psc-it.nl>
Re: unexpected behaviour behind a protecte directory <wyzelli@yahoo.com>
Re: URGENT! Please help me with this! <edgue@web.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 7 Nov 2001 21:57:18 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: .cgi program (long)
Message-Id: <tuk5bbd7bkdf0d@corp.supernews.com>
"John Smith" <creafin1998@yahoo.com> wrote in message:
: When the..
: in data file is: the out data file is:
: 40000 lines 27 lines and the 500 server
error
: 1800 lines 1011 lines and the 500 server
error
: 1700 1243 and the 500 server error
: 1650 1515 and the 500 server error
: 1624 1624 (as expected)
: 1600 1600 (as expected)
:
: Interestingly, I took several fields (columns) out of the
: 'in data file' shrinking the size down for an equal # of
: lines from the above example and found:
:
: When the...
: in data file is: the out data file is:
: 1799 lines 1799 lines (as expected)
: 3899 lines 585 lines and the 500 server
error
:
: I'm not getting any error messages from the server
: log that I have access to on any of these 500 server
: errors I get through my browser.
:
: Here's a copy of the entire program with generic
: names replacing the actual variable names.
: I know that it's a little sloppy. For those of you
: who are professionals, I apologize.
:
: #!/usr/local/bin/perl
Add (as mentioned in another post):
use CGI::Carp 'fatalsToBrowser';
[snipped for brevity - indentation added]
: &page_data;
:
: sub page_data {
:
: print "Content-type: text/html\n\n";
:
: # Example input data file line entry after removing
: # some fields (columns) as outlined in my email above
:
: open (LOGFILE, "</path/to/datafile.csv");
: @lognfile = <LOGFILE>;
This is the first thing that looked strange. I can
understand grabbing the whole file from the way your
algorithm works, but why keep the file open for all
that time? Why no check for a successful open?
open LOGFILE, "</path/to/datafile.csv" or die $!;
chomp( @lognfile = <LOGFILE> );
close LOGFILE;
I added the chomp as your code indicated it might
be useful.
:
: # Main for loop starts with 2nd line of input data file
: for ($z = 1; $z <= $#lognfile; $z++) {
: $s = 0;
: $count = 0;
: $tv = 0;
: $tc = 0;
Alright you've already been chastized about strict.
I won't go there, but:
foreach my $z (1 .. $#lognfile) {
my ($s, $count, $tv, $tc) = (0) x 4;
is much easier to read. The range operator (..)
is mentioned in perlop.
: ($text01, $text02, $data01, $data02, $data03, $data04,
$data05)
: = split /,/, $lognfile[$z];
Whenever you see var01, var02, var03, ... think
array:
($text01, $text02, @data) = split /,/, $lognfile[$z];
: $sum = $data01 + $data02 + $data03 + $data04 + $data05;
using @data, we can get a total with:
$sum += $_ for @data[0 .. 4];
I used @data[0 .. 4] because I didn't know how much
split returned. I could just as easily added:
@data = @data[0 .. 4]; and used @data.
: if ($data01 > 0) { $s = $s + 1; $count = $count + 1;}
: if ($data02 > 0) { $s = $s + 1; $count = $count + 1;}
: if ($data03 > 0) { $s = $s + 1; $count = $count + 1;}
: if ($data04 > 0) { $s = $s + 1; $count = $count + 1;}
: if ($data05 > 0) { $s = $s + 1; $count = $count + 1;}
: if ($data01 <= 0) { $count = $count + 1;}
: if ($data02 <= 0) { $count = $count + 1;}
: if ($data03 <= 0) { $count = $count + 1;}
: if ($data04 <= 0) { $count = $count + 1;}
: if ($data05 <= 0) { $count = $count + 1;}
Now that we are using an array:
for (@data[0 .. 4]) {
if ($_ > 0) { $s++; $count++;}
if ($_ <= 0) { $count++;}
}
Here is our first error in logic. Note that $count is
always incemented.
for (@data[0 .. 4]) {
$count++;
$s++ if $_ > 0;
}
accomplishes the same thing with half the tests. We
can combine this with:
for (@data[0 .. 4]) {
$sum += $_;
$count++;
$s++ if $_ > 0;
}
Or:
for (@data[0 .. 4]) {
$sum += $_;
$s++ if $_ > 0;
}
$count = 5;
: $z = $z + 1;
Z++;
: ($text1, $text2, $data1, $data2, $data3, $data4, $data5) =
split /,/,
: $lognfile[$z];
($text01, $text02, @data) = split /,/, $lognfile[$z];
: # BEGIN FOR LOOP
:
: for ($y = $z+1; $y <= $#lognfile; $y++) {
for my $y ($z + 1 .. $#lognfile) {
:
: if (($text1 eq "$text01") & ($text2 eq "$text02")) {
: $sum = $sum + $data1 + $data2 + $data3 + $data4 + $data5;
: if ($data1 > 0) { $s = $s + 1; $count = $count + 1;}
: if ($data2 > 0) { $s = $s + 1; $count = $count + 1;}
: if ($data3 > 0) { $s = $s + 1; $count = $count + 1;}
: if ($data4 > 0) { $s = $s + 1; $count = $count + 1;}
: if ($data5 > 0) { $s = $s + 1; $count = $count + 1;}
: if ($data1 <= 0) { $count = $count + 1;}
: if ($data2 <= 0) { $count = $count + 1;}
: if ($data3 <= 0) { $count = $count + 1;}
: if ($data4 <= 0) { $count = $count + 1;}
: if ($data5 <= 0) { $count = $count + 1;}
: }
Once again, this can be reduced to:
foreach my $y ($z + 1 .. $#lognfile) {
if (($text1 eq "$text01") & ($text2 eq "$text02")) {
for (@data[0 .. 4]) {
$sum += $_;
$count++;
$s++ if $_ > 0;
}
}
($text1, $text2, @data) = split /,/, $lognfile[$z];
}
This foreach throws up a huge red flag. We're
proccessing the rest of the array and leaving; only
to do it all over again. Thats extremely inefficient.
A bit of manipulating shows this as equivalent:
foreach my $z (1 .. $#lognfile) {
my ($s, $count, $tv, $tc) = (0) x 4;
($text01, $text02, @data) = split /,/, $lognfile[$z];
for (@data[0 .. 4]) {
$sum += $_;
$count++;
$s++ if $_ > 0;
}
foreach my $y ($z + 1 .. $#lognfile) {
($text1, $text2, @data) = split /,/, $lognfile[$z];
if (($text1 eq "$text01") & ($text2 eq "$text02")) {
for (@data[0 .. 4]) {
$sum += $_;
$count++;
$s++ if $_ > 0;
}
}
}
Still inefficient.
: ($text1, $text2, $data1, $data2, $data3, $data4, $data5) =
split /,/,
: $lognfile[$y];
:
: # END FOR LOOP
:
: }
:
: $tv = $sum / ($count + 0.0001);
: $tc = 100 * ($s / ($count + 0.0001));
: $tv = sprintf ("%01.2f", $tve);
: $tc = sprintf ("%01.1f", $tc);
: open (OUT, ">>/path/to/outdatafile.csv") or
: die "can't open output file: $!";
: print OUT "$text01,$text02,$tv,$tc\n";
: close (OUT);
Here's another flag. Why open and close this file
each time through the loop? Why not push the result
onto an array and append the file once?
push @out_file_contents, "$key,$tv,$tc\n";
then later:
open OUT, ">>/path/to/outdatafile.csv" or
die "can't open output file: $!";
print OUT @out_file_contents;
close OUT;
: $z = $z - 1;
: #end main for loop
: }
: close (LOGFILE);
: #end subroutine
:
: }
:
[snipped unused routine]
The first time through we pull out the first
element and sum the rest. The second time we pull
out the second element and sum the rest. And so
on.
Let's flip the problem over. We sum the
entire array. Then we subtract the first element.
Then we subtract the third element. And so on.
So, let's start over. We'll create 2 data
structures. One a hash containing an array of the
totals keyed by "$text01,$text02". The second will
be an array of arrays each inner array consisting
of [$key, $sum_for_that_line, $s_for_that_line].
I chose to name this @log.
my (@log, %results);
open LOGFILE, "</path/to/datafile.csv" or die $!;
<LOGFILE>; # discard first line.
while (<LOGFILE>) {
chomp;
my @data = split /,/;
my ($sum, $s) = (0, 0);
for (@data[2 .. 6]) { # look familiar?
$sum += $_;
$s++ if $_ > 0;
}
my $key = "$data[0],$data[1]";
$results{$key}[0] += $sum;
$results{$key}[1] += $s;
$results{$key}[2]++; # count / 5
push @log, [ $key, $sum, $s ];
}
close LOGFILE;
my @out_file_contents;
foreach my $line (@log) {
my $key = $$line[0];
my ($sum, $s, $count) = @{ $results{$key} };
$count *= 5;
my $tv = sprintf "%01.2f", $sum / ($count + 0.0001);
my $tc = sprintf "%01.1f", 100 * $s / ($count + 0.0001);
push @out_file_contents, "$key,$tv,$tc\n";
# here's where we subtract the current line
# from the totals
$results{$key}[0] -= $$line[1]; # sum
$results{$key}[1] -= $$line[2]; # s
$results{$key}[2]--; # count / 5
}
open OUT, ">>/path/to/outdatafile.csv" or
die "can't open output file: $!";
print OUT @out_file_contents;
close OUT;
"John Smith" <creafin1998@yahoo.com> wrote
in message news:tu9divpqapse4f@corp.supernews.com...
: I have a very annoying problem occurring with a new
: cgi program I wrote. I'm opening a text file and
: processing data from the file, then placing the
: results in another file. Done it a million times
: with no problems. This one is a little different
: in the since that I have 2 'for' loops which will
: cause the program to loop approximately 40,000 *
: (40,000 - n) times, where n starts at 1 and is
: incremented. This is more looping than I usually
:deal with in a program.
I think we are now at 40,000 * 2 iterations.
HTH,
Charles K. Clarkson
Clarkson Energy Homes, Inc.
Some people, when confronted with a problem,
think 'I know, I'll use regular expressions.'
Now they have two problems.
- Jamie Zawinski, on comp.lang.emacs
------------------------------
Date: Thu, 8 Nov 2001 05:27:52 -0500
From: "James Sullivan" <JJSUSA2001@yahoo.com>
Subject: A Newbie's Question
Message-Id: <9sdm2e$okc$1@slb5.atl.mindspring.net>
$input = "I am new";
What is the difference between:
@data = split (' ', $input) and
@data = split(/ /, $input)
What would I get for $data[0], $data[1], $data[2] in both cases? Are they
any differences?
------------------------------
Date: 8 Nov 2001 10:41:43 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: A Newbie's Question
Message-Id: <slrn9ukrdm.mi5.bernard.el-hagin@gdndev25.lido-tech>
On Thu, 8 Nov 2001 05:27:52 -0500, James Sullivan <JJSUSA2001@yahoo.com> wrote:
> $input = "I am new";
>
> What is the difference between:
>
> @data = split (' ', $input) and
> @data = split(/ /, $input)
>
> What would I get for $data[0], $data[1], $data[2] in both cases? Are they
> any differences?
Why don't you just try? Sheesh!
Cheers,
Bernard
------------------------------
Date: Wed, 7 Nov 2001 23:50:40 -0600
From: "Ken Stauffer" <kjs@stauffercom.com>
Subject: Re: Best language for low IQ programmers?
Message-Id: <9sd6ga$voa$1@slb4.atl.mindspring.net>
"dmason" <dylmason@hotmail.com> wrote in message
news:bb69ecbe.0111071427.35ba38c8@posting.google.com...
> ...I can't believe how many people actually took this seriously....
>
>
Some people took communism seriously, too. Don't be so suprised.
------------------------------
Date: Thu, 08 Nov 2001 08:06:09 GMT
From: "Eirik Mangseth" <no_spam_eirik@stockpoint.no>
Subject: Re: Best language for low IQ programmers?
Message-Id: <R1rG7.14$eZi.171124224@news.telia.no>
"jmburton" <jmburton@usenix.org> wrote in message
news:1005188797788841@usenix.org...
> > C++ is the best choice for dull programmers. The quality of your code
will
> > be indistinguishable from that of a the C++ guru.
>
> Are you a troll?
>
> In case if you are genuine, which I doubt, I disagree. Eiffel is a
> better language for dull programmers. Since Eiffel is usually abandoned
> before software goes into production, no one will ever have to deal
> with the inevitable bugs left by sloppy Eiffel programmers.
> Plus, poor performance due to bad algorithms designed by poorly
> educated programmers can be excused by the natural slowness of Eiffel
> (garbage collection instead of efficient on-demand memory allocation
> and deallocation).
>
> You have to know C++ anyway, as Eiffel is merely a front end to C++
> (it is compiled into C++, not native code), and requires external calls
> to C++ for anything useful like OS services.
>
> I studied Eiffel in college and have a buddy who used to program in
> that sad pathetic language, so I do know what I am talking about.
And pigs will fly.
> - - - - - - - - - - - - - - - - - -
> J M Burton
> FreeBSD Consulting & Security Administration
> * * * This is a .sig virus. Copy it into your .sig to propagate. * * *
>
-- eirik
"If I can't Eiffel in heaven, I won't go"
------------------------------
Date: Thu, 08 Nov 2001 10:07:39 +0100
From: Peter Henriksen <neskirneh_retep@hotmail.com>
Subject: Re: Best language for low IQ programmers?
Message-Id: <hlikutkg4os0m67gucs1hkn66a1cmfd6fm@4ax.com>
On Tue, 06 Nov 2001 23:58:21 GMT, "Marshall Spight" <mspight@dnai.com>
wrote:
>"Joona I Palaste" <palaste@cc.helsinki.fi> wrote in message news:9s9pk1$rrt$2@oravannahka.helsinki.fi...
>> Well technically JSP/Servlets and HTML are orthogonal technologies. For
>
>True enough. Still, I find it pretty wacky to have been passed over
>for something because of a missing ten cent technology, when I
>had hundred dollar skills listed on my resume.
You're absolutely right, thoguh that would tell me not to work for
such a company ;-)
If they're not smart enough to read my resume... but maybe it's just
me being picky ...
------------------------------
Date: Wed, 7 Nov 2001 22:46:35 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: Can you help optimize this??
Message-Id: <tuk5bcnsrkh20e@corp.supernews.com>
"Rob" <robsjobs@hotmail.com> wrote
in message
news:3KAF7.17026$zK1.5798745@typhoon.tampabay.rr.com...
: I realize that index is a horrible function for speed.
Bzzt. It is very fast. You just don't need it here.
: Here is what my program looks like (more pseudo than
: code, FYI)
:
: $array_of_abrev[0]="PA";
: $array_of_abrev[1]="PN";
: $array_of_abrev[3]="PR";
: $array_of_abrev[4]="PT";
my @array_of_abrev = qw/PA PN PR PT/;
: $list_of_cust_ids[0]="A95412";
my @list_of_cust_ids = qw/A95412/;
: $cust_config{$list_of_cust_ids[0]}= "AB,AC,AF,GR,PR";
my %cust_config;
$cust_config{$list_of_cust_ids[0]}= 'AB,AC,AF,GR,PR';
: Now.. When my code does it's work, this is the logic:
:
: foreach $cust (@list_of_cust_ids) {
: foreach $abrev (@array_of_abrev) {
: if (index($cust_config{$cust},$abrev) > -1) {
: #PROCESS THE DATA
: }
: }
: }
my %valid_abbreviation;
@valid_abbreviation{@array_of_abrev} = (1) x
@array_of_abrev;
foreach my $customer_id (@list_of_cust_ids) {
foreach my $abbreviation ( split /,/,
$cust_config{$customer_id} ) {
if ( $valid_abbreviation{$abbreviation} ) {
# proccess $abbreviation for $customer_id
} else {
# $abbreviation is invalid in $customer_id
}
}
}
HTH,
Charles K. Clarkson
Clarkson Energy Homes, Inc.
He who laughs last thinks slowest.
------------------------------
Date: 8 Nov 2001 08:48:46 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Dealing with Data::Dumper
Message-Id: <slrn9ukhoc.mup.rgarciasuarez@rafael.kazibao.net>
lvirden@cas.org wrote in comp.lang.perl.misc:
> I am seeing the following behavior:
>
> $ perl -e "use Data::Dumper"
> Data::Dumper object version 2.103 does not match $Data::Dumper::VERSION 2.12 at /volws/lwv26/ldatae/lib/perl5/5.7.2/sun4-solaris-stdio/XSLoader.pm line 97.
You're using bleadperl ? at your own risk... Data::Dumper 2.12 is in
bleadperl since 2001/10/31 but it's not on CPAN (yet). Check carefully
your settings.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: 08 Nov 2001 09:20:13 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: force stack dump after die
Message-Id: <slrn9ukjid.6t9.vek@pharmnl.ohout.pharmapartners.nl>
On 7 Nov 2001 13:30:10 -0800,
Reza Rob <google_news@linisoft.com> wrote:
>Can someone tell me how I can force a stack dump after each die command?
>Do I have to recompile perl 5.6.1?
There are some functions in Carp.pm which can give a stack backtrace
NAME
carp - warn of errors (from perspective of caller)
cluck - warn of errors with stack backtrace
(not exported by default)
croak - die of errors (from perspective of caller)
confess - die of errors with stack backtrace
SYNOPSIS
use Carp;
croak "We're outta here!";
use Carp qw(cluck);
cluck "This is how we got here!";
Villy
------------------------------
Date: 8 Nov 2001 02:07:53 -0800
From: msergeant@star.net.uk (Matt Sergeant)
Subject: Re: force stack dump after die
Message-Id: <eb3031b9.0111080207.557efbe4@posting.google.com>
google_news@linisoft.com (Reza Rob) wrote in message news:<af17817c.0111071330.7a54693f@posting.google.com>...
> Can someone tell me how I can force a stack dump after each die command?
> Do I have to recompile perl 5.6.1?
Use a $SIG{__DIE__} block to add the stack trace to the error, and
re-die. Something like:
$SIG{__DIE__} = sub {
local $SIG{__DIE__};
my $i = 1;
while(my @stack = caller($i++)) {
push @_, "From[$i]: $stack[1] line $stack[2]\n";
}
die @_;
}
Matt.
------------------------------
Date: 8 Nov 2001 00:05:08 -0800
From: au@id.ru (Alexander)
Subject: How to pass Perl objects into C++?
Message-Id: <fcb710ea.0111080005.1ac53ace@posting.google.com>
I create an interface to C++ library for Perl and need to pass Perl
objects as arguments into C++ methods. (To create C++ wrappers I use
SWIG)
Pretty easy I can pass C++defined objects into Perl and back, but how
can I access object which defined in Perl?
Actualy I need to pass "sockaddr" object to C++ likely it has the same
presentation in both languages, because it is a system structure.
------------------------------
Date: Thu, 08 Nov 2001 10:38:09 +0100
From: Tassilo von Parseval <tassilo.parseval@post.rwth-aachen.de>
Subject: Impossible to store tied hash (MLMDB) in an object?
Message-Id: <3BEA5281.3000105@post.rwth-aachen.de>
Hi,
I am having serious problems with storing a graph-like structure in a
tied hash which itself is attribute of a blessed reference (object, that
is). The basic problem is that the in-memory structure of the hash is ok
(according to Data::Dumper) but the hash is not written to the file.
Constructor:
sub new {
my ($class, %args) = @_;
if (! exists $args{dbfile}) {
croak <<EOC;
Lang::SemanticGraph->new needs a 'dbfile' argument to store the data:
dbfile => 'file'
EOC
}
my $self = bless {}, $class;
my %db_hash;
my $db = tie %db_hash, "MLDBM", $args{dbfile}
or croak <<EOC;
Error: Could not create $args{dbfile}: $!
EOC
$self->{db_hash} = { %db_hash };
$self->{db} = $db;
$self;
}
The following is a method to store a hypernym (a 'top term') along with
some hyponyms (the corresponding subordered terms) into a thus tied hash:
sub add_tuplet {
my ($self, %terms) = @_;
if (! exists $terms{hypernym}) {
carp "No Hypernym given";
return;
}
my %db = %{ $self->{db_hash} };
my $hyper = $terms{hypernym};
my @hypo = @{ $terms{hyponyms} };
# register $hyper as hypernym for each hyponym
for (@hypo) {
my $tmp = $db{$_};
push @{ $tmp->{hypernyms} }, $hyper for @hypo;
$db{$_} = $tmp;
$self->{db_hash} = { %db };
}
my $tmp = $db{$hyper};
if ($tmp) {
push @{ $tmp->{hyponyms} }, @hypo;
$db{$hyper} = $tmp;
$self->{db_hash} = { %db };
}
else {
$tmp->{hyponyms} = [ @hypo ];
$db{$hyper} = $tmp;
$self->{db_hash} = { %db };
}
}
I had already following the notes in the MLDBM manpage, that
$tied{1}{2} = "string";
would have to be written as
$tmp = $tied{1};
$tmp->{2} = "string";
$tied{1} = $tmp;
(makes it sort of a painful programming).
Does anyone have an idea why data, that I add to the tied hash via the
add_tuplets() method wont ever be written to the underlying DB_File?
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Thu, 8 Nov 2001 05:12:05 -0500
From: "Sarah Evan" <SEUSA2000@yahoo.com>
Subject: Need Help To Get Started
Message-Id: <9sdl1t$775$1@nntp9.atl.mindspring.net>
Where do get Perl's software to run on Windows 2000? I downloaded a source
code from www.perl.com but don't know how to make it work on Windows 2000. I
extracted the file but there is no install.exe or setup.exe. Must I have a
compiler like Visual C++ in order to use the software? Where can I get
instruction to use the Perl software on Windows? I understand that Perl is
an interpreted language not a compiled language like C/C++. Your help will
be appreciated, thanks in advance.
------------------------------
Date: Thu, 08 Nov 2001 10:10:00 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: Need Help To Get Started
Message-Id: <YRsG7.3579$Le.87185@sea-read.news.verio.net>
In article <9sdl1t$775$1@nntp9.atl.mindspring.net>,
Sarah Evan <SEUSA2000@yahoo.com> wrote:
>Where do get Perl's software to run on Windows 2000? I downloaded a source
>code from www.perl.com but don't know how to make it work on Windows 2000.
0) Forget about the sources
1) Go back to http://www.perl.com
2) Click on Downloads
3) Under "Binary Distributions", click on Win32
http://www.perl.com/pub/a/language/info/software.html#win32
4) Follow the links there to the ActiveState download page.
http://www.activestate.com/Products/ActivePerl/download.plex
5) Download the *.MSI file for Windows.
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Thu, 08 Nov 2001 11:08:17 +0100
From: Tassilo von Parseval <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Need Help To Get Started
Message-Id: <3BEA5991.8060106@post.rwth-aachen.de>
Sarah Evan wrote:
> Where do get Perl's software to run on Windows 2000? I downloaded a source
> code from www.perl.com but don't know how to make it work on Windows 2000. I
> extracted the file but there is no install.exe or setup.exe. Must I have a
> compiler like Visual C++ in order to use the software? Where can I get
> instruction to use the Perl software on Windows? I understand that Perl is
> an interpreted language not a compiled language like C/C++. Your help will
> be appreciated, thanks in advance.
There is a pre-built binary available for Win-systems somewhere at
http://www.activestate.com/ . Another one is Indigoperl
(http://www.indigostar.com/) that additionally comes with an apache
webserver.
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Thu, 08 Nov 2001 11:11:36 +0100
From: Edwin =?iso-8859-1?Q?G=FCnthner?= <edgue@web.de>
Subject: Re: Need Help To Get Started
Message-Id: <3BEA5A58.E70E4AD@web.de>
Hi Sarah,
just go to www.activestate.com and get their ActivePerl. I think
that is most suitable for beginners on Win.
> Where do get Perl's software to run on Windows 2000? I downloaded a source
> code from www.perl.com but don't know how to make it work on Windows 2000. I
> extracted the file but there is no install.exe or setup.exe. Must I have a
As you said - you downloaded the sources. If you download sources, you
need
to compile them. But normally it is much easier to download a binary
distribution - like the one from ActiveState.
If you really want to compile your own perl, you should download the
CYGWIN package (with tools like gcc, make and so on). But again - there
is no need to do so - if you just want to write perl scripts and execute
them. ActivePerl comes also with all the HTML documentation that is
useful for Perl, so check it out!
------------------------------
Date: Thu, 08 Nov 2001 07:40:10 GMT
From: "Geoff" <geoff@REMOVETHISgeoffball.net>
Subject: Re: passing array values from perl to javascript
Message-Id: <uFqG7.25419$5e2.4958623@news1.telusplanet.net>
"hugo" <hugo@fractalgraphics.com.au> wrote in message
news:3BE9E7EF.DC65BD88@fractalgraphics.com.au...
> Hi
>
> I am trying to pass an array with values from a perl to a javascript
> array, then open a new window which displays the javascript array
> values. I am reading in the perl array into the javascript array with
> print statements, and this seems to work well (when I look at thepage
> source). However, when I try to transfer the javascript array values to
> a new window, and display them, nothing happens. An alert statement
> attempting to display the [0] index value of the javascript array states
> that it is undefined.
>
> Here is my code:
>
> 1. First, in my perl code, I read fill in the javascript array with
> values from the perl array (@data is my perl array and jsinfile is my
> javascript array):
>
> print "<SCRIPT LANGUAGE=\"javascript\">";
> print "var jsinfile = new Array();";
> for ($i = 0; $i < @data; $i++) {
> chomp $data[$i];
> print "jsinfile[$i] = \"$data[$i]\"";
> }
> print "</SCRIPT>";
>
> Then I have a form with a button to view the new page, with an onClick
> statement, passing the jsinfile array to the function which opens the
> new page:
>
> print "<FORM METHOD=\"POST\" ENCTYPE=\"multipart/form-data\">";
> print "<p>View double-spaced file?";
> print "<INPUT TYPE=\"SUBMIT\" VALUE=\"View\"
> onClick=\"javascript:open_outfile1(jsinfile)\">";
> print "</FORM>";
>
This should probably be a button, not a submit [button]. That way, it won't
actually submit the form.
> Then I have the javascript function which is activated by onClick and
> opens the new window. The new window is opened but no jsinfile values
> are displayed in the page. Note that this function occurs earlier in the
> code (i.e. higher up), but that shouldn't matter. The window alert on
> the third line states that jsinfile is undefined.
I think you should just write the new page with a Perl script.
> print "<SCRIPT LANGUAGE=\"javascript\">";
> print "function open_outfile1(jsinfile) {";
> print "window.alert(\"jsinfile (in javascript function) is : \" +
> jsinfile[0]);";
> print "newWindow =
>
window.open('','newWin','toolbar=yes,location=yes,scrollbars=yes,resizable=y
es,width=500,height=500,');";
> print "newWindow.document.write(\"<html><head><title>Double spaced
> file<\/title><\/head><body bgcolor=#FFFFFF>\");";
> print "for (i =0; i < jsinfile.length; i++) {";
> print " newWindow.document.writeln(jsinfile[i]);";
> print " newWindow.document.writeln(\"<br>\");";
> print "}";
> print "newWindow.document.write(\"<\/body></\html>\");";
> print "newWindow.document.close();";
> print "}";
> print "</SCRIPT>";
>
> I think I may be doing something wrong in passing the value of jsinfile
> to the javascript function. Perhaps filling in values for jsinfile by
> printing it in the first window, does not make it follow that they can
> be transferred to another window? I am not very clear on that. If this
> is not the way to do it, how then do I open a new window and transfer
> array values from a perl array to the new window? Note that I do not
> want to do this with a FORM ACTION statement, as then my main window
> will be changed (not a new window opened).
>
> Any help will be greately appreciated.
>
> Thanks
>
> Hugo
>
> --
> Dr Hugo Bouckaert
> R&D Support Engineer, Fractal Graphics
> 57 Havelock Street, West Perth 6005
> Western Australia 6009
> Tel: +618 9211 6000 Fax: +618 9226 1299
> Email:hugo@fractalgraphics.com.au
> Web: http://www.fractalgraphics.com.au
As I said before, why use JavaScript? Why not just do everything with Perl?
Geoff
------------------------------
Date: 8 Nov 2001 00:51:48 -0800
From: xah@xahlee.org (Xah Lee)
Subject: Perl tool to grab websites
Message-Id: <7fe97cc4.0111080051.71a0c6f3@posting.google.com>
Dear all,
has anyone written a perl script that downloads a website with n
levels of link, given an url? That is, for the purpose of download a
website for online viewing.
I would write one, using LWP and probably HTML parser, but i think
someone must have already done it in one way or another.
(
btw, there are commercial software that does what i wanted, but i just
want a simple one. I recall one called webwhacker.
http://www.bluesquirrel.com/products/whacker/whacker.html
the Mac version of MS Internet Explorer 5.0 for Mac OS 9.x also does
it, but the saved file is binary and proprietary web archive file
(WAFF) that is not compatible from ie4 to ie5 and in general is
suspect. On IE 5 on Windows (PC) can save a single page as stand
alone, but does not save contents of links.
)
Xah
xah@xahlee.org
http://xahlee.org/PageTwo_dir/more.html
"The 3 characteristics of Perl programers: mundaneness, sloppiness,
and fatuousness."
------------------------------
Date: Thu, 8 Nov 2001 10:25:36 +0100
From: "Christian Winter" <thepoet@nexgo.de>
Subject: Re: Perl tool to grab websites
Message-Id: <9sditn$jhq$1@newsread2.nexgo.de>
"Xah Lee" <xah@xahlee.org> wrote:
> Dear all,
>
> has anyone written a perl script that downloads a website with n
> levels of link, given an url? That is, for the purpose of download a
> website for online viewing.
IMHO w3mir from CPAN archives does what you want.
http://theoryx5.uwinnipeg.ca/scripts/CPAN/authors/id/J/JA/JANL/w3mir-1.0.9.t
ar.gz
HTH
Christian
------------------------------
Date: Thu, 8 Nov 2001 07:46:50 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: playing WAV file on unix and windows?
Message-Id: <Xns91534F2A48962Laocooneudoramailcom@62.153.159.134>
> How do I play .wav file on both unix and windows?
>
> I'm not going to play a music, I just want to play simple and
> small(about 30k) wav file.
> It's ok if it sounds little different on another platform.
>
> Thanks for any help..
http://search.cpan.org/search?dist=Win32-Sound for Windows..
dunno bout unix~
------------------------------
Date: Thu, 08 Nov 2001 09:50:49 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: reg ex
Message-Id: <b2lkutco14g199unqvc87gimll8qb3f64a@4ax.com>
tez wrote:
> I have the following string
>
>my $test="www.vicnet.net.au check out this link www.vicnet.net.au it could
>be http://www.vicnet.net.au";;
>
>and a regex which follows:
>$test=~s/[^\/]www*\b/ http:\/\/www$1/gi;
That star doesn't look right. Neither does that $1 (there are no
parentheses).
>what i want to happen..is if it finds www i want it to add http:// in front
>of it.
>But..if http:// is already in front of www then don't do anything.
s<(https?://\S+)|(www\.)><$1 || "http://$2"/ge
The trick inthe above is first attempt to match anything you want to
skip, replacing it by itself, and try doing the normal match and
replacement in what's left.
It's likely possible to do something similar with negative lookbehind...
But I won't bother now. The optional "s" after "http" doesn't make it
easier.
--
Bart.
------------------------------
Date: Thu, 08 Nov 2001 10:17:28 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: reg ex
Message-Id: <YYsG7.3581$Le.87235@sea-read.news.verio.net>
In article <b2lkutco14g199unqvc87gimll8qb3f64a@4ax.com>,
Bart Lateur <bart.lateur@skynet.be> wrote:
> s<(https?://\S+)|(www\.)><$1 || "http://$2"/ge
^
s<(https?://\S+)|(www\.)><$1 || "http://$2">ge
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: 8 Nov 2001 09:01:17 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Simulating shell wildcards in perl
Message-Id: <slrn9ukifr.n1g.rgarciasuarez@rafael.kazibao.net>
Bernard Cosell wrote in comp.lang.perl.misc:
> I have an odd problem: my app wants to take a wildcard on the command
> line that Perl will evaluate [via =~], but it would be very nice if I
> could have the pattern *ONLY* implement shell wildcard [=glob]
> semantics.
Look at Regexp::Shellish on CPAN.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
Could Marconi have invented the radio if he hadn't by pure chance
spent years working at the problem? -- Monty Python, Penguins
------------------------------
Date: 8 Nov 2001 02:44:12 -0800
From: markus.cl@gmx.de (Markus Dehmann)
Subject: Store an object reference as hash key?
Message-Id: <c1e48b51.0111080244.5684d7be@posting.google.com>
Can I store a reference to a whole object as hash key?
I tried this code but it didn't work:
use Test;
my $t = Test->new();
$t->setValue("abc");
my $hash{ \$t } = 1;
foreach( keys %hash ){
my $a = $$_;
print $a->getValue(); # should say abc
}
Is there a possibility to do sth like that?
------------------------------
Date: 08 Nov 2001 09:28:29 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: too late for -T?
Message-Id: <slrn9ukk1t.6t9.vek@pharmnl.ohout.pharmapartners.nl>
On Thu, 08 Nov 2001 01:47:13 GMT,
Joe Smith <inwap@best.com> wrote:
>In article <9s90mk$lma$1@pheidippides.axion.bt.co.uk>,
>Kevin Brownhill <kevinbrownhill@yahoo.com> wrote:
>>Have you got a space between !# -and- /usr/bin/perl
>
>That is irrelevant. The kernel ignores spaces in that position.
>
>I believe the problem is this:
>
> unix% chmod +x temp.pl
> unix% perl temp.pl
> Too late for "-T" option at temp.pl line 1.
> unix% ./temp.pl
> OK
> unix% perl -T temp.pl
> OK
>
>The solution is to use "./temp.pl" or "$PWD/temp.pl" instead of
>manually invoking perl.
That works on unix only because the kernel will invoke the script as
xxxx/perl -T temp.pl, or whatever the kernel finds in the #! line.
Thus perl gets the -T option on initial invokation, which is the latest
point in time you can specify the -T option. When perl itself reads
the #! line it may find arguments that wasn't specified on initial
invokation; these will take effect, except it is now too late to enable
the taint option if it wasn't already enabled on initial invokation.
Villy
------------------------------
Date: Thu, 08 Nov 2001 08:32:51 GMT
From: "Kirst Hulspas" <google@psc-it.nl>
Subject: unexpected behaviour behind a protecte directory
Message-Id: <TqrG7.719$rW6.43@castor.casema.net>
A perl-script I'm using works fine for what it is designed to.
After POST-ing it returns a recap that can be approved or not.
If I use the 'back button' (or backspace key) to review my input,
it returns the original values in the filled-in form fields. So far so good.
However, if the same html-page is submitted behind a password protected
directory, the back-button returns an *empty* form, with all fields reset to
blank.
This behaviour applies to the browsers IE5, NS and Mozilla but *not* to
Konqueror. The webserver is a linux WN-server 2.2.9, using authwn as
authorisation module for the protected directories.
I have a feeling this behaviour is not directly caused by perl or the
browser. The ISP does not want to answer to this case as it concerns a
cgi-script they did not devellop themselves.
Has anyone got a clou on the origin of this behaviour and/or a work-around??
Thanks.
------------------------------
Date: Thu, 8 Nov 2001 18:23:10 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: unexpected behaviour behind a protecte directory
Message-Id: <PIrG7.2$KH6.128@vicpull1.telstra.net>
"Kirst Hulspas" <google@psc-it.nl> wrote in message
news:TqrG7.719$rW6.43@castor.casema.net...
> A perl-script I'm using works fine for what it is designed to.
> After POST-ing it returns a recap that can be approved or not.
> If I use the 'back button' (or backspace key) to review my input,
> it returns the original values in the filled-in form fields. So far so
good.
> However, if the same html-page is submitted behind a password protected
> directory, the back-button returns an *empty* form, with all fields reset
to
> blank.
>
> This behaviour applies to the browsers IE5, NS and Mozilla but *not* to
> Konqueror. The webserver is a linux WN-server 2.2.9, using authwn as
> authorisation module for the protected directories.
>
> I have a feeling this behaviour is not directly caused by perl or the
> browser. The ISP does not want to answer to this case as it concerns a
> cgi-script they did not devellop themselves.
> Has anyone got a clou on the origin of this behaviour and/or a
work-around??
This is known behaviour of the script you are using. Have you checked the
web site? BTW as I said last time, not very well written scripts...
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: Thu, 08 Nov 2001 10:00:17 +0100
From: Edwin =?iso-8859-1?Q?G=FCnthner?= <edgue@web.de>
Subject: Re: URGENT! Please help me with this!
Message-Id: <3BEA49A1.8AF3676C@web.de>
Hello Marianne,
Marianne Sisto wrote:
>
> Hey thats not very fair, I have spent hours working on this thing, I've been
> up all night doing it night after night and am getting no little to no from
> my school, I have written all the code myself and I only wanted a little
> advice from more experienced programmers. If this is 'pushing the limits'
> then its a very unfriendly place. I wont post here again dont worry.
That's not necessary. Simply take a break and take same time to get
used the Usenet, its rules and its culture.
Those rules might appear strange in the beginning, but have proven
to be very useful over years.
First of all: the subject of your posting should tell us about the
nature of your problem. Your subject didnt contain any information
related to the problem. A lot of people will simply skip your posting
because of this!
But you want people to read your posting - because that is the only way
to get answers, isnt it?
Next is: people in such groups tend to be geeks. They are interested
in your problem (maybe it is a really difficult one, then they
will have fun answering it). They are not interested in the
fact that it is your homework (or a job taks, or whatever).
Thats strange and you need to get used to it - but thats the way it
works. Of course you can include the information that you
need answers quick for some reasons - but do not expect other
people to simply adapt YOUR priorities.
I am using Usenet for years now. In my opinion it is one
of the best ways to retrieve information about any kind of
problem. But it takes some time to understand its rules.
Please take the time to LEARN how to use Usenet - I am sure
you will never regret it.
regards.
edwin günthner
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
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 2091
***************************************