[22922] in Perl-Users-Digest
Perl-Users Digest, Issue: 5142 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 26 18:06:12 2003
Date: Thu, 26 Jun 2003 15:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 26 Jun 2003 Volume: 10 Number: 5142
Today's topics:
Re: Array dereferencing <krahnj@acm.org>
Re: Array dereferencing (Jay Tilton)
Re: Execute shell script from a perl script (Andres Monroy-Hernandez)
Re: how to convert all invalid UTF-8 sequences to numer (Shambo)
Re: how to convert all invalid UTF-8 sequences to numer <flavell@mail.cern.ch>
HTML::TableExtract Simple question (Avatar)
Re: HTML::TableExtract Simple question <asu1@c-o-r-n-e-l-l.edu>
Installing CtCmd on Windows (Sherman Willden)
Re: Installing CtCmd on Windows <ndronen@io.frii.com>
Re: Offer tips, comments on this code (generates html t <spamblock@junkmail.com>
Re: Offer tips, comments on this code (generates html t <spamblock@junkmail.com>
Re: Offer tips, comments on this code (generates html t <asu1@c-o-r-n-e-l-l.edu>
Re: Offer tips, comments on this code (generates html t <glex_nospam@qwest.net>
Re: PERL - problems with use <matthew@weierophinney.net>
Re: PERL - problems with use <usenet@dwall.fastmail.fm>
perl code to test my C based CGI application (chris)
Re: perl code to test my C based CGI application <usenet@dwall.fastmail.fm>
PGP decrypt perl script (Mike)
Re: problem when use debug perl in win2000 os <brian_helterline@hp.com>
Q: "my" variables and "no strict 'refs'" (Daniel Friedman)
Re: Q: "my" variables and "no strict 'refs'" <emschwar@pobox.com>
Re: Q: "my" variables and "no strict 'refs'" <noreply@gunnar.cc>
simple way to test for undef <abc@nowhere.com>
Re: simple way to test for undef <krahnj@acm.org>
Re: stopping PPM3 connecting to internet for LOCAL inst (JW)
Re: why this doesn't work (tm)? :) <ndronen@io.frii.com>
Re: Write line at beginning of file? (Eric Pement)
Re: Write to a filehandle and to STDOUT without double <usenet@dwall.fastmail.fm>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 26 Jun 2003 21:09:26 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Array dereferencing
Message-Id: <3EFB610F.A0792F63@acm.org>
Jan Fure wrote:
>
> Given data of the form:
>
> 1 2 4
> 1 2 5
> 1 3 4.5
> 2 2 6
> 2 3 7
>
> How can I order it like:
> ([1,(2 2 3), (4 5 4.5)], [2, (2 3), (6 7)])
>
> In verbal form, I want to group the values from columns 2 to n by
> those corresponding to the same value in column 1, for further
> processing for the purpose of finding mean, median, standard deviation
> etc.
>
> The ultimate goal is to get an output file like:
>
> 1 2.333 4.5
> 2 2.5 6.5
Here is one way to do it:
#!/usr/bin/perl
use warnings;
use strict;
my %data;
my @keys;
while ( <DATA> ) {
my ( $key, @data ) = split;
push @keys, $key unless exists $data{ $key };
push @{ $data{ $key }[ $_ ] }, $data[ $_ ] for 0 .. $#data;
}
for my $key ( @keys ) {
print $key;
for my $array ( @{ $data{ $key } } ) {
my $sum;
$sum += $_ for @$array;
( my $avg = $sum / @$array ) =~ s/(\.\d{3})\d+/$1/;
print " $avg";
}
print "\n";
}
__DATA__
1 2 4
1 2 5
1 3 4.5
2 2 6
2 3 7
John
--
use Perl;
program
fulfillment
------------------------------
Date: Thu, 26 Jun 2003 22:05:52 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Array dereferencing
Message-Id: <3efb6cf3.424152641@news.erols.com>
jan_may2002_fure@attbi.com (Jan Fure) wrote:
: Given data of the form:
:
: 1 2 4
: 1 2 5
: 1 3 4.5
: 2 2 6
: 2 3 7
:
: How can I order it like:
: ([1,(2 2 3), (4 5 4.5)], [2, (2 3), (6 7)])
Or, written in Perl, like:
([1, [2, 2, 3], [4, 5, 4.5]], [2, [2, 3], [6, 7]])
#!perl
use warnings;
use strict;
my @DATA2 = (
[1, 2, 4 ],
[1, 2, 5 ],
[1, 3, 4.5 ],
[2, 2, 6 ],
[2, 3, 7 ],
);
my %data;
for( @DATA2 ){
my( $id, @numbers ) = @$_;
for(0..$#numbers) {
push @{ $data{$id}[$_] }, $numbers[$_]
}
}
my @points = map [$_, @{$data{$_}} ], sort {$a <=> $b} keys %data;
: The ultimate goal is to get an output file like:
:
: 1 2.333 4.5
: 2 2.5 6.5
use List::Util qw(sum);
for( @points ) {
my( $id, @series ) = @$_;
local($, , $\) = (' ', "\n");
print $id, map sum(@$_)/@$_, @series;
}
Clear as mud, eh?
------------------------------
Date: 26 Jun 2003 13:26:47 -0700
From: andres@monroy.com (Andres Monroy-Hernandez)
Subject: Re: Execute shell script from a perl script
Message-Id: <3591b31a.0306261226.243699e0@posting.google.com>
"kderaedt" <kderaedt@hotmail.com> wrote in message news:<3efafb0e$0$1064$ba620e4c@reader1.news.skynet.be>...
> Hi,
>
> How can I executed a Unix shell script from a Perl script.
> The shell script is a dump of a oracle table to a file. The perl script is
> for the reformat of this output file.
>
> Thanks
>
> Karel
Hi Karel,
you can try using a system, exec or backticks.
Here is the documentation for those:
http://www.perldoc.com/perl5.6/pod/func/system.html
http://www.perldoc.com/perl5.6/pod/perlop.html#
Hope that helps.
Regards,
-Andres Monroy-Hernandez
------------------------------
Date: 26 Jun 2003 12:53:54 -0700
From: shambo_p@yahoo.com (Shambo)
Subject: Re: how to convert all invalid UTF-8 sequences to numeric equivalent?
Message-Id: <72190192.0306261153.58ef3571@posting.google.com>
File disciplines, encode_utf8 and Encode::String functions don't seem
to work. They will simply remove any character they don't like, or
replace it with a question mark.
The reason I asked about numeric equivalents (£) is 'cause the
character gets properly represented when viewed in a web browser, and
the XML validates.
After MUCH education about character sets, encoding and modules, I see
why my preivous post could be a confusing.
Still, the problem remains. I need to preserve these characters
somehow.
many thanks for your help.
-S
------------------------------
Date: Thu, 26 Jun 2003 23:10:02 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: how to convert all invalid UTF-8 sequences to numeric equivalent?
Message-Id: <Pine.LNX.4.53.0306262308110.10535@lxplus087.cern.ch>
On Thu, Jun 26, Shambo inscribed on the eternal scroll:
> File disciplines, encode_utf8 and Encode::String functions don't seem
> to work.
That doesn't get us anywhere. Sure they work.
> They will simply remove any character they don't like, or
> replace it with a question mark.
Where's your simple test script to demonstrate that assertion?
> The reason I asked about numeric equivalents (£) is 'cause the
> character gets properly represented when viewed in a web browser, and
> the XML validates.
Sure, but the reason I didn't encourage you to follow that approach
and only that approach, was that you've given no clear idea of what
material you're going to be dealing with, and that could be a very
inefficient representation, even though, as you imply (and as my
character coding checklist points out), it's the safest way for people
who don't really understand what they're doing.
> Still, the problem remains. I need to preserve these characters
> somehow.
Isn't that what we've been working at all this time?
You don't need me to tell you that you can concatenate a & with a #
with ord($_) with a ; - that's elementary stuff. But if you didn't
tell Perl what you were reading-in in the first place (maybe it's
sometimes iso-8859-2, or koi8-r, we just don't know because you're
keeping us guessing) then you'll get the wrong answer. And if you
_do_ tell Perl correctly what you got, there should be no problem with
outputting utf-8 if that's what you wanted.
So do you want to make any progress with this or not?
> many thanks for your help.
You don't seem to have used much of it yet, but I'm hopeful that it
might be of some use to the occasional lurkers anyway.
------------------------------
Date: 26 Jun 2003 13:27:23 -0700
From: ksu1wd@mit.edu (Avatar)
Subject: HTML::TableExtract Simple question
Message-Id: <415d5171.0306261227.3f0fa317@posting.google.com>
I am trying to use the module HTML::TableExtract with little success,
here is what I have tried so far.
use HTML::TableExtract;
$te= new HTML::TableExtract( headers => [qw(One Two Three)] );
$te->parse($html_string);
Now what to put into that html string.
Here is what I have tried to do.
I have html saved in a text file. So I read from the text file, in an
attempt to put all of the html into the string $html_string, using
open(FILEHANDLE,"<file.txt");
text="";
while (read (FILEHANDLE, $newtext, 1)){
$text.=$newtext;
}
So this effectively puts all of the html into the scalar html_string.
But when I put it into $html_string and run it, nothing appears to
happen, where it's supposed to print I think the stuff with headers
one, two, three.
Then I jsut plain tried cut and copying the text like
parse(<HTML>....<\HTML>) but that also failed. So to sum up, the
question I am asking is what should go in the scalar $html_string.
------------------------------
Date: 26 Jun 2003 21:31:47 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: HTML::TableExtract Simple question
Message-Id: <Xns93A6B2544BC7Dasu1cornelledu@132.236.56.8>
ksu1wd@mit.edu (Avatar) wrote in news:415d5171.0306261227.3f0fa317
@posting.google.com:
> I am trying to use the module HTML::TableExtract with little success,
> here is what I have tried so far.
> use HTML::TableExtract;
>
> $te= new HTML::TableExtract( headers => [qw(One Two Three)] );
> $te->parse($html_string);
> Now what to put into that html string.
> Here is what I have tried to do.
> I have html saved in a text file. So I read from the text file, in an
> attempt to put all of the html into the string $html_string, using
>
> open(FILEHANDLE,"<file.txt");
> text="";
> while (read (FILEHANDLE, $newtext, 1)){
> $text.=$newtext;
> }
> So this effectively puts all of the html into the scalar html_string.
I do not think you need to do that. Since HTML::TableExtract inherits
parse from HTML::Parser, you can parse one chunk at a time. The following
seems to work for me:
#! C:/Perl/bin/perl.exe -w
use strict;
use warnings;
use HTML::TableExtract;
open(HTML, "< test.htm") || die 'Cannot open test.htm';
my $te = new HTML::TableExtract( headers => [qw(Age Schooling)] );
while(<HTML>) {
$te->parse($_);
}
close(HTML);
foreach my $row ($te->rows()) {
print join("\t", @$row), "\n";
}
You can find a copy of the test.htm I used for this example at
http://www.unur.com/comp/table/test.htm (I first tried getting the file
contents via LWP::Simple as a learning exercise). Anyway, running the
script above on the file available at that url gives the following
output:
C:\WWW\work>table2.pl
8 1
10 7
6 3
0 0
11 5
16 12
7 0
9 6
14 3
15 14
1 1
11 5
19 8
5 2
15 2
6 3
1 0
HTH.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: 26 Jun 2003 13:08:01 -0700
From: sherman.willden@hp.com (Sherman Willden)
Subject: Installing CtCmd on Windows
Message-Id: <3a80d8d6.0306261208.59c6336a@posting.google.com>
What are cl and dumpbin?
I am trying to configure CtCmd and I was reading the INSTALL document
before proceeding. It stated that I must be able to perform cl and
dumpbin from the command line before proceeding. What products are cl
and dumpbin contained in?
Thanks;
Sherman
------------------------------
Date: 26 Jun 2003 20:28:08 GMT
From: Nicholas Dronen <ndronen@io.frii.com>
Subject: Re: Installing CtCmd on Windows
Message-Id: <3efb5758$0$201$75868355@news.frii.net>
Sherman Willden <sherman.willden@hp.com> wrote:
SW> What are cl and dumpbin?
SW> I am trying to configure CtCmd and I was reading the INSTALL document
SW> before proceeding. It stated that I must be able to perform cl and
SW> dumpbin from the command line before proceeding. What products are cl
SW> and dumpbin contained in?
Dumpbin is part of Microsoft Visual Studio. Cl probably is, too.
Regards,
Nicholas
--
"Why shouldn't I top-post?" http://www.aglami.com/tpfaq.html
"Meanings are another story." http://www.ifas.org/wa/glossolalia.html
------------------------------
Date: Thu, 26 Jun 2003 13:59:36 -0700
From: "David Oswald" <spamblock@junkmail.com>
Subject: Re: Offer tips, comments on this code (generates html to index image files)
Message-Id: <vfmntg9h3qou76@corp.supernews.com>
I cleaned it up and perlized it considerably, and used here docs. But
somehow I broke it and can't figure out how to fix it. I apologize for the
minimal tabs. Something about how outlook interprets the tabs that exist in
the source. They're more generous irl. Here's what I've created:
_________________________
#!/usr/bin/perl -w
#imgdir2html.pl v1.02 (c)David Oswald
# The purpose of this script is to parse a single directory, read in all
# *.jpg, *.tif, *.jpeg, *.tiff, *.bmp, and *.gif filename, and output an
HTML
# page to index those files. Links will create popup windows for each
image.
# The output html file will list the images in alpha/perl order.
# Known limitations:
# Command line arguments are ignored for now.
# Only works in current directory unless $dirname is modified prior to
runtime.
# Entire directory is read in at once and manipulated as a list. Memory-
# sensitive code would read and process one directory item at a time.
# The simple way to customize this script is to modify the declarations.
use strict;
# --- Declarations ---
my $outfile ="index.html"; # Html file's name.
my @imagefiles;
my $dirname = "./"; # Input directory.
my $htmltitle ="Picture List"; # Html <title> and
# first line <h1> caption.
my $scriptver = "imgdir2html.pl v1.03";
# --- Main body ---
if (@imagefiles = getdir($dirname)) {
open_html_file($outfile);
print_head($htmltitle); #print the html header.
print_links(@imagefiles); #print the body links.
print_foot; #print the terminating tags.
close_html_file;
} else {
print "Exiting: Current directory is empty.\n";
}
# --- End main body ---
# --- Subroutine definitions ---
#Open the current directory and get all image filenames into a list.
sub getdir {
my ($dir)=@_;
opendir (CURRENTDIR, $dir)
|| die "Error: Unable to open directory: $dir \n $!";
my @entries = grep /\.(jpe?g|tiff?|bmp|gif)$/i, readdir(CURRENTDIR);
closedir(CURRENTDIR);
return sort(@entries);
}
#Opens (@_) as file HTML for output.
sub open_html_file {
my ($filename) = @_;
if (-e $filename) {
print "Warning: $filename already exists. Overwrite? (y/n) ";
unless (<STDIN> =~ /^y/i) {
exit;
}
}
open (HTML, ">$filename") || die "Error: Unable to open $filename for
output.\n $!";
return;
}
#Prints the html header to outfile.
sub print_head {
my ($title) = @_; #$title becomes <title> and <h1> headline.
print HTML <<HTML_BLOCK;
<html>
<head>
<title>$title</title>
</head>
<body>
<h1>$title</h1>
<hr>
<p>
Click on any link to open image in a separate window.
By opening an image in its own window, you can print
or easily save individual images.
</p>
<hr>
HTML_BLOCK
return;
}
#Prints <img src> and <a href> tag for each image.
sub print_links {
my @filelist = @_;
foreach (@filelist) {
print HTML <<HTML_BLOCK;
<p>
<img src = \"$_\" alt=$_ >
<a href = \"$_\" target = \"ImageWindow\" >
<br> $_ </a>
</p>
HTML_BLOCK
}
return;
}
#Prints an html footer; the "closing" stuff.
sub print_foot {
print HTML <<HTML_BLOCK;
<hr>
Page created by $scriptver .
<br>
</body>
</html>
HTML_BLOCK
return;
}
sub close_html_file { #Closes the html outfile.
close(HTML) || die "Error: Unable to close $filename after output.\n $!";
return;
}
-------------------------
And here's what errors I get when I now try to run it:
> imgdir2html.pl
Bareword "print_foot" not allowed while "strict subs" in use at
/home/pacifier..
Global symbol "$filename" requires explicit package name at
/home/pacifier.com/.
Bareword "close_html_file" not allowed while "strict subs" in use at
/home/paci.
Execution of /home/pacifier.com/d/da/davido.pacifier.com/pl/imgdir2html.pl
abor.
I think that the issue is that my here documents are somehow not being
terminated properly, resulting in subs not being defined. ...could that be?
Dave
----- Original Message -----
From: "Janek Schleicher" <bigj@kamelfreund.de>
Newsgroups: comp.lang.perl.misc
Sent: Thursday, June 26, 2003 4:09 AM
Subject: Re: Offer tips, comments on this code (generates html to index
image files)
------------------------------
Date: Thu, 26 Jun 2003 14:45:51 -0700
From: "David Oswald" <spamblock@junkmail.com>
Subject: Re: Offer tips, comments on this code (generates html to index image files)
Message-Id: <vfmqkhnh6eumf1@corp.supernews.com>
Thanks to all for the input. Now that I've got it working again, and now
that it passes both "-w" and "use strict;", I'd like to hear comments again
from a style, efficiency, and lexicon standpoint: How can the existing code
be improved upon retaining equal functionality? In other words, I'm not
looking for how to add features. I'm looking at critiquing the script
holding its given featureset constant.
Here it is again:
______________________________________________
#!/usr/bin/perl -w
#imgdir2html.pl v1.03 (c)David Oswald
# The purpose of this script is to parse a single directory, read in all
# *.jpg, *.tif, *.jpeg, *.tiff, *.bmp, and *.gif filename, and output an
HTML
# page to index those files. Links will create popup windows for each
image.
# The output html file will list the images in alpha/perl order.
# Known limitations:
# Command line arguments are ignored for now.
# Only works in current directory unless $dirname is modified prior to
runtime.
# Entire directory is read in at once and manipulated as a list. Memory-
# sensitive code would read and process one directory item at a time.
# The simple way to customize this script is to modify the declarations.
use strict;
# --- Declarations ---
my $outfile ="index.html"; # Html file's name.
my @imagefiles;
my $dirname = "./"; # Input directory.
my $htmltitle ="Picture List"; # Html <title> and
# first line <h1> caption.
my $scriptver = "imgdir2html.pl v1.03";
# --- Main body ---
if (@imagefiles = getdir($dirname)) {
open_html_file($outfile);
print_head($htmltitle); #print the html header.
print_links(@imagefiles); #print the body links.
print_foot(); #print the terminating tags.
close_html_file();
} else {
print "Exiting: Current directory is empty.\n";
}
# --- End main body ---
# --- Subroutine definitions ---
#Open the current directory and get all image filenames into a list.
sub getdir {
my ($dir)=@_;
opendir (CURRENTDIR, $dir)
|| die "Error: Unable to open directory: $dir \n $!";
my @entries = grep /\.(jpe?g|tiff?|bmp|gif)$/i, readdir(CURRENTDIR);
closedir(CURRENTDIR);
return sort(@entries);
}
#Opens (@_) as file HTML for output.
sub open_html_file {
my ($ourfile) = @_;
if (-e $ourfile) {
print "Warning: $ourfile already exists. Overwrite? (y/n) ";
unless (<STDIN> =~ /^y/i) {
exit;
}
}
open (HTML, ">$ourfile") || die "Error: Unable to open $ourfile for
output.\n $!";
return;
}
#Prints the html header to outfile.
sub print_head {
my ($title) = @_; #$title becomes <title> and <h1> headline.
print HTML <<HTML_BLOCK;
<html>
<head>
<title>$title</title>
</head>
<body>
<h1>$title</h1>
<hr>
<p>
Click on any link to open image in a separate window.
By opening an image in its own window, you can print
or easily save individual images.
</p>
<hr>
HTML_BLOCK
return;
}
#Prints <img src> and <a href> tag for each image.
sub print_links {
my @filelist = @_;
foreach $_ (@filelist) {
print HTML <<HTML_BLOCK;
<p>
<img src = \"$_\" alt=$_ >
<a href = \"$_\" target = \"ImageWindow\" >
<br> $_ </a>
</p>
HTML_BLOCK
}
return;
}
#Prints an html footer; the "closing" stuff.
sub print_foot {
print HTML <<HTML_BLOCK;
<hr>
Page created by $scriptver .
<br>
</body>
</html>
HTML_BLOCK
return;
}
sub close_html_file { #Closes the html outfile.
close(HTML) || die "Error: Unable to close output file.\n $!";
return;
}
______________________
Again I apologize for the way Outlook interprets tabs as being one space
each. Duh. Anyway, the actual code IRL is properly tabbed.
Dave
------------------------------
Date: 26 Jun 2003 21:58:55 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Offer tips, comments on this code (generates html to index image files)
Message-Id: <Xns93A6B6EDB993Casu1cornelledu@132.236.56.8>
"David Oswald" <spamblock@junkmail.com> wrote in
news:vfmqkhnh6eumf1@corp.supernews.com:
> Thanks to all for the input. Now that I've got it working again, and
> now that it passes both "-w" and "use strict;", I'd like to hear
> comments again from a style, efficiency, and lexicon standpoint: How
> can the existing code be improved upon retaining equal functionality?
> In other words, I'm not looking for how to add features. I'm looking
> at critiquing the script holding its given featureset constant.
I am not sure if this would be considered adding features, but when I was
working on a similar script, I found HTML::Template to be very useful. It
made it unnecessary to mix code with HTML generation.
If you would like to look at its usage, you can find the source code for my
script at http://www.unur.com/comp/photobrowser/index.html.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Thu, 26 Jun 2003 16:29:34 -0500
From: "J. Gleixner" <glex_nospam@qwest.net>
Subject: Re: Offer tips, comments on this code (generates html to index image files)
Message-Id: <EAJKa.62$j4.52472@news.uswest.net>
> And here's what errors I get when I now try to run it:
>
>
>>imgdir2html.pl
>
> Bareword "print_foot" not allowed while "strict subs" in use at
> /home/pacifier..
> Global symbol "$filename" requires explicit package name at
> /home/pacifier.com/.
> Bareword "close_html_file" not allowed while "strict subs" in use at
> /home/paci.
> Execution of /home/pacifier.com/d/da/davido.pacifier.com/pl/imgdir2html.pl
> abor.
>
>
> I think that the issue is that my here documents are somehow not being
> terminated properly, resulting in subs not being defined. ...could that be?
Ahhh. no.. These are the things that 'use strict' reports.
print_foot is defined later in your program as a subroutine. In those
cases, tell Perl it's a subroutine by doing:
print_foot()
Or move your subroutines around so they're all listed before they're
actually called.
Same with close_html_file
close_html_file()
$filename should be passed to close_html_file() just like you do for
open_html_file().
------------------------------
Date: Thu, 26 Jun 2003 18:12:09 GMT
From: Matthew Weier O'Phinney <matthew@weierophinney.net>
Subject: Re: PERL - problems with use
Message-Id: <ZHGKa.38817$1n.26174@twister.nyroc.rr.com>
* Alan Vowles <alan.vowles@virgin.net>:
> I have written a simple PERL script for use with my website, and even
> through the script runs perfectly on my own computer using the Apache
> webserving software, i am having problems making the script online.
>
> The server i am using does support the use of PERL and i have even double
> checked the path to PERL for the '#!' line. The server simply produces an
> "Access Denied - You are not allowed to view this page" error.
This isn't a problem with perl; it's a problem with the web server
and/or where and how you have placed the file.
Check the permissions for the script (needs to be executable by the web
server), and that you have configured apache (either through httpd.conf
or an .htaccess file) to allow the script to execute at the location
(via a "+ExecCGI" reference for that directory).
--
Matthew Weier O'Phinney
http://weierophinney.net/matthew/
------------------------------
Date: Thu, 26 Jun 2003 18:22:01 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: PERL - problems with use
Message-Id: <Xns93A692245E7AFdkwwashere@216.168.3.30>
Alan Vowles <alan.vowles@virgin.net> wrote:
> I have written a simple PERL script for use with my website, and
> even through the script runs perfectly on my own computer using
> the Apache webserving software, i am having problems making the
> script online.
>
> The server i am using does support the use of PERL and i have even
> double checked the path to PERL for the '#!' line. The server
> simply produces an "Access Denied - You are not allowed to view
> this page" error.
>
> Can anyone help?
It's not a problem with Perl.
You'd be more likely to get help in a group devoted to the web server
software you're using. Try one of the comp.infosystems.www.servers.*
groups.
However, it wouldn't hurt to check the permissions on the script, the
directory it's in, and how the server is configured to handle documents
in that directory.
------------------------------
Date: 26 Jun 2003 12:47:07 -0700
From: od488gw02@sneakemail.com (chris)
Subject: perl code to test my C based CGI application
Message-Id: <c452700a.0306261147.24e810c7@posting.google.com>
Already tried cgi newsgroup to no avail.
I'm a Perl begginner, and it's starting to look like Perl is the best
way to do this. I have a C based CGI executable that receives a single
arguement via HTTP POST method as follows:
<form method="POST" action="http://mypc-01/scripts/MyCGI.exe"
name="postToCGI">
I'd like to load test it by creating a Perl script that simply calls
it with same argument over and over and over. How can I do this?
thanks.
chris
------------------------------
Date: Thu, 26 Jun 2003 19:53:15 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: perl code to test my C based CGI application
Message-Id: <Xns93A6A19DE6D90dkwwashere@216.168.3.30>
chris <od488gw02@sneakemail.com> wrote:
[a CGI program written in C]
> I'd like to load test it by creating a Perl script that simply
> calls it with same argument over and over and over. How can I do
> this?
See
perldoc lwpcook
It has examples that should get you started.
------------------------------
Date: 26 Jun 2003 14:35:49 -0700
From: mgraham1@wellcarehmo.com (Mike)
Subject: PGP decrypt perl script
Message-Id: <868e7884.0306261335.5dc410e2@posting.google.com>
Hello. I am in need of direction on where I might find a perl script
that will automatically decrypt pgp files that have been FTP'd to a
server.
Any help would be appreciated. I am new to perl and have had no luck
trying to create it on my own.
------------------------------
Date: Thu, 26 Jun 2003 13:47:25 -0700
From: "Brian Helterline" <brian_helterline@hp.com>
Subject: Re: problem when use debug perl in win2000 os
Message-Id: <3efb609c$1@usenet01.boi.hp.com>
"Bob Heye" <heye@v2tech.com> wrote in message
news:bde59v$1ros$1@mail.cn99.com...
> Hi,all
> I have such a problem, someone can help me?
>
> When I debug a program written in perl using "perl -d foo.pl"
> The following message show up:
> ================================
> Unable to connect to remote host: 127.0.0.1:2000
> Compilation failed in require.
> main::BEGIN() called at D:/Perl/5.8.0/lib/perl5db.pl line 0
> eval {...} called at D:/Perl/5.8.0/lib/perl5db.pl line 0
> BEGIN failed--compilation aborted.
> ================================
> My OS is win2000, and the perl version is 5.8.0.
> If I don't debug it, just run it ( perl foo.pl), everything is fine.
>
> Any comments will be appreciated.
> Regrads
>
> BobH
>
Make sure that you don't have the PERLDB_OPTS environment variable
configured to use remote debugging.
This same problem bit me also. If I remember correctly it was after I
installed a trial version of Visual Perl (or ASPEN perl) and then removed
it. This variable was left behind....
-brian
------------------------------
Date: 26 Jun 2003 13:22:55 -0700
From: danielf@erols.com (Daniel Friedman)
Subject: Q: "my" variables and "no strict 'refs'"
Message-Id: <68cdce23.0306261222.7a4fc7a7@posting.google.com>
The bottom of p.594 in the Camel book (3rd edition) says this:
no strict 'refs';
$name = "variable";
$$name = 7 ; # Sets $variable to 7
...but I don't obtain that if I declare the variables with "my".
Here's my code:
no strict 'refs';
my ($variable, $name);
$variable = 1;
$name = "variable";
$$name = 7; # should set $variable to 7
print "\$variable is $variable\n";
... and this prints for me:
$variable = 1
I've found the code works fine if I don't declare the variables (with
the "my" line). What am I not understanding here?
(I'm using Perl 5.6.0 on RH7.2, in case it makes a difference.)
Thanks very much,
--daniel
------------------------------
Date: 26 Jun 2003 14:33:07 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Q: "my" variables and "no strict 'refs'"
Message-Id: <eton0g4pojg.fsf@wormtongue.emschwar>
danielf@erols.com (Daniel Friedman) writes:
> The bottom of p.594 in the Camel book (3rd edition) says this:
>
> no strict 'refs';
> $name = "variable";
> $$name = 7 ; # Sets $variable to 7
Don't do that.
See <http://perl.plover.com/varvarname.html> for reasons why.
> ...but I don't obtain that if I declare the variables with "my".
Yes, that's correct.
perldoc -q "How can I use a variable as a variable name?"
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Thu, 26 Jun 2003 22:44:10 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Q: "my" variables and "no strict 'refs'"
Message-Id: <bdfluk$sj5on$1@ID-184292.news.dfncis.de>
Daniel Friedman wrote:
> The bottom of p.594 in the Camel book (3rd edition) says this:
>
> no strict 'refs';
> $name = "variable";
> $$name = 7 ; # Sets $variable to 7
>
> ...but I don't obtain that if I declare the variables with "my".
Good, because you shouldn't.
<snip>
> I've found the code works fine if I don't declare the variables
> (with the "my" line). What am I not understanding here?
http://www.perldoc.com/perl5.8.0/pod/perlref.html#Symbolic-references
(or p.264 in your book)
"Only package variables (globals, even if localized) are visible to
symbolic references. Lexical variables (declared with my()) aren't in
a symbol table, and thus are invisible to this mechanism."
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 26 Jun 2003 20:26:04 GMT
From: ktom <abc@nowhere.com>
Subject: simple way to test for undef
Message-Id: <3EFB5714.6080006@nowhere.com>
i have created an array that is sparse, ie there are a number of
elements which are undefined, because i have used a numeric index to the
array and not all of the intermediate indices get used.
here is the code to print this array, which doesn't work...
print Dumper( @ca ) ;
foreach my $item ( @ca ) {
if( defined ref $ca[$item] ) {
print "chain $item has $ca[$item] exceptions\n";
}
}
here is a snippet of the output..
$VAR1 = 6;
$VAR2 = undef;
$VAR3 = undef;
$VAR4 = 5;
$VAR5 = undef;
$VAR6 = 88;
$VAR7 = 1;
chain 6 has 1 exceptions
Use of uninitialized value in array element at ./findViolInScanPath.pl
line 51, <IFILE> line 100.
it seems the autovivification process is biting me, but i don't know how
to work around it. am i making harder than it needs to be.
thanks.
kevin
------------------------------
Date: Thu, 26 Jun 2003 21:45:35 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: simple way to test for undef
Message-Id: <3EFB6988.66365E67@acm.org>
ktom wrote:
>
> i have created an array that is sparse, ie there are a number of
> elements which are undefined, because i have used a numeric index to the
> array and not all of the intermediate indices get used.
>
> here is the code to print this array, which doesn't work...
>
> print Dumper( @ca ) ;
> foreach my $item ( @ca ) {
> if( defined ref $ca[$item] ) {
The return value of ref() is true or false but not undef. Your
statement will always print even if $item or $ca[$item] is undefined
(one of which is producing the warning message.)
> print "chain $item has $ca[$item] exceptions\n";
> }
> }
John
--
use Perl;
program
fulfillment
------------------------------
Date: 26 Jun 2003 12:08:02 -0700
From: thesitus@yahoo.de (JW)
Subject: Re: stopping PPM3 connecting to internet for LOCAL installs
Message-Id: <21bb1f64.0306261108.58339d3c@posting.google.com>
randy@theoryx5.uwinnipeg.ca (Randy Kobes) wrote in message news:<slrnbfh7bv.o6n.randy@theoryx5.uwinnipeg.ca>...
> On Tue, 24 Jun 2003 09:37:38 +0100, Chris Lowth <dont@want.spam> wrote:
> >Randy Kobes wrote:
> >
> >> On Mon, 23 Jun 2003 13:28:49 +0100, Chris Lowth <dont@want.spam> wrote:
> >>>I want to use "PPM" in ActiveState perl 5.8.0 on NT4 to install a module
> >>>from a local file. I have downloaded the zip file and unzipped it. Then
> >>>run
> >>> ppm install IO-Stringy.ppd
> >>>This hangs.
> >>>Running "tcpdump" on the firewall, I can see that the command is trying to
> >>>connect to ppm.activestate.com (which my firewall forbids - I am trying to
> >>>simulate a truely off-line install).
> >>
> >> Are you running the ppm command from the same directory as
> >> where the ppd file is located?
> >
> >Yes
> >Oh - and sorry - the example module is IO-stringy not IO-Stringy.
>
> Is the example file also called IO-stringy.ppd (case sensitive)?
> And also, in the ppd file, does the HREF specification of
> the CODEBASE tag correspond to where the (local) archive is
> on your system? If it specifies a http:// address, then this
> would explain why it's trying to connect. And finally, is
> the NAME attribute of the ARCHITECTURE tag specified as
> MSWin32-x86-multi-thread-5.8, appropriate for ActivePerl 8xx?
I have the same problem (W2K, perl v5.8.0, ppm3, No Internet)
and i'm very tired. After hours i tried this. In the ppm-command-line:
rep add file:///c|/perl-ppd
If there a .ppd-File under c:\perl-ppd , i.e. DBI.ppd,
and it exists a hope that "install DBI" works.
------------------------------
Date: 26 Jun 2003 19:21:16 GMT
From: Nicholas Dronen <ndronen@io.frii.com>
Subject: Re: why this doesn't work (tm)? :)
Message-Id: <3efb47ac$0$197$75868355@news.frii.net>
Matija Papec <mpapec@yahoo.com> wrote:
MP> print $i for $i(1..3);
MP> is there a reason, or simply just doesn't work?
Use this instead:
$ perl -wle 'print for 1..3;'
1
2
3
Regards,
Nicholas
--
"Why shouldn't I top-post?" http://www.aglami.com/tpfaq.html
"Meanings are another story." http://www.ifas.org/wa/glossolalia.html
------------------------------
Date: 26 Jun 2003 11:37:27 -0700
From: pemente@northpark.edu (Eric Pement)
Subject: Re: Write line at beginning of file?
Message-Id: <227a55e9.0306261037.2bd00d21@posting.google.com>
tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnbfhgda.2im.tadmc@magna.augustmail.com>...
> Eric Pement <pemente@northpark.edu> wrote:
> > tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnbfe194.mf6.tadmc@magna.augustmail.com>...
>
>
> >> perldoc -q beginning
> >>
> >> How do I change one line in a file/delete a line in a
> >> file/insert a line in the middle of a file/append to the
> >> beginning of a file?
[ ... ]
> > and the FAQ says this:
> >
> > Although humans have an easy time thinking of a text file as
> > being a sequence of lines that operates much like a stack of
> > playing cards--or punch cards--computers usually see the text
> > file as a sequence of bytes. In general, there's no direct way
> > for Perl to seek to a particular line of a file, insert text
> > into a file, or remove text from a file.
>
>
> That is not what it says in the most recent version of perl (5.8.0).
>
> (but I liked that old answer better than the new answer...)
Me too. Let me say one thing in response. I have maintained a FAQ
file for several years, and I'm accustomed to hearing lots of simple
questions that are tough for the questioner but are very basic for me.
I think the nature of the question requires a different kind of
response or detail, not the same level of complexity or sophistication
for all questions. When a person asks "How do I add a line to the top
of a file?", I think they need a simple, no-frills answer with a
minimum of complexity. When a person asks a question about socket
programming, a greater degree of complexity can be admitted into the
answer. In short, make the answer appropriate to the question. Thus,
for a very basic question, even presuming that the questioner knows
how to use Perl modules could be going too far.
[ ... ]
> _True_ inplace editing is not straightforward, so the FAQ suggests
> the effect of inplace editing (but it isn't really "in place", it
> is in a _different_ place, a temp file).
[ ... ]
> And the FAQ says to do just that, perhaps you did not recognize
> that that is what was being said?
>
> The general solution is to create a temporary copy of
> the text file with the changes you want, then copy that
> over the original.
> ...
> Perl can do this sort of thing for you automatically with the
> ...
To be honest, I was reacting more to the paragraphs that preceded
this one than to this paragraph itself, which addresses it more
directly.
[ ... ]
> You can do multiple in-place edits from a single Perl program
> as well as (better, actually) from a shell program.
>
>
> > with the -i switch to perform
> > in-place replacement,
>
>
> Errr, that _is_ what the FAQ you quoted recommends, so what
> was wrong with that answer again?
>
> :-)
Thanks for the smile. You and I were both presuming (correctly,
I think) that the Original Poster had not read the FAQ. I'm the greater
skeptic and I think the OP may not even have known *how* to look up the
FAQ, so I repeated the recommendation about the -i switch in the wild
hope that the OP might actually return to c.l.p.m. to see if anyone had
answered his question! I just try to do my best. :)
Thanks again for your response.
--
Eric Pement
------------------------------
Date: Thu, 26 Jun 2003 18:13:41 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Write to a filehandle and to STDOUT without double print statements?
Message-Id: <Xns93A690BBFD0A0dkwwashere@216.168.3.30>
Brian McCauley <nobull@mail.com> wrote:
> tadmc@augustmail.com (Tad McClellan) writes:
>
>> perldoc -q file
>>
>> How do I print to more than one file at once?
>
> Tad, whilst I approve of RTFFAQ answers in principle, I should
> point out that the FAQ fails to mention IO::Tee which is probably
> the "right" answer.
>
> Could someone please submit a patch to the FAQ.
It's been added, but I don't know when it was added. I have Perl
v5.8.0 (Activestate build 804) and this FAQ entry mentions IO::Tee.
------------------------------
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 5142
***************************************