[23019] in Perl-Users-Digest
Perl-Users Digest, Issue: 5239 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 18 21:08:18 2003
Date: Fri, 18 Jul 2003 18: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 Fri, 18 Jul 2003 Volume: 10 Number: 5239
Today's topics:
"use" remote modules? <ltierney@ltierney.demon.co.uk>
Re: "use" remote modules? <ben.goldberg@hotpop.com>
Re: Daily Perl puzzle <ltierney@ltierney.demon.co.uk>
Re: File::Find is slower than using recursion!? <ben.goldberg@hotpop.com>
Re: File::Find is slower than using recursion!? <ben.goldberg@hotpop.com>
Re: How to match all characters in a Character Class <ben.goldberg@hotpop.com>
Re: How to match all characters in a Character Class <emschwar@pobox.com>
Re: HTML REGEX <REMOVEsdnCAPS@comcast.net>
Re: Makefile for 5.6 when 5.004 is default (Pete Butler)
Re: need 2 digit dd/mm output <rpl-erroroneous@goldengate.net>
Re: need 2 digit dd/mm output <tony_curtis32@yahoo.com>
OT: You should really use the ISO date format (YYYY-MM- <julian@mehnle.net>
Re: Perl Graphics <mgjv@tradingpost.com.au>
Re: perlstyles <parv_fm@emailgroupsWhereElse.net>
Re: <his_ron@yahoo.com>
Re: Removing characters once a series stops <michael.p.broida@boeing.com>
Requiring a selection on a dropdown list? <his_ron@yahoo.com>
Re: Requiring a selection on a dropdown list? <emschwar@pobox.com>
Re: Running CGI through browser from local hard disk (dan baker)
Re: Running CGI through browser from local hard disk (Malcolm Dew-Jones)
Re: Running CGI through browser from local hard disk <tony_curtis32@yahoo.com>
Re: Running CGI through browser from local hard disk <wsegrave@mindspring.com>
Re: Running CGI through browser from local hard disk (Malcolm Dew-Jones)
Re: Running CGI through browser from local hard disk <noreply@gunnar.cc>
Re: Running CGI through browser from local hard disk (Lukas Mai)
Re: Running CGI through browser from local hard disk <wsegrave@mindspring.com>
Re: Running CGI through browser from local hard disk <wsegrave@mindspring.com>
s there a module to acess Micorsoft Access datafiles? <stanb@panix.com>
Re: s there a module to acess Micorsoft Access datafile <brian_helterline@hp.com>
Re: s there a module to acess Micorsoft Access datafile <wsegrave@mindspring.com>
Re: s there a module to acess Micorsoft Access datafile <wsegrave@mindspring.com>
Re: s there a module to acess Micorsoft Access datafile <stanb@panix.com>
Re: s there a module to acess Micorsoft Access datafile <wsegrave@mindspring.com>
Re: tab delimited file processing problem <domenico_discepola@quadrachemicals.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 18 Jul 2003 21:52:59 +0100
From: "lord0" <ltierney@ltierney.demon.co.uk>
Subject: "use" remote modules?
Message-Id: <bf9mni$bm2$1$8302bc10@news.demon.co.uk>
Hi,
Is it possible to "use" or otherwise import modules held on a REMOTE host
that they may be used? I had considered some sort of SOAP solution but any
ideas/urls etc would be appreciated
Lord0
------------------------------
Date: Fri, 18 Jul 2003 18:36:33 -0400
From: Benjamin Goldberg <ben.goldberg@hotpop.com>
Subject: Re: "use" remote modules?
Message-Id: <3F187671.9A35D400@hotpop.com>
lord0 wrote:
>
> Hi,
>
> Is it possible to "use" or otherwise import modules held on a REMOTE
> host that they may be used? I had considered some sort of SOAP solution
> but any ideas/urls etc would be appreciated
Perl 5.6.1 and latter allow you to put a coderef into @INC.
When you use or require a file, that coderef will be called with two
arguments -- the first one being the coderef itself, the second being
the filename. The coderef may return undef, indicating to perl to
continue searching @INC, or it may return a filehandle, which should
then be used as the required file.
Here's some untested code to do what you want:
use lib sub {
require LWP::Simple;
my $name = "http://www.foo.com/" . pop;
my $doc = LWP::Simple::get($name) or return;
open(my ($fh), "<:scalar", \$doc) or die horribly;
$fh;
};
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Fri, 18 Jul 2003 21:54:50 +0100
From: "lord0" <ltierney@ltierney.demon.co.uk>
Subject: Re: Daily Perl puzzle
Message-Id: <bf9mra$bpv$1$8302bc10@news.demon.co.uk>
Thanks that's perfect
"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x7r84neq5f.fsf@mail.sysarch.com...
> >>>>> "LT" == Lawrence Tierney <lawrence.tierney@bipcontracts.com> writes:
>
> LT> Anybody know of a website or similar which will, on a daily basis,
> LT> email you a perl problem or puzzle etc with the answer being
> LT> provided at a later date?
>
> LT> I ask because our dept. of programmers is looking for some way to
> LT> sort out the wheat from the chaff - a perl top-gun if you will.
>
> this is a weekly puzzle with both beginner and expert problems.
>
> http://perl.plover.com/qotw/
>
> uri
>
> --
> Uri Guttman ------ uri@stemsystems.com --------
http://www.stemsystems.com
> --Perl Consulting, Stem Development, Systems Architecture, Design and
Coding-
> Search or Offer Perl Jobs ----------------------------
http://jobs.perl.org
------------------------------
Date: Fri, 18 Jul 2003 18:47:25 -0400
From: Benjamin Goldberg <ben.goldberg@hotpop.com>
Subject: Re: File::Find is slower than using recursion!?
Message-Id: <3F1878FD.2401DB47@hotpop.com>
Steve Allan wrote:
>
> sholden@flexal.cs.usyd.edu.au (Sam Holden) writes:
>
> <snip>
> >> Is poor performance a known problem with File::Find, or am I using it
> >> improperly? It's hard to believe it could be slower than recursion.
> >> Any insights on why I'm seeing such a discrepancy?
> >
> >I'll take correct over fast any day.
>
> No argument there.
>
> >The recursive version doesn't work in the presence of symlink loops.
> >Where doesn't work means infinitely recurses (well I guess it will run
> >out of stack or memory at some point).
> >
> >I'll also take 1 line of code over 30 odd lines, and worry about
> >speed if it turns out to be not fast enough for a given task.
>
> I Agree here too. I wasn't considering the use of the home-grown
> recursive solution over the File::Find module. I was more interested
> in posting a reproducible example of what seems to be poor performance
> to see if someone had any insight as to why File::Find is so much
> slower than recursion. Your point about symlinks may be hint.
> Perhaps File::Find is just flat out doing more and that accounts for
> the extra time.
Yes, it's doing quite a bit more.
> It could also be that my sense that recursion is
> inherently slow is outdated and just not true in Perl.
Recursion is most certainly *not* inherently slow. I can't think of a
time when it was... at least, not in perl.
> Anyone else have some thoughts on this?
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Fri, 18 Jul 2003 19:07:03 -0400
From: Benjamin Goldberg <ben.goldberg@hotpop.com>
Subject: Re: File::Find is slower than using recursion!?
Message-Id: <3F187D97.E0FD747E@hotpop.com>
Steve Allan wrote:
[snip]
You could go even faster, if you used neither recursion nor File::Find.
sub get_files {
my (@dirs, @flist) = ".";
while( my $dir = pop @dirs ) {
opendir( my $dh, $dir ) or die "opendir($dir): $!";
for my $f (readdir $dh) {
next if $f eq "." or $f eq "..";
$f = "$dir/$f";
push @dirs, $f if !-l $f and -d _;
push @flist, $f if -f $f;
}
}
print "In GetFiles: found ", scalar @flist, " files\n";
}
Here's a slightly different version, which uses a bit less memory (at
the cost of more open dirhandles), especially with large directories.
sub get_files {
my (@dirs, @flist);
opendir( $dirs[0], "." ) or die "opendir(.): $!";
push @dirs, ".";
while(@dirs) {
defined( my $f = readdir $dirs[-2] ) or
(splice @dirs, -2, 2), next;
next if $f eq "." or $f eq "..";
$f = "$dirs[-1]/$f";
push @flist, $f and next if -f $f;
next if -l $f or !-d _;
opendir( my $dh, $f ) or die "opendir($f): $!";
push @dirs, $dh, $f;
}
print "In GetFiles: found ", scalar @flist, " files\n";
}
[both untested]
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Fri, 18 Jul 2003 19:09:19 -0400
From: Benjamin Goldberg <ben.goldberg@hotpop.com>
Subject: Re: How to match all characters in a Character Class
Message-Id: <3F187E1F.6A2C7E64@hotpop.com>
Chinna Polinati wrote:
>
> Is there a way in Perl to match all the characters in the Character
> Class?
use Quantum::Superpositions;
all(map chr, 0..255) =~ /[charclass]/;
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: 18 Jul 2003 17:09:47 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: How to match all characters in a Character Class
Message-Id: <etoy8yvph38.fsf@wormtongue.emschwar>
Benjamin Goldberg <ben.goldberg@hotpop.com> writes:
> Chinna Polinati wrote:
> > Is there a way in Perl to match all the characters in the Character
> > Class?
>
> use Quantum::Superpositions;
> all(map chr, 0..255) =~ /[charclass]/;
Shouldn't it be
all(map chr, 0..65535) =~ /[charclass]/;
to account for unicode? :)
-=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: Fri, 18 Jul 2003 19:32:24 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: HTML REGEX
Message-Id: <Xns93BCD0E8D68C0sdn.comcast@206.127.4.25>
"Boudga" <bruce@ghbraille.com> wrote in
news:vhdtd7jrp2mi50@corp.supernews.com:
> I want to remove the Style tags from my HTML files so I wrote this
> Perl script to remove the line breaks and attempt to remove the Style
> tags but it fails....any help would be much appreciated!
...
> #$outline =~ s/\n/ /gi;
> #$outline =~ s/<style[^>]*>//gi;
Gee, it helps if the statements you expect to do the work aren't comments.
--
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
------------------------------
Date: 18 Jul 2003 11:17:42 -0700
From: pmbutler@attbi.com (Pete Butler)
Subject: Re: Makefile for 5.6 when 5.004 is default
Message-Id: <9b766f0.0307181017.5635f5e0@posting.google.com>
<details of what I'm doing snipped>
> Run "/path/to/5.6.1/perl Makefile.PL"
>
> And it should automagically work.
Indeed it did.
Thank you for the help!
-- Pete Butler
------------------------------
Date: Fri, 18 Jul 2003 14:52:56 -0500
From: "Bob" <rpl-erroroneous@goldengate.net>
Subject: Re: need 2 digit dd/mm output
Message-Id: <3f184ffc$0$104$8f4e7992@newsreader.goldengate.net>
"Vladimir P." <vladimir@NoSpamPLZ.net> wrote in message
news:F8TRa.4700$d34.173390@weber.videotron.net...
> On Fri, 18 Jul 2003 08:16:37 -0500, Bob wrote:
> >
> > need to have host get date and use in outputfile name. mon and day has
to
> > be two digits.
> > ex: spc20030702.kdg
> >
> Here is one way of doing it:
>
> ($yr,$mon,$day) = (localtime)[5,4,3];
> $yr+=1900,$mon++;
> printf "spc%4d%02d%02d.kdg",$yr,$mon,$day;
>
> --
> .signature: No such file or directory
is there a way to get "spc%4d%02d%02d.kdg",$yr,$mon,$day; in a
variable...
like $filename = "spc%4d%02d%02d.kdg",$yr,$mon,$day;
so I can do
print $filename "something";
------------------------------
Date: Fri, 18 Jul 2003 14:54:47 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: need 2 digit dd/mm output
Message-Id: <87lluv1ugo.fsf@limey.hpcc.uh.edu>
>> On Fri, 18 Jul 2003 14:52:56 -0500,
>> "Bob" <rpl-erroroneous@goldengate.net> said:
> is there a way to get
> "spc%4d%02d%02d.kdg",$yr,$mon,$day; in a variable...
> like $filename = "spc%4d%02d%02d.kdg",$yr,$mon,$day;
sprintf
> so I can do print $filename "something";
Yes, and see my other follow-up about POSIX::strftime().
hth
t
------------------------------
Date: Sat, 19 Jul 2003 01:49:14 +0200
From: "Julian Mehnle" <julian@mehnle.net>
Subject: OT: You should really use the ISO date format (YYYY-MM-DD)
Message-Id: <bfa0vr$cnjmo$1@ID-65075.news.uni-berlin.de>
Ron wrote:
> 1. Get the current date & day of the week.
> 2. Put it into this format MM-DD-YY Day
On an off-topic note: you should really use the internationally
standardized ISO date format[1], which is YYYY-MM-DD. Most other date
formats, like MM-DD-YY, are either confusing or ambiguous, or both.
Even if you can't use the ISO format in your application immediately, you
should plan using it in the future and advocate it towards friends,
colleagues, and bosses. ;-)
[1] http://www.cl.cam.ac.uk/~mgk25/iso-time.html
------------------------------
Date: Sat, 19 Jul 2003 10:43:17 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Perl Graphics
Message-Id: <slrnbhh514.rlm.mgjv@martien.heliotrope.home>
On Wed, 16 Jul 2003 22:05:47 GMT,
Bob Walton <bwalton@rochester.rr.com> wrote:
> Matt Oliverius wrote:
>
> ...
>
>
>> I have a quick question that I hope someone finds remotely relevant to this
>> newsgroup. Is there any way to dynamically generate an image with Perl?
>> I've used Perl and regular expressions in the past to parse a vector
>> graphics image and replace flags in a dummy document (very tedious to set
>> up) to generate what I want. However, now I would like to do something
>> similar to this so that I can return a rastor image via the web. It would
>> also be nice if I didn't have to use an intermediate dummy document.
> ...
>
>
>> Matt
> ...
>
>
> Here is an example of one way you can generate a "dynamic image" with
> Perl, all from one file with no "intermediate files". You'll need the
> GD module installed to run this, and you'll need to call it "GDtest.pl":
>
> use CGI qw(:standard);
Since you use the CGI module, there is no need to force a particular
name. The CGI module has methods to get to the URL that was called to
execute this instance. Have a look at script_name(), query_string() and
related stuff.
> use GD;
You missed
use strict;
use warnings;
use CGI::Carp 'fatalsToBrowser';
> if(param('image')){
> print "Content-type: image/png\n\n";
Since you are using the CGI module anyway, why don't you use it's
methods?
> binmode STDOUT;
To be strict, you're supposed to call binmode() before any I/O is done
on the file handle. You should call it before you print the content type
header. If you use the CGI module, you won't have to worry about
outputting the correct line endings anymore after the binmode:
binmode STDOUT;
print header(-type => "image/png");
Of coiurse, you could just generate the image first, and then do the
printing once you've succeeded in doing that. Much easier to handle
errors that way.
> $im = new GD::Image(100,100);
since you're using these values (100 and 100), later in the program
again, it is probably wiser to use some program-global variables for
this, or do it in some other way that allows you to have a single place
where this is set.
> if(param()){
> print img{src=>'GDtest.pl?n1='.param('n1').
> '&n2='.param('n2').'&n3='.param('n3').
> '&n4='.param('n4').'&image=yes',width=>100,height=>100};
All of this can be cleaned up if you use the script_name() and
query_string() methods.
I also don't think you answered the OP's question (except showing that
GD exists). Most of your answer is about something entirely different
from what the OP was asking, IMO, but it's hard to tell, since the OP
isn't responding to this thread. However, I am pretty certain that when
the OP said "dynamically generate an image", that they didn't intend to
use the CGI environment.
Martien
--
|
Martien Verbruggen | For heaven's sake, don't TRY to be cynical.
| It's perfectly easy to be cynical.
|
------------------------------
Date: Fri, 18 Jul 2003 19:07:03 GMT
From: parv <parv_fm@emailgroupsWhereElse.net>
Subject: Re: perlstyles
Message-Id: <slrnbhghfg.jba.parv_fm@localhost.holy.cow>
in message <pan.2003.07.18.03.44.22.45903@kamelfreund.de>,
wrote Janek Schleicher ...
> parv wrote at Fri, 18 Jul 2003 03:14:08 +0000:
>
>> in message <g1udhv065eijbi9kd4flhr3k2o1n19uoa7@4ax.com>,
>> wrote Matija Papec ...
>>
>>> @arr = join ',', map s|'|\\'|g && "'$_'", grep /^MB/, @arr;
>>
>> @arr = join ',' , map { s/'/\\'/g; "'$_'" }
> ^^
> In your solution, every element of the array is mapped into
> enclosing single quotes, while in the OP's code, an element is
> only enclosed by single quotes if there had been any single quote
> inside the element before. I don't know whether it is a problem
> for the OP, but at least, it's a little difference
Yes, it is different. I was not paying much attention to map or
grep blocks/expressions, just the format of putting things in (point
of OP).
- parv
--
In order to reach me, do away w/ WhereElse in the address.
A programmer, budding Unix system administrator, and amateur photographer
is in search of employment: http://www103.pair.com/parv/work/
------------------------------
Date: Fri, 18 Jul 2003 23:35:53 GMT
From: "Ron" <his_ron@yahoo.com>
Subject: Re:
Message-Id: <tv%Ra.91979$TJ.5252351@twister.austin.rr.com>
Tried this code get a server 500 error.
Anyone know what's wrong with it?
if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
dienice("Please use the back button on your browser to fill out the Day
& Route fields.");
}
Thanks,
Ron
------------------------------
Date: Sat, 19 Jul 2003 00:00:16 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Removing characters once a series stops
Message-Id: <3F188A10.8DA14D45@boeing.com>
Sara wrote:
>
> jimnl69@hotmail.com (Jim) wrote in message news:<3966ee66.0307180645.1bf4f959@posting.google.com>...
> > I have strings that I need to get the first set of numbers from. IE:
> >
> > ABC123DEF
> > ABC11JH8KLZ
> >
> > I need to get 123 and 11 from the from the above strings. I can strip
> > the first characters off with =~ s/\D*//; but how do I strip off
> > everything else, even any additional numbers, after the first set of
> > numbers ends? Thanks!
> >
> > J
>
> Hello Jim:
>
> Let's see here, how about
>
> s/^\D*(\d+).+$/$1/;
Hmm, that requires at least one character AFTER the initial
number group. That fits the examples, but not necessarily
ALL of the data that will be encountered.
Perhaps just change the ".+" to ".*" ?? THAT will fit the
examples AND any other data with nothing after the initial
number group.
Mike
------------------------------
Date: Fri, 18 Jul 2003 22:29:18 GMT
From: "Ron" <his_ron@yahoo.com>
Subject: Requiring a selection on a dropdown list?
Message-Id: <2x_Ra.85066$hV.5920326@twister.austin.rr.com>
Maybe more of an html question but here goes. I have a form with a
drop-down list I would like to require the user to make a selection on. How
would I go about doing this?
Thanks,
Ron
------------------------------
Date: 18 Jul 2003 16:30:44 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Requiring a selection on a dropdown list?
Message-Id: <eto3ch3qxgr.fsf@wormtongue.emschwar>
"Ron" <his_ron@yahoo.com> writes:
> Maybe more of an html question but here goes.
More like CGI, really. You want comp.infosystems.www.authoring.cgi,
over --> thataway.
> I have a form with a drop-down list I would like to require the user
> to make a selection on. How would I go about doing this?
Print the form again, with an error message, if they don't make a
selection. See the aforementioned CGI group for more details.
-=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: 18 Jul 2003 11:59:04 -0700
From: botfood@yahoo.com (dan baker)
Subject: Re: Running CGI through browser from local hard disk
Message-Id: <13685ef8.0307181059.6a2972c6@posting.google.com>
jpcostella@hotmail.com (Dr. John P. Costella) wrote in message news:<e5141246.0307151811.77bd99fe@posting.google.com>...
>
> I am trying to test what a browser would show when accessing a CGI
> script, but without going through an actual server.
-----------
youve got to have a localhost server....
try xitami.com . easy to install and free.
d
------------------------------
Date: 18 Jul 2003 13:14:39 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Running CGI through browser from local hard disk
Message-Id: <3f18552f@news.victoria.tc.ca>
Gunnar Hjalmarsson (noreply@gunnar.cc) wrote:
: Dr. John P. Costella wrote:
: > I am trying to test what a browser would show when accessing a CGI
: > script, but without going through an actual server.
: Well, you do need a server.
Not really, though that is easiest in the long run.
He could simply go to the command line and run the script with the desired
parameters and save the output in a file.
C:> perl my-cgi.pl submit=doit the_field=test-value > temp.htm
and then browse that file (temp.htm) to check what it looked like.
------------------------------
Date: Fri, 18 Jul 2003 15:17:06 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Running CGI through browser from local hard disk
Message-Id: <87he5j1tfh.fsf@limey.hpcc.uh.edu>
>> On 18 Jul 2003 13:14:39 -0800,
>> yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) said:
> Gunnar Hjalmarsson (noreply@gunnar.cc) wrote:
> : Dr. John P. Costella wrote:
> : > I am trying to test what a browser would show when
> accessing a CGI : > script, but without going through an
> actual server.
> : Well, you do need a server.
> Not really, though that is easiest in the long run.
> He could simply go to the command line and run the
> script with the desired parameters and save the output
> in a file.
> C:> perl my-cgi.pl submit=doit the_field=test-value > temp.htm
> and then browse that file (temp.htm) to check what it
> looked like.
Yeah, but there are other considerations. The most
obvious one is that of the userid and environment under
which CGI programs would execute, rather than as yourself
at the command-line.
But I fear this is drifting way off-topic for clpm.
hth
t
------------------------------
Date: Fri, 18 Jul 2003 15:53:50 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Running CGI through browser from local hard disk
Message-Id: <bf9mtv$7fo$2@slb9.atl.mindspring.net>
"Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
news:3f18552f@news.victoria.tc.ca...
> Gunnar Hjalmarsson (noreply@gunnar.cc) wrote:
> : Dr. John P. Costella wrote:
> : > I am trying to test what a browser would show when accessing a CGI
> : > script, but without going through an actual server.
>
> : Well, you do need a server.
>
> Not really, though that is easiest in the long run.
>
> He could simply go to the command line and run the script with the desired
> parameters and save the output in a file.
>
> C:> perl my-cgi.pl submit=doit the_field=test-value > temp.htm
>
> and then browse that file (temp.htm) to check what it looked like.
IMO, testing from the command line is something the OP should be doing
before deployment on a CGI server.
BTW, when you save to an HTML file, you may wish to comment out the header
shortcut in your script, so you can open the file with your browser to see
it as it would look in a browser, e.g.,
#!perl -w
# webcam_gallery.pl - command line version
# usage - perl webcam_gallery.pl > webcam_show.htm
use strict;
use CGI qw(:standard);
print
# header,
start_html;
# rest of script
Cheers.
Bill Segraves
------------------------------
Date: 18 Jul 2003 14:09:20 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Running CGI through browser from local hard disk
Message-Id: <3f186200@news.victoria.tc.ca>
William Alexander Segraves (wsegrave@mindspring.com) wrote:
: BTW, when you save to an HTML file, you may wish to comment out the header
: shortcut in your script, so you can open the file with your browser to see
: it as it would look in a browser, e.g.,
: #!perl -w
: # webcam_gallery.pl - command line version
: # usage - perl webcam_gallery.pl > webcam_show.htm
: use strict;
: use CGI qw(:standard);
: print
: # header,
: start_html;
: # rest of script
: Cheers.
I have never found that necessary. It's true the headers are displayed at
the top, but otherwise they do not interfere with the html in any way I
have ever noticed.
------------------------------
Date: Fri, 18 Jul 2003 23:26:59 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Running CGI through browser from local hard disk
Message-Id: <bf9p2k$bs8pj$1@ID-184292.news.uni-berlin.de>
William Alexander Segraves wrote:
> "Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
> news:3f18552f@news.victoria.tc.ca...
>> Gunnar Hjalmarsson (noreply@gunnar.cc) wrote:
>>> Dr. John P. Costella wrote:
>>>> I am trying to test what a browser would show when accessing
>>>> a CGI script, but without going through an actual server.
>>>
>>> Well, you do need a server.
>>
>> Not really, though that is easiest in the long run.
>>
>> He could simply go to the command line and run the script with
>> the desired parameters and save the output in a file.
>>
>> C:> perl my-cgi.pl submit=doit the_field=test-value > temp.htm
>>
>> and then browse that file (temp.htm) to check what it looked
>> like.
>
> IMO, testing from the command line is something the OP should be
> doing before deployment on a CGI server.
Why? If you direct the exception messages to the browser, which is
kind of natural when developing CGI scripts, personally I find 'the
CGI way' to be more convenient.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 18 Jul 2003 15:12:05 -0700
From: .lmai@web.de (Lukas Mai)
Subject: Re: Running CGI through browser from local hard disk
Message-Id: <951cf24.0307181412.68c36102@posting.google.com>
jpcostella@hotmail.com (Dr. John P. Costella) wrote:
>
> I am trying to test what a browser would show when accessing a CGI
> script, but without going through an actual server. I have Perl
> running fine on the local machine (Win XP) and am working through some
> tutorials etc. But if I try to access the file through MSIE it runs
> the script from a command prompt rather than piping the result back to
> the browser.
>
> Is this possible to do without the actual server? (I intend to put the
> final working script onto a real server down the track, but for
> various reasons that's not possible at this time.)
Check out w3m. According to http://www.w3m.org it can "locally run cgi
scripts to test html output (requires *no* webserver)".
HTH, Lukas
------------------------------
Date: Fri, 18 Jul 2003 18:56:29 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Running CGI through browser from local hard disk
Message-Id: <bfa2ql$pd1$1@slb6.atl.mindspring.net>
"Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
news:3f186200@news.victoria.tc.ca...
<snip>
> I have never found that necessary. It's true the headers are displayed at
> the top, but otherwise they do not interfere with the html in any way I
> have ever noticed.
>
ISTM we're not talking (writing) about the same scenario. While the headers
cause no problems when served by a CGI server; they do cause problems when
they are at the top of an HTML file that is opened with MSIE. That's why I
commented out the header shortcut in the example I posted for the command
line version of a working script.
YMMV.
Cheers.
Bill Segraves
------------------------------
Date: Fri, 18 Jul 2003 19:14:54 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Running CGI through browser from local hard disk
Message-Id: <bfa2qm$pd1$2@slb6.atl.mindspring.net>
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:bf9p2k$bs8pj$1@ID-184292.news.uni-berlin.de...
> William Alexander Segraves wrote:
> > "Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
> > news:3f18552f@news.victoria.tc.ca...
> >> Gunnar Hjalmarsson (noreply@gunnar.cc) wrote:
> >>> Dr. John P. Costella wrote:
> >>>> I am trying to test what a browser would show when accessing
> >>>> a CGI script, but without going through an actual server.
<snip>
> > IMO, testing from the command line is something the OP should be
> > doing before deployment on a CGI server.
>
> Why? If you direct the exception messages to the browser, which is
> kind of natural when developing CGI scripts, personally I find 'the
> CGI way' to be more convenient.
Hi, Gunnar.
It appears to be a matter of personal preference. Personally, I prefer to do
my syntax checking from the command line. Why would I want to run a broken
script on a CGI server?
In a literal sense, it appears the OP wants "without going through an actual
server".
Cheers.
Bill Segraves
------------------------------
Date: Fri, 18 Jul 2003 18:14:47 +0000 (UTC)
From: Stan Brown <stanb@panix.com>
Subject: s there a module to acess Micorsoft Access datafiles?
Message-Id: <bf9den$bom$1@reader1.panix.com>
I find myself with the eed to obtain some data stored in Microsoft Access
format files from a perl script ruinning on a FreebSD box.
What's the best way to do this?
The files are actually on a Windows machien, but I can mount the partiton
using Samba.
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
------------------------------
Date: Fri, 18 Jul 2003 13:11:21 -0700
From: "Brian Helterline" <brian_helterline@hp.com>
Subject: Re: s there a module to acess Micorsoft Access datafiles?
Message-Id: <3f1859c0$1@usenet01.boi.hp.com>
"Stan Brown" <stanb@panix.com> wrote in message
news:bf9den$bom$1@reader1.panix.com...
> I find myself with the eed to obtain some data stored in Microsoft Access
> format files from a perl script ruinning on a FreebSD box.
>
> What's the best way to do this?
>
> The files are actually on a Windows machien, but I can mount the partiton
> using Samba.
>
Try the DBD:ODBC Module
------------------------------
Date: Fri, 18 Jul 2003 15:03:56 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: s there a module to acess Micorsoft Access datafiles?
Message-Id: <bf9lhr$mv7$1@slb6.atl.mindspring.net>
"Stan Brown" <stanb@panix.com> wrote in message
news:bf9den$bom$1@reader1.panix.com...
> I find myself with the eed to obtain some data stored in Microsoft Access
> format files from a perl script ruinning on a FreebSD box.
>
> What's the best way to do this?
Win32::ODBC
Bill Segraves
------------------------------
Date: Fri, 18 Jul 2003 15:40:26 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: s there a module to acess Micorsoft Access datafiles?
Message-Id: <bf9mtu$7fo$1@slb9.atl.mindspring.net>
"William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
news:bf9lhr$mv7$1@slb6.atl.mindspring.net...
> "Stan Brown" <stanb@panix.com> wrote in message
> news:bf9den$bom$1@reader1.panix.com...
> > I find myself with the eed to obtain some data stored in Microsoft
Access
> > format files from a perl script ruinning on a FreebSD box.
> >
> > What's the best way to do this?
>
> Win32::ODBC
Retracted. I see FreeBSD (which I originally missed), not Win32, as
platform.
Bill Segraves
------------------------------
Date: Fri, 18 Jul 2003 20:59:46 +0000 (UTC)
From: Stan Brown <stanb@panix.com>
Subject: Re: s there a module to acess Micorsoft Access datafiles?
Message-Id: <bf9n42$f1b$1@reader1.panix.com>
In <bf9lhr$mv7$1@slb6.atl.mindspring.net> "William Alexander Segraves" <wsegrave@mindspring.com> writes:
>"Stan Brown" <stanb@panix.com> wrote in message
>news:bf9den$bom$1@reader1.panix.com...
>> I find myself with the eed to obtain some data stored in Microsoft Access
>> format files from a perl script ruinning on a FreebSD box.
>>
>> What's the best way to do this?
>Win32::ODBC
Correct me if I'm wrong, but wouldn't that have to run ont Windows amchine?
Perhaps I did not mention, the idea is to not have to do any more to the
Windows box than mount it's share to get access to the files?
Or am I on the wrong track here? I certainly will be the first to admit
that I know nothing about the Windows side of things!
--
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
-- Benjamin Franklin
------------------------------
Date: Fri, 18 Jul 2003 17:03:49 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: s there a module to acess Micorsoft Access datafiles?
Message-Id: <bfa062$3rb$1@slb9.atl.mindspring.net>
"Stan Brown" <stanb@panix.com> wrote in message
news:bf9n42$f1b$1@reader1.panix.com...
> In <bf9lhr$mv7$1@slb6.atl.mindspring.net> "William Alexander Segraves"
<wsegrave@mindspring.com> writes:
>
> >"Stan Brown" <stanb@panix.com> wrote in message
> >news:bf9den$bom$1@reader1.panix.com...
> >> I find myself with the eed to obtain some data stored in Microsoft
Access
> >> format files from a perl script ruinning on a FreebSD box.
> >>
> >> What's the best way to do this?
>
> >Win32::ODBC
>
Stan, please note I retracted this statement, on seeing what appeared to be
your objective.
>
> Correct me if I'm wrong, but wouldn't that have to run on the Windows
machine?
>
Yes. In addition, you'd have to set up a DSN on the Win32 machine to make it
possible for Win32::ODBC to access the files. See
http://www.roth.net/odbc/odbcfaq.htm for, well, FAQ stuff, on Win32.
> Perhaps I did not mention, the idea is to not have to do any more to the
> Windows box than mount it's share to get access to the files?
>
I understand. I wouldn't be at all surprised if you could do it that way. I
just haven't done it myself.
> Or am I on the wrong track here? I certainly will be the first to admit
> that I know nothing about the Windows side of things!
You may take a look at _Programming the Perl DBI_, Descartes, Alligator and
Bunce, Tim, "ODBC from Perl", pp. 167-172 for how to move a Perl script that
uses Win32::ODBC from Win32 to another platform.
If you want to try setting up a Win32 box to provide access to MS Access
files, you might try downloading and installing IndigoPerl, free from
www.indigostar.com, on the Win32 box. Note that you don't need to have MS
Access installed on the Win32 box to be able to access an MS Access file,
although it would certainly be helpful, especially if you need to generate
MS Access files for testing.
A couple of interesting projects I've encountered that may be helpful to
you:
1. #GUFE: Generic but Usable Front End
#by Aaron Weiss (aaron@pobox.com) for the Web Developers' Virtual Library
# http://www.wdvl.com
2. # ODBC query - requires PERL 5.003_7 or higher and Win32::ODBC
# Author Alan Johnston - modified by WAS 11May2002
# Downloaded from http://www.roth.net/perl/scripts/scripts.asp?ODBCQry.pl
I'd certainly *like* to be in your situation, as my preference, at times,
would be to know as little as possible about Windows.
Cheers.
Bill Segraves
------------------------------
Date: Fri, 18 Jul 2003 15:58:24 -0400
From: "Domenico Discepola" <domenico_discepola@quadrachemicals.com>
Subject: Re: tab delimited file processing problem
Message-Id: <0mYRa.43185$PD3.4440052@nnrp1.uunet.ca>
"Bill Smith" <wksmith@optonline.net> wrote in message
news:pxWRa.31700$n95.4353711@news4.srv.hcvlny.cv.net...
>
> "Domenico Discepola" <joeminga@yahoo.com> wrote in message
> news:698c67f.0307171302.5b601332@posting.google.com...
> > Hi all. I have constructed a script that uses Win32::OLE to save an
> Excel
> > workbook as a tab-delimited text file (TSV file). This works fine.
> My next
> > step is to perform formatting on each field per line in the TSV file
> while
> > retaining the # of fields. The problem lies with "empty" cells in the
> 1st
> > column of the Excel file.
>
> I remember having similar problems in the distant past. I used native
> EXCEL commands to create the TSV file. Details of the file format
> depended on the version of EXCEL. This is probably not a problem to
> you, but beware!
>
> Bill
>
>
As an added note, if one particular row in Excel has fewer columns than
columns in surrounding rows, Excel will not pad the remaining columns with
tabs... In other words, you can end up with a TSV file having a different
number of fields:
Example Excel file:
row1: x, y, z
row2: a, b, c, d
resultant TSV file (in regex format):
row1: /^x\ty\tz$/
row2: /^a\tb\tc\td$/
So, as you see, if you are trying to manipulate a TSV file and expect the
same number of fields per line, you must account for it programmatically as
Excel does not do it for you.
------------------------------
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 5239
***************************************