[22978] in Perl-Users-Digest
Perl-Users Digest, Issue: 5198 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 9 21:12:46 2003
Date: Wed, 9 Jul 2003 18:10:52 -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 Wed, 9 Jul 2003 Volume: 10 Number: 5198
Today's topics:
Re: Dynamically generating multi-table SQL <nospam@nospam.com>
Re: Dynamically generating multi-table SQL (John D)
Re: Dynamically generating multi-table SQL (Bart Van der Donck)
Re: Dynamically generating multi-table SQL (Bryan Castillo)
email script <spedwards@qwest.net>
Re: email script <bwalton@rochester.rr.com>
Re: email script <theaney@cablespeed.com>
Fastest way to build a hash (=?ISO-8859-1?Q?Stefan_Fischerl=E4nder?=)
Re: Fastest way to build a hash <REMOVEsdnCAPS@comcast.net>
Find string in web page (Kirk Larsen)
Re: Find string in web page (Greg Bacon)
Getting started with Perl <carpenti@cerfacs.fr>
Re: Getting started with Perl <willis_31_40@yahoo.com>
Re: Getting started with Perl <sv99oya02@sneakemail.com>
Grabbing certain section of a string <me@helpme.com>
Re: Grabbing certain section of a string <abigail@abigail.nl>
Re: Grabbing certain section of a string <mbudash@sonic.net>
Re: Hanging pipes in CGI Perl <cbaegert-pas-de-spam@europeanservers.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 9 Jul 2003 01:39:09 +1000
From: "Gregory Toomey" <nospam@nospam.com>
Subject: Re: Dynamically generating multi-table SQL
Message-Id: <6lBOa.4755$oN.189931@newsfeeds.bigpond.com>
"Jesse Sheidlower" <jester@panix.com> wrote in message
news:bed7hg$mqr$1@panix2.panix.com...
>
> I'm trying to automatically generate multi-table SQL
> statements from a Web environment, and am having a lot of
> difficulty doing it in a way that doesn't feel kludgy to
> me. I've looked at various sites and books, but they tend to
> focus on situations where multi-table joins are fixed--you
> want the same results every time, so form of the query never
> changes.
This may give you some ideas. I use a subroutine "sql" to return an SQL
statement in this example.I generate the various parts of the sql statement
depending on various conditions.
I use the sub{..}->() inline subroutine to add extra tables into the 'from'
statement.
The join(" and ", grep {$_} part adds extra 'and' into the' where' clause.
sub sql {
return "select \$column_list
from ipo".
sub {return ",ipo_underwriter " if !all
$in{underwriter}}->().
sub {return ' where visible="Y" and ' if (!all
$in{underwriter})||(!all $in{industry})||(!all $in{year})}->().
join(" and ", grep {$_}
(
sub {return "ipo.ipo_id=ipo_underwriter.ipo_id and
ipo_underwriter.underwriter_id in @{[sql_in($in{underwriter})]}" if !all
$in{underwriter}}->(),
sub {return "(industry_group_no in
@{[sql_in($in{industry})]} or sub_group_no in @{[sql_in($in{industry})]})"
if !all $in{industry}}->(),
sub {return "year(ipo_dt) in @{[sql_in($in{year})]}"
if !all $in{year}}->())
).
" order by \$order_by "
}
gtoomey
------------------------------
Date: 8 Jul 2003 10:39:55 -0700
From: johndageek@yahoo.com (John D)
Subject: Re: Dynamically generating multi-table SQL
Message-Id: <c608545f.0307080939.8028513@posting.google.com>
jester@panix.com (Jesse Sheidlower) wrote in message news:<bed7hg$mqr$1@panix2.panix.com>...
> I'm trying to automatically generate multi-table SQL
> statements from a Web environment, and am having a lot of
> difficulty doing it in a way that doesn't feel kludgy to
> me. I've looked at various sites and books, but they tend to
> focus on situations where multi-table joins are fixed--you
> want the same results every time, so form of the query never
> changes.
>
> Suppose you have the archetypal CD database. If all the
> information is in a single table, you just have "SELECT
> artist, album, song FROM cd WHERE..." If you don't want the
> song, or want the label, you just drop or add it to the SELECT
> list. But if the data is in related tables, with, say, "album"
> as the main table, "artist" and "label" keyed to the album id,
> and "song" tied in via a separate join table, it gets much
> worse. If you only want the album, you have "SELECT album
> FROM album WHERE...", but if you want the artist too, it
> becomes "SELECT artist.artist, album.album FROM artist, album
> WHERE...AND artist.album_id = album.id", and so forth; if you
> want to search on "artist" and "song" only, you have to know that
> they can only be connected by bringing in "album" as well, so
> you end up with a four-table join.
>
> And this is a very simple example; real ones could involve
> larger sets of tables with more complex relationships that
> could be searched in more different ways.
>
> The way I've been working so far is to have an array
> @tables_needed and push the table names onto it as they
> are required, and then uniquing the array at the end; and
> also having a table with the basic WHERE clause elements
> for the join (e.g. "artist.album_id = album.id") and
> similarly adding that to my constructed WHERE clause. But
> while this works, it looks ugly and is hard to maintain,
> and I also haven't been able to figure out (except by
> hard-coding all possible examples) how to bring in
> intermediate required tables, or how to handle the need
> to write certain queries as LEFT JOINs rather than INNER
> JOINs depending on the query.
>
> I'd be grateful for any suggestions for approaches, or
> pointers to sample code, etc.
>
> Thanks.
>
> Jesse Sheidlower
this is not a perl question.
That said,
before posting to a database forum you may want to decide how much
mnormalization is needed for your data, how many entries would be
possible in your application, estimated number of hits pe rtime period
you expect to take.
Programming multi table joins can be a pain, but assuming you know all
of the tables you may need, plus which user input will cause a given
table to be needed someting along the line of the following psuedo
code would work.
$from = "album_table" ## assume album is needed in all cases
$where = "" ## start blank
$fields = "album_name" # lets get the album name
if (user_entered_artist)
{
$from = $from . ",artist_table";
}
if ($where eq "")
{
$where = "Where album_table.id = artist_table.album_id";
}
else
{
$where = "and album_table.id = artist_table.album_id";
}
and so on (welcome to the joys of database programming)
good luck
JD
------------------------------
Date: 8 Jul 2003 12:11:37 -0700
From: bart@nijlen.com (Bart Van der Donck)
Subject: Re: Dynamically generating multi-table SQL
Message-Id: <b5884818.0307081111.2a378a24@posting.google.com>
jester@panix.com (Jesse Sheidlower) wrote in message news:<bed7hg$mqr$1@panix2.panix.com>...
> I'm trying to automatically generate multi-table SQL
> statements from a Web environment, and am having a lot of
> difficulty doing it in a way that doesn't feel kludgy to
> me. I've looked at various sites and books, but they tend to
> focus on situations where multi-table joins are fixed--you
> want the same results every time, so form of the query never
> changes.
>
> Suppose you have the archetypal CD database. If all the
> information is in a single table, you just have "SELECT
> artist, album, song FROM cd WHERE..." If you don't want the
> song, or want the label, you just drop or add it to the SELECT
> list. But if the data is in related tables, with, say, "album"
> as the main table, "artist" and "label" keyed to the album id,
> and "song" tied in via a separate join table, it gets much
> worse. If you only want the album, you have "SELECT album
> FROM album WHERE...", but if you want the artist too, it
> becomes "SELECT artist.artist, album.album FROM artist, album
> WHERE...AND artist.album_id = album.id", and so forth; if you
> want to search on "artist" and "song" only, you have to know that
> they can only be connected by bringing in "album" as well, so
> you end up with a four-table join.
>
> And this is a very simple example; real ones could involve
> larger sets of tables with more complex relationships that
> could be searched in more different ways.
>
> The way I've been working so far is to have an array
> @tables_needed and push the table names onto it as they
> are required, and then uniquing the array at the end; and
> also having a table with the basic WHERE clause elements
> for the join (e.g. "artist.album_id = album.id") and
> similarly adding that to my constructed WHERE clause. But
> while this works, it looks ugly and is hard to maintain,
> and I also haven't been able to figure out (except by
> hard-coding all possible examples) how to bring in
> intermediate required tables, or how to handle the need
> to write certain queries as LEFT JOINs rather than INNER
> JOINs depending on the query.
>
> I'd be grateful for any suggestions for approaches, or
> pointers to sample code, etc.
>
> Thanks.
>
> Jesse Sheidlower
Jesse,
Writing queries that relate more than 2 tables can easily become very
(too) complex. If you're dealing with an exisiting structure, then you
maybe have no choice than using the data as they are provided. But you
can avoid growing complexity in queries even then. When I have more
than 2 tables to join, I generally use a more transparent construction
by splitting the query up into hashes that hold the matching results
from a table. But generally it depends on the sizes of the different
tables what will be the best option for you.
Here under an example. I suppose you connect through DBI since you
posted on a perl ng.
# find artistnames that match user input
$query = $db->prepare("SELECT ArtistID from Artists WHERE ArtistName
REGEXP '$userinput'");
$query->execute; $numrows = $query->rows;
while (@array = $query->fetchrow_array)
{
push @artistIDs,$array[0];
$ARTIST{$array[0]}=$array[1];
}
$extendquery = "WHERE (ArtistID='";
$extendquery. = join "' OR ArtistID='",@artistIDs;
$extendquery. = "')";
# find the songs
$query = $db->prepare("SELECT SongTitle, ArtistID from Songs
$extendquery");
$query->execute; $numrows = $query->rows;
while (@array = $query->fetchrow_array)
{
($title, $artistID) = @array;
print "Song: $title, Artist: $ARTIST{$artistID} \n";
}
If you do this for CD names and labels, you will have a clear view of
the queries and what they do.
No loss of speed because the tables need to be searched anyway when
you would have joined it. Alternatively, you could make the string
$extendedquery out of hash %ARTISTS (you would save the memory of the
array with that). However, you need to think about the structure of
your data so that no tons of variables are generated that slow down
the app.
Other elements like select, radio, checkbox in your web form should
not be handled like this because you can assign the ID's directly in
their value-attributes.
Another approach could be to alter the table structure before
developing the API. If you have that possibility. Some time ago I did
a similar job as you are doing now, but it was a structure yet to
built up. Generally we had 2 choices: would we put the data in 1 table
or relate them by putting it into more tables?
We chose for option 1 and until today I never regretted that for a
second.
Considering good db design we should have put it in more tables, but
in our case the speed, maintainability and code transparency was more
important. Speed is better because queries need to search only 1
table, however the table holds some identical data (such as here: CD
titles, artist names). Maintainability and transparency: definitely
better. Of course the general structure of the data must be somewhat
convenient to put it into one single table. I have learned to not
immediately think "This must definitely be in separate tables".
Or, if you have the possibility, e.g. only relate the Artists and put
the other stuff into 1 large table. Or why not make some perl job to
create a new table for you exactly as you want to have it.
Hope this helps
Bart
------------------------------
Date: 8 Jul 2003 22:55:20 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Dynamically generating multi-table SQL
Message-Id: <1bff1830.0307082155.13a4950b@posting.google.com>
jester@panix.com (Jesse Sheidlower) wrote in message news:<bed7hg$mqr$1@panix2.panix.com>...
> I'm trying to automatically generate multi-table SQL
> statements from a Web environment, and am having a lot of
> difficulty doing it in a way that doesn't feel kludgy to
> me. I've looked at various sites and books, but they tend to
> focus on situations where multi-table joins are fixed--you
> want the same results every time, so form of the query never
> changes.
>
Are you familiar with OO perl? If so, I would suggest you
use a class to build the SQL statements. Im working on a project
right now that creates a sql statement using fields and values
submitted from an HTML form. Depending, on what fields are specified
I will either use INNER of LEFT joins, and some fields will support
multiple values i.e. "where id in (1,2,3)"
I have one abstract class SimpleSQLBuilder. It has methods:
- init
* An empty method, which is used so child classes can
initialize state.
- addFieldCondition
* 1st parameter is the field name and the rest are the values
supports 1 to N values.
* This method then calls a method set<FieldName> on itself
passing the values to this method. A child class should
define these methods.
- getSql
* A child class should define this method to return the
SQL statement
I then have a child class which inherits from this class
In init it will set up variables for each part of the statement
and the initial join types for each table.
As each set method is called it will add the condition to the
where clause. If a field is specified in a joined table,
that table will be promoted from a LEFT join to an INNER join.
The class also keeps track of whether or not AND's are needed.
The methods may also provide validation.
Finally, the getSql method assembles the parts.
The driving code is very clean with this approach:
It is something like:
my $cgi = CGI->new;
my $sqlbuilder = CktxSqlBuilder->new;
foreach my $var (qw{merid acqid aba nacct dlstate dlnum}) {
$sqlbuilder->addFieldCondition($var, $cgi->param($var));
}
my $sql = $sqlbuilder->getSql;
All of the state information is stored in CktxSqlBuilder, and
since the parent class forces you to define a method for
each field condition in order to work, it keeps the code
a little more manageable (IMHO).
> Suppose you have the archetypal CD database. If all the
<snip>
>
> And this is a very simple example; real ones could involve
> larger sets of tables with more complex relationships that
> could be searched in more different ways.
>
> The way I've been working so far is to have an array
> @tables_needed and push the table names onto it as they
> are required, and then uniquing the array at the end; and
That makes sense, it might be easier to use a hash since you
are removing duplicate elments from the array at the end
anyway. The tables_needed (array or hash) would be a data member of an
SqlBuilder object in my description above.
> also having a table with the basic WHERE clause elements
> for the join (e.g. "artist.album_id = album.id") and
> similarly adding that to my constructed WHERE clause. But
> while this works, it looks ugly and is hard to maintain,
This is probably hard to maintain if you have all of the state
information mixed with the other parts of the code.
Are you using a lot of global variables?
> and I also haven't been able to figure out (except by
> hard-coding all possible examples) how to bring in
> intermediate required tables, or how to handle the need
> to write certain queries as LEFT JOINs rather than INNER
> JOINs depending on the query.
Here are some snippets of stuff I was working on.
(these parts are untested and just parts not whole
for one there is no validation here)
This kind of shows how I am handling the JOIN types.
sub init {
my $self = shift;
.... other init stuff....
# setup the default join types
$self->{joining_tables} = {
acquirer => {required=>1, join_type=>'LEFT'},
micr => {required=>1, join_type=>'LEFT'},
dl => {required=>1, join_type=>'LEFT'},
terminal => {required=>0, join_type=>'LEFT'}
};
}
# here is a method that would be called to set a
# field that is in the micr table.
# Since this is part of the search criteria
# I will want an INNER join instead of a LEFT join.
sub setAba {
my $self = shift;
$self->addCondition("aba = '".$_[0]."');
$self->{joining_tables}{micr}{join_type} = 'INNER';
}
# I use this method just to keep track of whether or not
# I need an AND or not
sub addCondition {
my $self = shift;
if (!$self->{clauses}++) {
$self->{sql_where} .= ' AND ';
}
$self->{sql_where} .= $_[0];
}
>
> I'd be grateful for any suggestions for approaches, or
> pointers to sample code, etc.
>
> Thanks.
>
> Jesse Sheidlower
I hope this made some sense.
------------------------------
Date: Tue, 8 Jul 2003 18:02:52 -0600
From: "Shawn" <spedwards@qwest.net>
Subject: email script
Message-Id: <r%IOa.82$nW5.140108@news.uswest.net>
Hi,
I have been using the below script to attach text files to a email and send
the email to whoever. But, I'd like to change the file Type to attach a
Excel file instead of a text file. What type of changes would I need to
make?
Thanks,
Shawn
#!/usr/local/bin/perl5.6
use lib "lib";
use MIME::Lite;
$msg = new MIME::Lite
From => "$ARGV[0]",
To => "$ARGV[1]",
Subject => "$ARGV[2]",
Type => 'TEXT',
Path => "$ARGV[3]",
Encoding => '7bit';
attach $msg
Type => 'TEXT',
Path => "$ARGV[4]",
Filename => "$ARGV[5]";
$msg->send;
--
------------------------------
Date: Wed, 09 Jul 2003 00:31:09 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: email script
Message-Id: <3F0B6243.90902@rochester.rr.com>
Shawn wrote:
...
> I have been using the below script to attach text files to a email and send
> the email to whoever. But, I'd like to change the file Type to attach a
> Excel file instead of a text file. What type of changes would I need to
> make?
...
> Shawn
>
> #!/usr/local/bin/perl5.6
>
> use lib "lib";
> use MIME::Lite;
>
> $msg = new MIME::Lite
> From => "$ARGV[0]",
> To => "$ARGV[1]",
> Subject => "$ARGV[2]",
> Type => 'TEXT',
> Path => "$ARGV[3]",
> Encoding => '7bit';
> attach $msg
> Type => 'TEXT',
> Path => "$ARGV[4]",
> Filename => "$ARGV[5]";
> $msg->send;
Try [untested]:
...
attach $msg
Type => 'application/msexcel',
Disposition=>'attachment',
Path => "$ARGV[4]",
Filename => "$ARGV[5]";
...
--
Bob Walton
------------------------------
Date: Tue, 08 Jul 2003 20:47:12 -0400
From: Tim Heaney <theaney@cablespeed.com>
Subject: Re: email script
Message-Id: <87k7asplv3.fsf@mrbun.watterson>
"Shawn" <spedwards@qwest.net> writes:
>
> I have been using the below script to attach text files to a email and send
> the email to whoever. But, I'd like to change the file Type to attach a
> Excel file instead of a text file. What type of changes would I need to
> make?
The Type is a MIME type, so just substitute
Type => 'application/x-msexcel',
for the second
> Type => 'TEXT',
I hope this helps,
Tim
------------------------------
Date: 9 Jul 2003 16:28:10 -0700
From: fischerlaender@gmx.de (=?ISO-8859-1?Q?Stefan_Fischerl=E4nder?=)
Subject: Fastest way to build a hash
Message-Id: <ff9bee6c.0307091528.5d0b71a1@posting.google.com>
I've got the following situation:
My data is stored in a file; 5 bytes form one record. The bytes 0 to 3
are a long integer, which is regarded as the key, wheras byte 4 is the
value. I have to read this data structure into a hash.
What I'm doing at the moment is:
open(IN,"<file");
while(read(IN, $buf, 5))
{
$hash{unpack("L", substr($buf,0,4))} = substr($buf,4,1);
}
close(IN);
This takes about 5 seconds to read a file with about 100.000 records,
which is to long for my needs. (Celeron 800, IDE 7200rpm)
I figured out that the bottleneck isn't the I/O, because this version
takes as long as the script above:
open(IN,"<file")
$bread = read(IN, $buf, 1000000) / 5;
close(IN);
for($i=0;$i<$bread;$i++)
{
$hash{unpack("L", substr($buf,$i*5,4))} = substr($buf,$i*5+4,1);
}
Does anyone have any ideas how to build this hash faster? It would
also be possible to change the format of the data file. I already did
experiments with store and retrieve from the Storable module and with
a permanent hash with DB_File. In both cases the data file grew, while
the script was even slower.
Stefan
------------------------------
Date: Wed, 09 Jul 2003 19:38:59 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Fastest way to build a hash
Message-Id: <Xns93B3D20B7EA76sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
fischerlaender@gmx.de (Stefan Fischerländer) wrote in
news:ff9bee6c.0307091528.5d0b71a1@posting.google.com:
> I've got the following situation:
>
> My data is stored in a file; 5 bytes form one record. The bytes 0 to 3
> are a long integer, which is regarded as the key, wheras byte 4 is the
> value. I have to read this data structure into a hash.
>
> What I'm doing at the moment is:
> open(IN,"<file");
> while(read(IN, $buf, 5))
> {
> $hash{unpack("L", substr($buf,0,4))} = substr($buf,4,1);
> }
> close(IN);
>
> This takes about 5 seconds to read a file with about 100.000 records,
> which is to long for my needs. (Celeron 800, IDE 7200rpm)
Untested, but my first thought is:
$/ = undef;
$raw = <IN>; # slurp whole file
%hash = $raw =~ /(....)(.)/gs; # split into 4, 1 byte pairs
(Note: untested)
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPwy1mWPeouIeTNHoEQKsSgCg2l2gpuew2T2wuY79MCaIyDdMLsgAn1Ke
/fZKEVdWPNi7oJOpwLhmQNII
=zYBt
-----END PGP SIGNATURE-----
------------------------------
Date: 9 Jul 2003 11:19:37 -0700
From: spamme@kirklarsen.com (Kirk Larsen)
Subject: Find string in web page
Message-Id: <4628ab88.0307091019.17e73755@posting.google.com>
Sounds simple enough. I need to retrieve the source from a web page
and then find a link in that web page that ends with a string which I
have stored in a variable. Can someone please post or direct me to a
sample of how to do this? Thanks!
------------------------------
Date: Wed, 09 Jul 2003 20:48:29 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Find string in web page
Message-Id: <vgovst6ppdil2d@corp.supernews.com>
In article <4628ab88.0307091019.17e73755@posting.google.com>,
Kirk Larsen <spamme@kirklarsen.com> wrote:
: Sounds simple enough. I need to retrieve the source from a web page
: and then find a link in that web page that ends with a string which I
: have stored in a variable. Can someone please post or direct me to a
: sample of how to do this? Thanks!
Try this on for size:
% cat try
#! /usr/local/bin/perl
use strict;
use warnings;
use HTML::Parser;
use LWP::UserAgent;
use URI::URL;
use Data::Dumper;
sub make_parser {
my $inside;
my %attr;
my $text;
my @links;
my $record = sub {
my $state = Dumper {
inside => $inside,
attr => \%attr,
text => $text,
};
my @cond = (
[ sub { $state }, "not inside" ],
[ sub { %attr }, "no attr" ],
[ sub { $attr{href} }, "no href" ],
);
my $ok = 1;
for (@cond) {
my($check,$msg) = @$_;
unless ($check->()) {
warn "$0: $msg:\n$state ";
$ok = 0;
}
}
push @links => [ $text || '<empty>', $attr{href} ] if $ok;
$inside = 0;
%attr = ();
$text = '';
};
my $start_h = sub {
my $tag = shift;
return unless $tag eq 'a';
if ($inside) {
warn "$0: already inside";
$record->();
}
my $attr = shift;
return unless $attr->{href};
%attr = %$attr;
$inside = 1;
};
my $text_h = sub {
return unless $inside;
$text .= shift;
};
my $end_h = sub {
my $tag = shift;
return unless $tag eq 'a';
return unless $inside;
$record->();
};
my $p = HTML::Parser->new(
api_version => 3,
start_h => [ $start_h, "tagname, attr" ],
text_h => [ $text_h, "dtext" ],
end_h => [ $end_h, "tagname" ],
);
($p, sub { @links });
}
sub usage () { "Usage: $0 search-pattern\n" }
## main
die usage unless @ARGV;
my $pat = shift;
my $lookfor = eval { qr/$pat/ };
die "$0: bad pattern: $pat" unless $lookfor;
my $url = "http://www.cpan.org/";
my $ua = LWP::UserAgent->new;
my($p,$links) = make_parser;
# Request document and parse it as it arrives
my $res = $ua->request(
HTTP::Request->new(GET => $url),
sub { $p->parse($_[0]) }
);
my $base = $res->base;
for ($links->()) {
my($text,$href) = @$_;
next unless $text =~ /$lookfor$/;
my $url = url($href, $base)->abs;
$text =~ s/\s+/ /g;
print "$text:\n $url\n";
}
% ./try 's$'
Perl modules:
http://www.cpan.org/modules/index.html
Perl scripts:
http://www.cpan.org/scripts/index.html
Perl recent arrivals:
http://www.cpan.org/RECENT.html
CPAN sites:
http://www.cpan.org/SITES.html
CPAN sites:
http://mirrors.cpan.org/
CPAN modules, distributions, and authors:
http://search.cpan.org/
CPAN Frequently Asked Questions:
http://www.cpan.org/misc/cpan-faq.html
Perl Mailing Lists:
http://lists.cpan.org/
Perl Bookmarks:
http://bookmarks.cpan.org/
% ./try '('
./try: bad pattern: ( at ./try line 95.
Hope this helps,
Greg
--
In a system of full capitalism, there should be (but, historically, has not
yet been) a complete separation of state and economics, in the same way and
for the same reasons as the separation of state and church.
-- Ayn Rand
------------------------------
Date: Wed, 09 Jul 2003 16:26:03 +0200
From: Bruno Carpentieri <carpenti@cerfacs.fr>
Subject: Getting started with Perl
Message-Id: <3F0C25FB.1060804@cerfacs.fr>
Hi all.
I would like to learn the Perl language, and I have
the following two very basic questions:
1) what is the best Perl distribution for Windows XP
to get started (I will work on a laptop) ? Is the
Active Perl from Activestate reliable ?
2) Can anyone suggest me any online documentation,
most preferably into one single PS or PDF file ?
Many thanks for any information.
Bruno Carpentieri
carpenti@cerfacs.fr
------------------------------
Date: Wed, 09 Jul 2003 15:03:34 GMT
From: w i l l <willis_31_40@yahoo.com>
Subject: Re: Getting started with Perl
Message-Id: <2kbogvkgv644mrtcfnoaqlb3s4ukpcvv2c@4ax.com>
1) Activestate has been reliable for me for years, just get the latest
version off of their website.
2) perldoc.com has all the man pages online
good luck with it.
w i l l
On Wed, 09 Jul 2003 16:26:03 +0200, Bruno Carpentieri
<carpenti@cerfacs.fr> wrote:
>Hi all.
>
>I would like to learn the Perl language, and I have
>the following two very basic questions:
>
>1) what is the best Perl distribution for Windows XP
> to get started (I will work on a laptop) ? Is the
> Active Perl from Activestate reliable ?
>
>2) Can anyone suggest me any online documentation,
> most preferably into one single PS or PDF file ?
>
>Many thanks for any information.
>
>Bruno Carpentieri
>carpenti@cerfacs.fr
------------------------------
Date: Wed, 09 Jul 2003 17:12:13 +0200
From: =?ISO-8859-1?Q?Steffen_M=FCller?= <sv99oya02@sneakemail.com>
Subject: Re: Getting started with Perl
Message-Id: <behbc2$ef6$1@news.rz.uni-karlsruhe.de>
Bruno Carpentieri wrote:
> I would like to learn the Perl language, and I have
> the following two very basic questions:
>
> 1) what is the best Perl distribution for Windows XP
> to get started (I will work on a laptop) ? Is the
> Active Perl from Activestate reliable ?
It is.
> 2) Can anyone suggest me any online documentation,
> most preferably into one single PS or PDF file ?
I doubt you'll find a good pdf/ps tutorial / reference. I suggest you do
the following:
1) Buy a book. They don't cost the world and help a lot. I suggest going
with "Learning Perl".
2) Make yourself *very* comfortable with the tons of documentation that
come with perl. (perldoc and also the HTML docs that come with AS Perl.)
3) perldoc.com if you need it online at all costs.
4) Read comp.lang.perl.*
5) Think about investing a few bucks in more advanced literature like
the "Perl Cookbook", "Programming Perl", "Advanced Perl
Programming"(=Panther book), "Object-oriented Perl", etc.
Learning from books really helps. Other than that, I was rather
impressed with the pace of http://www.eecs.tufts.edu/g/150PPP/ which I
didn't attend, but if you manage to complete the assignments of this
course, you're well on your way.
HTH,
Steffen
--
@n=([283488072,6076],[2105905181,8583184],[1823729722,9282996],[281232,
1312416],[1823790605,791604],[2104676663,884944]);$b=6;@c=' -/\_|'=~/./g
;for(@n){for$n(@$_){map{$h=int$n/$b**$_;$n-=$b**$_*$h;$c[@c]=$h}reverse
0..11;push@p,map{$c[$_]}@c[reverse$b..$#c];$#c=$b-1}$p[@p]="\n"}print@p;
------------------------------
Date: Wed, 09 Jul 2003 14:53:14 GMT
From: "Desmo" <me@helpme.com>
Subject: Grabbing certain section of a string
Message-Id: <94724eff9e851813349be69596df5d41@free.teranews.com>
If I have a rather long string like "blah blah
blah.....filename="intent.doc"...blah blah
blah...filename="second.doc"....blah blah", and I want to assign the words
between the quotation marks after filename= to variables, is there a quick
and easy way of doing it?
--
Ryan Carrier
ISA CCST III
Fraser Papers, Inc.
(207) 728-8601
ryanc@madawaska.fraserpapers.com
------------------------------
Date: 09 Jul 2003 14:55:16 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Grabbing certain section of a string
Message-Id: <slrnbgob6k.q45.abigail@alexandra.abigail.nl>
Desmo (me@helpme.com) wrote on MMMDXCIX September MCMXCIII in
<URL:news:94724eff9e851813349be69596df5d41@free.teranews.com>:
@@ If I have a rather long string like "blah blah
@@ blah.....filename="intent.doc"...blah blah
@@ blah...filename="second.doc"....blah blah", and I want to assign the words
@@ between the quotation marks after filename= to variables, is there a quick
@@ and easy way of doing it?
Assuming the string is in $str:
my @filenames = $str =~ /filename="([^"]*)"/g;
Abigail
--
# Count the number of lines; code doesn't match \w. Linux specific.
()=<>;$!=$=;($:,$,,$;,$")=$!=~/.(.)..(.)(.)..(.)/;
$;++;$*++;$;++;$*++;$;++;`$:$,$;$" $. >&$*`;
------------------------------
Date: Wed, 09 Jul 2003 15:09:00 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Grabbing certain section of a string
Message-Id: <mbudash-E41A38.08090209072003@typhoon.sonic.net>
In article <94724eff9e851813349be69596df5d41@free.teranews.com>,
"Desmo" <me@helpme.com> wrote:
> If I have a rather long string like "blah blah
> blah.....filename="intent.doc"...blah blah
> blah...filename="second.doc"....blah blah", and I want to assign the words
> between the quotation marks after filename= to variables, is there a quick
> and easy way of doing it?
@filenames = $longstring =~ /"([^"]+)"/g;
hth-
--
Michael Budash
------------------------------
Date: Tue, 08 Jul 2003 22:20:54 +0200
From: Christophe Baegert <cbaegert-pas-de-spam@europeanservers.net>
Subject: Re: Hanging pipes in CGI Perl
Message-Id: <bef936$1s9b$1@biggoron.nerim.net>
Hello,
Bob Walton wrote:
> *please* copy/paste working code, don't just type it in!!!
Sorry, this is my prog A.
-----------------------------------------------------------------------------
#!/usr/local/bin/perl
use warnings;
$|=1;
print "Content-type: text/html\n\ntest";
$text="To: xxxx\@yyyyy.zzz\nFrom: xxxx\@yyyyy.zzz\nSubject: test\n\ntest";
open(MAIL,'|/home/xxx/cgi-bin/B.pl') or die "error : $!";
print MAIL $text;
close MAIL;
-----------------------------------------------------------------------------
This is my prog B.
-----------------------------------------------------------------------------
#!/usr/local/bin/perl
open(FILE,'>/tmp/file') or die "$!";
while($line=<STDIN>){
print FILE $line;
}
close FILE;
-----------------------------------------------------------------------------
It runs well under bash, but it displays nothing, without error and without
exiting under CGI.
When I comment the last three lines of prog A, it runs well even under CGI.
Regards,
Christophe.
------------------------------
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 5198
***************************************