[12013] in Perl-Users-Digest
Perl-Users Digest, Issue: 5613 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 10 01:07:25 1999
Date: Sun, 9 May 99 22:00:29 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 9 May 1999 Volume: 8 Number: 5613
Today's topics:
[SRC] dejaview -- Easily search DejaNews (Matthew Bafford)
A CGI/PERL that emails data and then post data to an as <mike-carter@email.msn.com>
Re: A CGI/PERL that emails data and then post data to a (Michel Dalle)
Re: combining data in a text delimited file (Tad McClellan)
Re: combining data in a text delimited file (Jim Britain)
Re: combining data in a text delimited file <gellyfish@gellyfish.com>
CPAN-POD & pulling my hair OUT! HELP! do the doc's real <nospam@atanytimeonthe.net>
Re: CPAN-POD & pulling my hair OUT! HELP! do the doc's <gellyfish@gellyfish.com>
DBI For NT??? <sova0001@algonquinc.on.ca>
Re: File::Find non-functional when passing arguments to (Ilya Zakharevich)
Re: File::Find non-functional when passing arguments to (Charles R. Thompson)
Re: File::Find non-functional when passing arguments to (Ilya Zakharevich)
Re: File::Find non-functional when passing arguments to (Randal L. Schwartz)
Re: File::Find non-functional when passing arguments to (Charles R. Thompson)
Re: Free Perl Web Database w/ full source code - commen <mpersico@erols.com>
Re: Free Perl Web Database w/ full source code - commen (Jeff Vannest)
I got a problem need info <sova0001@algonquinc.on.ca>
Re: I got a problem need info <gellyfish@gellyfish.com>
Re: I got a problem need info <ebohlman@netcom.com>
Re: I got a problem need info <mamster@mamster.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 09 May 1999 21:06:37 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: [SRC] dejaview -- Easily search DejaNews
Message-Id: <slrn7jbtds.226.dragons@dragons.duesouth.net>
Soon to be placed at my site, but I'd like some input before I put it up.
Share and Enjoy!
--Matthew
--
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use URI::Escape;
use Getopt::Long;
use Date::Parse;
my $header_color = qq."#0000FF".;
my $body_color = qq."#000000".;
my @valid_langs = qw.ALL chinese danish dutch english finnish french german
hungarian italian japanese korean norwegian portuguese
polish russian spanish swedish vietnamese.;
my @valid_sects = ('complete', 'standard', 'adult', 'jobs', 'for sale');
my $proxy = undef;
my $max = -1;
my $out = '-';
my $language = $valid_langs[0];
my $section = $valid_sects[0];
my $verbose = undef;
my $get_threads = undef;
Getopt::Long::Configure("bundling");
GetOptions(
'p=s' => \$proxy,
'v+' => \$verbose,
'm=i' => \$max,
't' => \$get_threads,
'l=s' => \$language,
's=s' => \$section,
) or exit 1;
die "Invalid language!\n" if !grep {$_ eq $language} @valid_langs;
die "Invalid section!\n" if !grep {$_ eq $section } @valid_sects;
my $search_url = "http://www.dejanews.com/[ST_rn=ps]/dnquery.xp?ST=PS&maxhits=100&LNG=$language&QRY=";
my $thread_url = "http://www.dejanews.com/[ST_rn=ps]/viewthread.xp?AN=";
my $view_url = "http://www.dejanews.com/[ST_rn=ps]/getdoc.xp?AN=";
my $view_plain_url = "http://www.dejanews.com/[ST_rn=ps]/getdoc.xp?fmt=raw&AN=";
my $query = uri_escape(shift);
$query =~ s/&/%26/g; # why doesn't uri_escape do this?
my $ua = LWP::UserAgent->new();
$ua->agent("DejaView");
$ua->proxy(http => $proxy) if $proxy;
my %ids; # Visited IDs
my %messages;
my %parents;
my %children;
my $page = 1;
my $count = 0;
my $total = 0;
my @todo_urls = ($search_url . $query);
my @todo_threads;
my @todo_articles;
sub get_url {
my($url, $text) = @_;
my $req = HTTP::Request->new(GET => $url);
$req->referer("http://www.perl.com");
my $response = $ua->request($req);
if ( $response->is_error() ) {
$@ = $response->status_line;
return;
}
return $response->content();
}
sub fetch_matchpage {
my $url = shift;
my $thread = shift;
printf STDERR "Fetching page $page of %s...\n",
$thread ? "thread pages" : "search results" if $verbose;
my $content = get_url($url) or die "Failed to retrieve $url: $@\n";
$page++;
LINE:
for ( split /\n/, $content )
{
if ( m{
(http://x\d+\.dejanews\.com/\[ST_rn=ps\]/dnquery\.xp\?
search=next[^"]+)"
}ix
)
{
push @todo_urls, $1;
last LINE;
}
if (
m|(http://x\d+\.dejanews\.com/\[ST_rn=ps\]/getdoc\.xp\?AN=(\d+))|
||
m|(http://x\d+\.dejanews\.com/\[ST_rn=ps\]/threadmsg_ct\.xp\?&AN=(\d+))|
) {
next LINE if $ids{$2}++;
return if @todo_articles > $max-1 && $max && !$thread;
my $todo_thread = "$thread_url$2";
push @todo_articles, $2;
push @todo_threads, $todo_thread if !$thread && $get_threads;
}
}
}
sub get_article {
my $an = shift;
my $thread = shift;
my $url = "$view_plain_url$an";
++$count;
print STDERR "....fetching match $count out of $total\n"
if $verbose;
my $content = get_url($url) or die "Can't get $url: $@\n";
my $id = $1 if ( $content =~ /^Message-ID: +<([^>]+)> *$/mi );
next unless $id;
if ( $content =~ /^References: (.+)$/m ) {
my $parent = (split " ", $1)[-1];
$parent =~ s/^<([^>]+)>$/$1/;
$parents{$id} = $parent;
push @{$children{$parent}}, $id;
}
$content =~ s/^/AN: $an\n/;
$messages{$id} = $content;
}
sub print_toc {
my @ids = @{shift(@_)};
my $depth = shift || 0;
for my $id ( @ids ) {
my $message = $messages{$id};
my $subject = '(No Subject)';
if ( $message =~ m/^Subject: +(.+)$/m and $1 !~ /^\s+$/ ) {
$subject = $1;
}
print '-'x4x$depth, qq.<A HREF="#$id">$subject</A><BR>\n.;
if ( $children{$id} ) {
print_toc($children{$id}, $depth+1);
}
}
}
sub print_articles {
my @ids = @{shift(@_)};
my $depth = shift || 0;
my $first = $depth == 0;
for my $id ( @ids ) {
print "\n<HR>\n" unless $first || $depth;
$first = 0;
my $message = $messages{$id};
$message =~ s.&.&.g;
$message =~ s.<.<.g;
$message =~ s.>.>.g;
$message =~ s.".".g;
$message =~ s.\n+$..;
my($headers, $body) = split /\n{2,}/, $message, 2;
$headers =~ s.^AN: (\d+)\n..mi
and
$headers .= qq;\n[<A HREF="$view_url$1">View on DejaNews</A> <A HREF="#TOP">Back to the top</A>];;
$headers =~ s.^.<A NAME="$id"></A>.;
s.^.' ' x 4 x $depth.meg for $headers, $body;
print <<EOT;
<PRE>
<FONT COLOR=$header_color>
$headers
</FONT>
<FONT COLOR=$body_color>
$body
</FONT>
</PRE>
EOT
if ( $children{$id} ) {
print_articles($children{$id}, $depth+1);
}
}
}
fetch_matchpage shift @todo_urls
while @todo_urls;
$page = 1;
fetch_matchpage shift @todo_threads, 'thread'
while @todo_threads;
$total = @todo_articles;
get_article shift @todo_articles
while @todo_articles;
$max = 0;
my @toplevels =
grep {
not defined $parents{$_}
or
not defined $messages{$parents{$_}}
} keys %messages;
my $nice_query = uri_unescape $query;
print STDERR "No matches, try changing your query.\n" unless $count;
print qq|<HTML><HEAD><TITLE>Search Results for [$nice_query]</TITLE></HEAD><BODY>\n|;
print qq|<A NAME="TOP">\n|;
print qq|<H1>Search Results for [$nice_query]</H1>\n|;
print qq|<P>There were $count matches.</P>\n|;
print qq|<P><A HREF="$search_url$query">Run the search on DejaNews</A></P>\n|;
print qq|\n<HR>\n|;
print_toc(\@toplevels);
print qq|\n<HR>\n|;
print_articles(\@toplevels);
print qq|</BODY></HTML>\n|;
__END__
=pod
=head1 NAME
dejaview - Search DejaNews' site, returning results on one file
=head1 SYNOPSIS
dejaview [B<-p> I<string>] [B<-v>] [B<-m> I<number>] [B<-t>] [B<-l> I<language>] I<query string>
=head1 DESCRIPTION
I<dejaview> runs a search on the DejaNews website, returning all matches in
one html file.
Output is to standard output.
=head2 FEATURES
I<dejaview> has many features, including:
=over 4
=item saves time
Rather than having to go through hundreds of links to find the article that
matches your need, I<dejaview> grabs all articles and places them in a single
file.
=item threaded output
The articles in the output file are nicely indented so that you can easily
tell one article's relationship to another.
=back
=head2 OPTIONS
I<dejaview> accepts several options to help customize your experience:
=over 4
=item B<-p> I<string>
Allows you to specify a proxy server for I<dejaview> to use.
=item B<-v>
If specified, I<dejaview> will be very noisy.
=item B<-m> I<number>
I<number> specifies the maximum number of hits I<dejaview> should retrieve.
Note, if B<-t> is specified, B<-m> will not affect the number of thread
messages that are downloaded.
=item B<-t>
Tells I<dejaview> to download all of the messages in the threads of the matched
articles.
=item B<-l> I<language>
Lets you specify the language DejaNews should search.
Possible choices are:
=over 8
=item ALL
=item chinese
=item danish
=item dutch
=item english
=item finnish
=item french
=item german
=item hungarian
=item italian
=item japanese
=item korean
=item norwegian
=item portuguese
=item polish
=item russian
=item spanish
=item swedish
=item vietnamese
=back
=back
=head1 DejaNews Queries
DejaNews has it's own little language that is used to query it's servers.
It's fairly straightforward.
The following meta characters are recognized:
=over 4
=item &
Find item 1 AND item 2. Ie:
Wall & Christiansen
will find all articles that contain both Wall and Christiansen (though they
may not be side by side).
=item |
Find item 1 OR item 2. Ie:
Perl | Python
will find all articles that talk about the two scripting languages.
=item &!
Find item 1, but NOT item 2. Ie:
Perl &! Python
will find all articles that talk about Perl without comparing it to Python.
=item ^
Find item 1, but only if it is NEAR item 2. Ie:
Perl | Python
will find all articles that talk about Perl AND Python in the same sentence
(or close to).
=item "" (Quotes)
When wrapped around text, these tell DejaNews to find text that exactly matches
whatever is between the quotes. Ie:
"Larry Wall"
will match all articles that contain Larry Wall somewhere within.
=item *
Wildcard match. Ie:
Larry W*
will find Larry Wall and Larry Wrong.
=item () (Parentheses)
Group items together. Ie:
Perl & (Wall | Christiansen)
will find all articles that talk about Perl and Larry Wall, or Perl and Tom
Christiansen.
=item {} (Braces)
Search on a range of words. Ie:
{monkey monkeying}
would locate articles containing the words "monkey", "monkey's", "monkey73",
"monkeying", etc (or so DejaNews claims).
=item ~a
Find articles with a certain author. Ie:
~a Wall
will find all articles written by someone with Wall in his name (or email
address).
=item ~s
Find articles with a certain subject. Ie:
~s Perl
will find all articles with a subject that contains the word Perl.
=item ~g
Find articles posted in a certain group. Ie:
~g comp.lang.perl.misc
will find all articles posted in clpm.
=item ~dc
Find articles with a certain creation date. Ie:
~dc 1996/12/31
will find all articles posted at the end of 1996.
=back
=head2 SAMPLE QUERIES
The following worked for me, no promises.
./dejaview -v -t -m 1 '(~g comp.lang.perl.misc) & (~s y2k)' > y2k.html
Fetch the last thread dealing with y2k.
./dejaview -v -m 20 '(~g comp.lang.perl.misc) & ~a (Larry & Wall)' > larry_wall.html
Fetch Larry Wall's last 20 articles in clpm.
=head1 ENVIRONMENT
I<dejaview> is not affected by any environment variables.
=head1 ACKNOWLEDGEMENTS
I would like to thank I<Chew Wei Yih> for his I<DejaSearch> program.
If I had not seen it, I probably would have never written I<dejaview>.
I'd also like to thank I<DejaNews>, I<http://www.dejanews.com/corp/> for
archiving usenet (and allowing people to view that archive for free). If
only they'd put a sigdash on their outgoing messages. *sigh*
=head1 BUGS
I<dejaview> has quite a few bugs, the most obvious of which include:
=over 4
=item Reliance on DejaNews's page format
Unfortunatly, this program relies on DejaNews keeping their page exactly the
same. The past has taught us that commercial sites are not legally allowed to
do this, and so in time DejaNews will change their site.
Hopefully the change will be minor and bug fixes will quickly follow.
=item No sorting
I'd like to have the threads sorted (by date, probably), but I wanted to get
this version out to the public. Maybe it'll come later.
=item No help message
There is no way to find out what valid options/languages/sections are.
Use the source, Luke!
=item Deep threading doesn't look good
After you get to about 5 levels deep, it starts to scroll off the edge of the
screen (on my screen, anyway).
=item Threading doesn't work right if an article is missing
If you have two articles from the thread, but there's an article missing
between them, I<dejaview> won't recognize it as a thread.
=item Modems are slow
This is great when I run it on another server and compress it, though. :-)
=item Other stuff
Let me know.
=back
=head1 TODO
I'd like to write another version similar to this one, but that uses pTk.
=head1 AUTHOR
This program was written by Matthew Bafford, I<dragons@dragons.duesouth.net>.
=head1 COPYRIGHT and LICENSE
This program is copyright (c) Matthew Bafford, 1999.
This program is free and open software. You may use, modify, distribute,
and sell this program (and any modified variants) in any way you wish,
provided you do not restrict others from doing the same.
It is requested that you notify the author of all sellings, modifications,
distributings, or usings of this program.
------------------------------
Date: Sun, 9 May 1999 13:42:35 -0400
From: "Mike" <mike-carter@email.msn.com>
Subject: A CGI/PERL that emails data and then post data to an asp page
Message-Id: <utYhROkm#GA.303@cpmsnbbsa05>
I have a cgi script that sends data to 3 email recipients, I need to then
post the same data to an asp page.
This is a shopping cart and I am integrating it with authorize net's secure
cc processing form and I need to send Name Amount Ect to their asp page,
directly from the CGI script, via a POST method.
Any help would be great, I use java and vb script but never perl so I am a
little lost.
Mike
------------------------------
Date: Sun, 09 May 1999 19:19:16 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: A CGI/PERL that emails data and then post data to an asp page
Message-Id: <7h4n22$ruk$1@xenon.inbe.net>
In article <utYhROkm#GA.303@cpmsnbbsa05>, "Mike" <mike-carter@email.msn.com> wrote:
>I have a cgi script that sends data to 3 email recipients, I need to then
>post the same data to an asp page.
>
>This is a shopping cart and I am integrating it with authorize net's secure
>cc processing form and I need to send Name Amount Ect to their asp page,
>directly from the CGI script, via a POST method.
>
>Any help would be great, I use java and vb script but never perl so I am a
>little lost.
>
>Mike
I would highly recommend that you take this question to
comp.infosystems.www.authoring.cgi
In the mean time, also have a look at CGI.pm and the LWP module
at CPAN. And while you're at it, ask authorize net whether they
already have such a CGI, and whether they guarantee not to change
their asp page without notifying you. :-)
Good luck,
Michel.
------------------------------
Date: Sun, 9 May 1999 08:20:04 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: combining data in a text delimited file
Message-Id: <khu3h7.tga.ln@magna.metronet.com>
dejanews@fearsome.net wrote:
: The part of the script that I am stuck on is reading in information from a
: delimited text file and performing clculations on it. The data is read in from
: the text file in the format with a pipe '|' as the delimiter;
: product1|quantity2|price2
: product2|quantity2|price2
: I need to add up the price column of data, but I am unsure how to do this. I
: presume that I have to assign variables to every element, but I am unsure. I
: would prefer to read about this in some documentation rather than be provided
: wih a cut-and-paste solution, since I am trying to learn perl, but I can't
: find any informtion largely because I am unsure exactly of the name of what I
: should be looking for- arrays? sorting? parsing? data mainpulation?
perldoc -f split
remember that | is a regex metacharacter, you need to escape
it to get a literal | character.
@fields = split /\|/, $_;
print "price is $fields[2]\n";
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 09 May 1999 18:28:31 GMT
From: jbritain@home.com (Jim Britain)
Subject: Re: combining data in a text delimited file
Message-Id: <3735cf65.114151017@news>
[Cc: via e-mail]
On Sun, 09 May 1999 14:15:09 GMT, dejanews@fearsome.net wrote:
>Hi,
>
>I am looking for some help with a perl script I am writing, please forgive me
>if this is the incorrect forum for such questions.
>
>The part of the script that I am stuck on is reading in information from a
>delimited text file and performing clculations on it. The data is read in from
>the text file in the format with a pipe '|' as the delimiter;
>
>product1|quantity2|price2
>product2|quantity2|price2
>
>I need to add up the price column of data, but I am unsure how to do this. I
>presume that I have to assign variables to every element, but I am unsure. I
>would prefer to read about this in some documentation rather than be provided
>wih a cut-and-paste solution, since I am trying to learn perl, but I can't
>find any informtion largely because I am unsure exactly of the name of what I
>should be looking for- arrays? sorting? parsing? data mainpulation?
What you are wanting to do, is to split the incoming data -- not
combine it.
The function to separate an individual record into separate elements,
is called -- split -- of all things...
combining data -- to produce output records joined together with a
specified delimiter is called ____
------------------------------
Date: 9 May 1999 18:40:30 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: combining data in a text delimited file
Message-Id: <7h4kqu$5m7$1@gellyfish.btinternet.com>
On Sun, 09 May 1999 14:15:09 GMT dejanews@fearsome.net wrote:
>
> I am looking for some help with a perl script I am writing, please forgive me
> if this is the incorrect forum for such questions.
>
Strangely you seem to have stumbled upon the right place for this
question - I cant detect even the slightest hint of CGI there ;-0
> The part of the script that I am stuck on is reading in information from a
> delimited text file and performing clculations on it. The data is read in from
> the text file in the format with a pipe '|' as the delimiter;
>
> product1|quantity2|price2
> product2|quantity2|price2
>
> I need to add up the price column of data, but I am unsure how to do this. I
> presume that I have to assign variables to every element, but I am unsure. I
> would prefer to read about this in some documentation rather than be provided
> wih a cut-and-paste solution, since I am trying to learn perl, but I can't
> find any informtion largely because I am unsure exactly of the name of what I
> should be looking for- arrays? sorting? parsing? data mainpulation?
>
What you are looking for is the split() function which is documented in
the perlfunc manpage, you will also need to examine the perlre documentation
as the first argument to split() is a regular expression.
You will need to probably look at various other pieces of the Perl
documentation which should indicate themselves as you refer to the
perl manpage.
Anyhow I *will* post an example here just to get you started - the following
reads the data and computes the total cost based on quantity * price
for each product - you will probably want to read a file rather than the
DATA filehandle : look at the documentation for open() in the perlfunc
manpage.
#!/usr/bin/perl -w
use strict;
my %product_total;
while(<DATA>)
{
chomp;
my ($product,$quantity,$price) = split /\|/;
$product_total{$product} += $quantity * $price;
}
for ( keys %product_total )
{
print "$_\t$product_total{$_}\n";
}
__END__
widget|2|1.25
thing|1|25.02
yoyo|5|0.75
widget|7|1.25
thing|99|25.02
yoyo|1|0.75
widget|10|1.25
thing|5|25.02
yoyo|75|0.75
widget|1|1.25
thing|1000|25.02
yoyo|8|0.75
For more detail on the hash used to coalesce the data for each product
can be found in the perldata manpage.
Have fun
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 09 May 1999 15:17:05 -0700
From: N <nospam@atanytimeonthe.net>
Subject: CPAN-POD & pulling my hair OUT! HELP! do the doc's really suck this bad?
Message-Id: <37360961.34FE@atanytimeonthe.net>
I can't beleive how much time I have spent looking through CPAN stuff
trying to find what I would call "struct" - where you would find all the
little variables / calls that you can make to a MODULE.
I thought the whole idea of creating a module is you want other people
to use it's features, so first thing you should show is how to call your
module and then what all the variables / calls names you can make.
Instead I get a big huge half a page on my screen showing NAME,
SYNOPSIS (with like two little lines in it), DESCRIPTION (says a little
story about how the guy made it and such. They should put this crap at
the END, where's the beef???
It should say here's what it does (basicly) here's a example, and then a
list of all the variables / functions to call it with. Where is all this
hiding?
This stuff is WORTHLESS without good documentation, and CPAN you would
think would demand good docs on the operation of a module.
What use is a module if only the "author" knows what it does inside and
has all the source code?
Am I missing something here? Going to the wrong CPAN archive? What? It's
not right up front at the CPAN site! Man this is frustrating.
Text::English wow! what a cool thing, too bad the guy forgot to list
what the hell you call it with.
Net::whateveryouwant where's the STRUCT list? should I just throw
variables at it for the next year till I figure out what it wants?
Well, sorry for complaining but if I am missing this, others may be too.
Thanks, I will come back and read what you have to say.
------------------------------
Date: 9 May 1999 23:57:08 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: CPAN-POD & pulling my hair OUT! HELP! do the doc's really suck this bad?
Message-Id: <7h57ck$71q$1@gellyfish.btinternet.com>
On Sun, 09 May 1999 15:17:05 -0700 N wrote:
> I can't beleive how much time I have spent looking through CPAN stuff
> trying to find what I would call "struct" - where you would find all the
> little variables / calls that you can make to a MODULE.
>
> I thought the whole idea of creating a module is you want other people
> to use it's features, so first thing you should show is how to call your
> module and then what all the variables / calls names you can make.
>
> Instead I get a big huge half a page on my screen showing NAME,
> SYNOPSIS (with like two little lines in it), DESCRIPTION (says a little
> story about how the guy made it and such. They should put this crap at
> the END, where's the beef???
>
<snip bitching about how modules documentation is no good>
Fine. But most of the documentation that I have looked at has perfectly
good documentation of the modules *methods* under the heading (strangely
enough) METHODS. On the whole the documentation for all Perl stuff is
excellent because most Perl programmers are sensitive to the opinion of
their peers (well those in the mainstream anyhow - we all know of some
who couldnt care about that ... )
If you have a problem with any particular piece of documentation please
feel free to submit patches to the modules author, if you feel that the
Community of Perl Authors could require some standards for production
of the documentation please submit some guidelines to the group for
peer review.
If on the other hand you have totally failed to understand the nature
of the Modules (which your use of the term 'Struct' would seem to indicate)
then please just read the responses you get here and try to understand
what people are telling you.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 10 May 1999 00:01:56 -0400
From: Jason Sova <sova0001@algonquinc.on.ca>
Subject: DBI For NT???
Message-Id: <37365A34.FC7056FB@algonquinc.on.ca>
Hey
Thanks guys for your help with my last question but I've seem to
have gotten stuck. I'm looking for DBD::XBase and all the links are
dead. I found it at Jan Pazdziora's Page but it's the unix source. I'm
running a NT Server. What can be done. I'm still new to alot of this
stuff.
Jason
------------------------------
Date: 9 May 1999 19:11:27 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: File::Find non-functional when passing arguments to &wanted
Message-Id: <7h4mkv$a0i$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Charles R. Thompson
<design@raincloud-studios.com>],
who wrote in article <eAjZ2.1477$vP2.1085@news.rdc1.tn.home.com>:
> I'm not sure if I've uncovered a bug in File::Find, but passing
> locally scoped arguments from a sub to &wanted (or my version of)
> clears the default variable in the &wanted sub, thus killing the
> functionality of the module.
???? Parse error.
> perldoc File::Find, Cookbook, Programming Perl have
> been referenced, but none talk about passing arguments with
> this module. It doesn't say you can, doesn't say you can't either.
> I have not seen examples of it in any of the File::Find code
> snippets I've come across so far.
>
> I can't imagine not being able to pass arguments in this manner
> because it keeps the variables scoped 'properly'... Isn't this
> the 'proper' way to do this?
???? Parse error.
Perl has closures/global-variables, so there is no need to restrict
inter-subroutine communication to arguments. An example with a
closure follows:
use File::Find;
sub dof {
my ($d, @args) = @_;
find sub { print "$_: '@args'\n"}, $d;
}
dof('.',1,2,3);
Ilya
------------------------------
Date: Sun, 09 May 1999 21:08:14 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: File::Find non-functional when passing arguments to &wanted
Message-Id: <MPG.119fc3ccb9b7f196989680@news>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <7h4mkv$a0i$1@mathserv.mps.ohio-state.edu>, Ilya Zakharevich
says...
> Perl has closures/global-variables, so there is no need to restrict
> inter-subroutine communication to arguments. An example with a
> closure follows:
>
> use File::Find;
>
> sub dof {
> my ($d, @args) = @_;
> find sub { print "$_: '@args'\n"}, $d;
> }
>
> dof('.',1,2,3);
I think I get you here. I'm really new to a lot of what is thrown my way
terminology wise, so I often find myself asking one more question to make
sure. The example helped. Thanks. After staring at what you sent me for a
minute, I placed my search processing code within find itself...
# pre-search checking here...
find sub {
# do blah de blah processing here
# that was in &findkeywords here
}, 'path/to/search';
# after search stuff here
This worked nicely. From this I can gather that basically anytime I could
call a subroutine, I could probably go this route? I'm pretty certain
this was the concept you were presenting, or did I miss it?
Thanks!
--
Charles R. Thompson
RainCloud Studios
-- posted with evaluation copy of MicroPlanet Gravity(PC) --
--please email me if software causes problems in newsgroup posts--
------------------------------
Date: 9 May 1999 22:28:09 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: File::Find non-functional when passing arguments to &wanted
Message-Id: <7h525p$cng$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Charles R. Thompson
<design@raincloud-studios.com>],
> > Perl has closures/global-variables, so there is no need to restrict
> > inter-subroutine communication to arguments. An example with a
> > closure follows:
> >
> > use File::Find;
> >
> > sub dof {
> > my ($d, @args) = @_;
> > find sub { print "$_: '@args'\n"}, $d;
> > }
> >
> > dof('.',1,2,3);
> find sub {
> # do blah de blah processing here
> # that was in &findkeywords here
> }, 'path/to/search';
>
> # after search stuff here
>
> This worked nicely. From this I can gather that basically anytime I could
> call a subroutine, I could probably go this route?
I'm afraid not using standard terms deeply hinders your
communications.
"Each time something expects a reference to a
subroutine, you can use a reference to an anonymous subroutine",
nothing more.
My example contains more than this: the anonymous subroutine "uses" a
lexical variable declared outside of this subroutine. This makes the
anonymous subroutine into something more, a "closure", which
encapsulates both the subroutine and the data mentioned by the
subroutine.
Rewriting my example:
use File::Find;
sub encapsulate_sub_and_data {
my (@data) = @_;
return sub { print "$File::Find::name: '@data'\n"};
}
find encapsulate_sub_and_data(1,2,3), '.';
may give you more insight. See perl documentation for details.
Hope this helps,
Ilya
P.S. Since two "find"-subroutines have little chance to be used
simultaneously, encapsulation is not that much needed in the
above example.
Probably
use File::Find;
@global_data = (1,2,3);
sub foo { print "$File::Find::name: '@global_data'\n"};
find \&foo, '.';
will work as good as the above example. But *in general* using
global data is much more fragile than closures.
------------------------------
Date: 09 May 1999 15:31:02 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: File::Find non-functional when passing arguments to &wanted
Message-Id: <m1r9opq3ix.fsf@halfdome.holdit.com>
>>>>> "Charles" == Charles R Thompson <design@raincloud-studios.com> writes:
Charles> find(\&findkeywords(@keyword_list), "/drv1/web/sites/web6517e/");
This is almost certainly not doing what you think it may be doing.
You're not passing a reference to &findkeywords to File::Find::find...
you're calling that subroutine *once* in the context of gathering args
to find(), and then passing a reference to the return value of your
subroutine's invocation.
find() wants a coderef. Not an invocation. :)
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Sun, 09 May 1999 23:26:12 GMT
From: design@raincloud-studios.com (Charles R. Thompson)
Subject: Re: File::Find non-functional when passing arguments to &wanted
Message-Id: <MPG.119fe4c6a1252a08989681@news>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <m1r9opq3ix.fsf@halfdome.holdit.com>, Randal L. Schwartz
says...
> This is almost certainly not doing what you think it may be doing.
> You're not passing a reference to &findkeywords to File::Find::find...
> you're calling that subroutine *once* in the context of gathering args
> to find(), and then passing a reference to the return value of your
> subroutine's invocation.
>
> find() wants a coderef. Not an invocation. :)
Ding!
I decided to not move my eyes from the screen until I read this enough
times for it to click (took six if you were curious). Ilya is correct in
that my lack of understanding common terminology is hurting me here. Now
it makes more sense than ever before! Man... that was kind of a dumb
thing to do now that I understand it. Of course it didn't work. :)
--
Charles R. Thompson
RainCloud Studios
--posted with evaluation copy of MicroPlanet Gravity(PC)--
--please email if software causes problems in newsgroup--
------------------------------
Date: Sun, 09 May 1999 20:02:27 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: Free Perl Web Database w/ full source code - comments encouraged - db_Perl_Database_100.zip (0/1)
Message-Id: <37362213.ED15752C@erols.com>
Jeff Vannest wrote:
>
> On Sun, 09 May 1999 04:22:28 GMT, jefflv@usol.com (Jeff Vannest)
> wrote:
> >Here is a little hobby project I've been working for some time now....
>
> It occurs to me that this newsgroup was not the appropriate place to
> post this message - especially with a file attached. My apologies in
> advance (but feel free to flame me anyway, for I apparently deserve
> it!)
>
Don't sweat it. It appears that your attachment ended up in the bit
bucket.
--
Matthew O. Persico
http://www.erols.com/mpersico
http://www.digistar.com/bzip2
------------------------------
Date: Sun, 09 May 1999 23:06:10 GMT
From: jefflv@usol.com (Jeff Vannest)
Subject: Re: Free Perl Web Database w/ full source code - comments encouraged - db_Perl_Database_100.zip (0/1)
Message-Id: <373712f3.125805142@news.usol.com>
On Sun, 09 May 1999 04:22:28 GMT, jefflv@usol.com (Jeff Vannest)
wrote:
>Here is a little hobby project I've been working for some time now....
It occurs to me that this newsgroup was not the appropriate place to
post this message - especially with a file attached. My apologies in
advance (but feel free to flame me anyway, for I apparently deserve
it!)
In part, this is due to the this group's name, which is a misnomer,
for it's purpose seems NOT to be miscellaneous, but regarding quite
specifically perl syntax and language fundamentals.
I have read several messages regarding how this group's name is
appropriate, however its topical latitude still is frequently debated.
I must agree with those who urge a more specific name for this group -
let the .misc cover the .misc.
Again, I apologize.
Sincerely,
Jeff Vannest
------------------------------
Date: Sun, 09 May 1999 15:22:10 -0400
From: Jason Sova <sova0001@algonquinc.on.ca>
Subject: I got a problem need info
Message-Id: <3735E062.F14098BD@algonquinc.on.ca>
Hey
I have resently been asked by my manager to put together a webpage
search page to search my companies intentory for cetain part numbers.
Now the database storing the inventory information is a Visual Fox Pro
5.0 table. My Webserver is IIS running on and NT 4.0 server. I was
thinking about writing the CGI script to preform the search but I'm not
sure if perl can work with a foxpro table. Please if you have any info
I'd really be greatfull.
Jason
sova0001@algonquinc.on.ca
------------------------------
Date: 9 May 1999 21:04:38 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: I got a problem need info
Message-Id: <7h4t96$65u$1@gellyfish.btinternet.com>
On Sun, 09 May 1999 15:22:10 -0400 Jason Sova wrote:
> Hey
> I have resently been asked by my manager to put together a webpage
> search page to search my companies intentory for cetain part numbers.
> Now the database storing the inventory information is a Visual Fox Pro
> 5.0 table. My Webserver is IIS running on and NT 4.0 server. I was
> thinking about writing the CGI script to preform the search but I'm not
> sure if perl can work with a foxpro table. Please if you have any info
> I'd really be greatfull.
Originally I would have recommended using the DBD::XBase module that
is available from CPAN - however I have some recollection that MS
did something to cause FoxPro use the Jet engine. If your files are
still .dbf extensions then you will be alright however you might also
want to look at using the DBD::ODBC module or alternatively Win32::ODBC
depending on your taste - though I would recommend using the DBI/DBD
modules if you might be thinking of changing your platform at some time.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 9 May 1999 20:52:48 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: I got a problem need info
Message-Id: <ebohlmanFBHGo0.Axw@netcom.com>
Jason Sova <sova0001@algonquinc.on.ca> wrote:
: I have resently been asked by my manager to put together a webpage
: search page to search my companies intentory for cetain part numbers.
: Now the database storing the inventory information is a Visual Fox Pro
: 5.0 table. My Webserver is IIS running on and NT 4.0 server. I was
: thinking about writing the CGI script to preform the search but I'm not
: sure if perl can work with a foxpro table. Please if you have any info
: I'd really be greatfull.
DBI with DBD::XBase should do the trick.
------------------------------
Date: Sun, 9 May 1999 16:55:06 -0400
From: Matthew Amster-Burton <mamster@mamster.net>
Subject: Re: I got a problem need info
Message-Id: <Pine.GSO.3.96.990509165231.22125A-100000@wired.your-site.com>
On Sun, 9 May 1999, Jason Sova wrote:
> I have resently been asked by my manager to put together a webpage
> search page to search my companies intentory for cetain part numbers.
> Now the database storing the inventory information is a Visual Fox Pro
> 5.0 table. My Webserver is IIS running on and NT 4.0 server. I was
> thinking about writing the CGI script to preform the search but I'm not
> sure if perl can work with a foxpro table. Please if you have any info
> I'd really be greatfull.
You want the DBI module, which provides an API to talk to a number of
relational databases. The DBI home page is at
<http://www.symbolstone.org/technology/perl/DBI/index.html>. In addition
to DBI itself, you'll need a DBD (driver) module for your particular
database. You have two choices: DBD::XBase to interface directly with
the file, or DBD::ODBC to use ODBC on Windows. I'd probably go with the
latter if it's going to live permanently on NT.
Good luck,
Matthew
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5613
**************************************