[17899] in Perl-Users-Digest
Perl-Users Digest, Issue: 59 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 14 14:07:52 2001
Date: Sun, 14 Jan 2001 11:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979499110-v10-i59@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 14 Jan 2001 Volume: 10 Number: 59
Today's topics:
[Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
ANNOUNCE: DDL::Oracle v0.32 <rvsutherland@yahoo.com>
ANNOUNCE: HTTP::WebTest 0.01 <starfire@zipcon.net>
ANNOUNCE: Mail::Audit 1.6 is available <simon@brecon.co.uk>
ANNOUNCE: Text::Balanced 1.82 (Damian Conway)
Re: Can't associate .PL files in Win98 (David Efflandt)
Re: Can't associate .PL files in Win98 dtbaker_dejanews@my-deja.com
Re: converting a form value (Honza Pazdziora)
Re: csv revisited <bart.lateur@skynet.be>
Re: Help me append (David Efflandt)
how to test if $a is part of $b?? <ja@nee.snee>
Re: how to test if $a is part of $b?? (Martien Verbruggen)
Re: how to test if $a is part of $b?? <mikecook@cigarpool.com>
overload not autogenerating as expected mintcake@my-deja.com
Re: overload not autogenerating as expected <artd@artd3.com>
Re: Parsing the URL for Hidden variables <nospam.newton@gmx.li>
Perl's garbage collection <ubl@schaffhausen.de>
Q: Altering wav file speed robert_meineke@my-deja.com
Regexp for XML <c-kleinheitz@freenet.de>
Re: Regexp for XML (Garry Williams)
Re: RegExp substitution w/Array Dereference <baldheadedjohn@SpamAnyone?newsguy.com>
Re: Syntactic symbol for continuing one line into anoth <bart.lateur@skynet.be>
Re: Syntactic symbol for continuing one line into anoth <flavell@mail.cern.ch>
Re: word combinations? egwong@netcom.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 14 Jan 2001 11:20:51 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage979471445.29338@news.teleport.com>
Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 29 Apr 2000
[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
of 1998; of course, ongoing updates are made as needed. ]
For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).
http://www.cpan.org/doc/FAQs/
Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.
For an alternative way to get answers, check out the Perlfaq website.
http://www.perlfaq.com/
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.
perldoc perlfaq
man perlfaq
If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.
If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.
http://www.cpan.org/
http://www.perl.com/CPAN/
http://www.cpan.org/doc/FAQs/FAQ/html/
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/
You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)
California ftp://ftp.cdrom.com/pub/perl/CPAN/
Texas ftp://ftp.metronet.com/pub/perl/
South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
Australia ftp://cpan.topend.com.au/pub/CPAN/
Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.
Have fun with Perl!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 14 Jan 2001 13:19:02 -0500
From: "Richard Sutherland" <rvsutherland@yahoo.com>
Subject: ANNOUNCE: DDL::Oracle v0.32
Message-Id: <t63s14508jd1cf@corp.supernews.com>
==========================================================================
Release of version 0.32 of DDL::Oracle
==========================================================================
NAME
DDL::Oracle - a DDL generator for Oracle release 7.3, 8.0 and 8i
databases.
CHANGES
Modified the CREATE TABLESPACE statement to allow for 8i's specialized
CREATE TEMPORARY TABLESPACE feature.
Modified the 'resize' method for tables to include ALTER INDEX REBUILD
statements for affected indexes. Such indexes become UNUSABLE during the
move of a table and/or its [SUB]PARTITIONs.
Included new wrapper script 'query.pl', which prompts for the name of a
file. The file should contain a query which returns OWNER and NAME of
objects, via any arbitrary WHERE clause. This lets the user without
knowledge of Perl generate DDL for lists of objects of any type.
DESCRIPTION
Overview
Designed for Oracle DBA's and users. It reverse engineers database objects
(tables, indexes, users, profiles, tablespaces, roles, constraints, etc.).
It generates DDL to *resize* tables and indexes to the provided standard or
to a user defined standard.
We originally wrote a script to defrag tablespaces, but as DBA's we
regularly find a need for the DDL of a single object or a list of objects
(such as all of the indexes for a certain table). So we took all of the DDL
statement creation logic out of defrag.pl, and put it into the general
purpose DDL::Oracle module. DDL::Oracle was then expanded to include
tablespaces, users, roles, and all other dictionary objects. The completely
revised program 'defrag.pl' is included with the distribution.
Oracle tablespaces tend to become fragmented (now THAT's an understatement).
Even when object sizing standards are adopted, it is difficult to get 100%
compliance from users. And even if you get a high degree of compliance,
objects turn out to be a different size than originally thought/planned --
small tables grow to become large (i.e., hundreds of extents); what was
thought would be a large table ends up having only a few rows. And so forth.
So the main driver for creating DDL::Oracle was the object management needs
of Oracle DBA's. The "resize" method generates DDL for a list of tables or
indexes. For partitioned objects, the "appropriate" size of EACH partition
is calculated and supplied in the generated DDL.
Initialization and Constructor
configure
The configure method is used to define the DBI connection and to
set several session level options. These are:
dbh A reference to a valid DBI connection (obtained via
DBI->connect). This is a mandatory argument.
NOTE: The user connecting MUST have SELECT privileges
on the following (in addition to the DBA or USER
views):
V$INSTANCE
V$PARAMETER
schema Defines whether and what to use as the scema for DDL
on objects which use this syntax. "1" means use the
owner of the object as the schema; "0" means omit the
schema syntax; any other arbtrary string will be
imbedded in the DDL as the schema. The default is "1".
resize Defines whether and what to use in resizing segments.
"1" means resize segments using the default algorithm;
"0" means keep the current INITIAL and NEXT values; any
other string will be interpreted as a resize definition.
The default is "1".
view Defines which Dictionary views to query: DBA or USER
(e.g., DBA_TABLES or USER_TABLES). The default is DBA.
new
The new method is the object constructor. The two mandatory
object definitions are defined by calling this method, to wit:
type The type of object (e.g., TABLE, INDEX, SYNONYM, table
family, etc.).
For 'table family', supply the name(s) of tables -- the
DDL will include the table and its:
Comments (Table and Column)
Indexes
Constraints
Triggers
list An arrayref to an array of arrayrefs (as in the DBI's
"fetchall_arrayref" method) containing pairs of owner and
name.
Object methods
create
The create method generates the DDL to create the list of Oracle
objects.
drop
The drop method generates the DDL to drop the list of Oracle
objects.
resize
The resize method generates the DDL to resize the list of Oracle
objects. The 'type' defined in the 'new' method is limited to
'index' and 'table'. For tables, this generates an ALTER TABLE
MOVE statement; for indexes, it generates an ALTER INDEX REBUILD
statement. If the table or index is partitioned, then a
statement for each partition is generated.
To generate DDL for a single partition of an index or table,
define the 'name' as a colon delimited field (e.g.,
'name:partition').
compile
The compile method generates DDL to compile the list of Oracle
objects. The 'type' defined in the 'new' method is limited to
'function', 'package', 'procedure', 'trigger' and 'view'.
SYNOPSIS
use DBI;
use DDL::Oracle;
my $dbh = DBI->connect(
"dbi:Oracle:dbname",
"username",
"password",
{
PrintError => 0,
RaiseError => 1
}
);
# Use default resize and schema options.
# query default DBA_xxx tables (could use USER_xxx for non-DBA types)
::Oracle->configure(
dbh => $dbh,
resize => 1
schema => 1
view => 'dba'
);
# Create a list of one or more objects
my $sth = $dbh->prepare(
"SELECT
owner
, table_name
FROM
dba_tables
WHERE
tablespace_name = 'MY_TBLSP' -- your mileage may vary
"
);
$sth->execute;
my $list = $sth->fetchall_arrayref;
my $obj = DDL::Oracle->new(
type => 'table',
list => $list,
);
my $ddl = $obj->create; # or $obj->resize; or $obj->drop;
print $ddl; # Use STDOUT so user can redirect to desired file.
FILES
ddl.pl
defrag.pl
copy_user.pl
copy_user.sh
README
README.defrag
AUTHOR
Richard V. Sutherland
rvsutherland@yahoo.com
COPYRIGHT
Copyright (c) 2000, Richard V. Sutherland. All rights reserved.
This module is free software. It may be used, redistributed,
and/or modified under the same terms as Perl itself. See:
http://www.perl.com/perl/misc/Artistic.html
==========================================================================
AVAILABILITY
DDL::Oracle has been uploaded to the CPAN and is also available from:
http://sourceforge.net/projects/ddl-oracle
==========================================================================
------------------------------
Date: 13 Jan 2001 09:04:08 -0800
From: starfire <starfire@zipcon.net>
Subject: ANNOUNCE: HTTP::WebTest 0.01
Message-Id: <t63s069um23vbb@corp.supernews.com>
NAME
HTTP::WebTest - Test remote URLs or local web files
DESCRIPTION
This module runs tests on remote URLs or local web files containing
Perl/HTML/JavaScript/etc. and generates a detailed test report. The
test specifications can be read from a parameter file or input as
method arguments. If you are testing a local file, Apache is
started on a private/dynamic port with a configuration file in a
temporary directory. The module displays the test results on the
terminal by default or directs them to a file. The module will also
optionally e-mails the test results. When the calling program
exits, the module stops the local instance of Apache and deletes
the temporary directory.
Each test consists of literal strings or regular expressions that
are either required to exist or forbidden to exist in the fetched
page. You can also specify tests for the minimum and maximum number
of bytes in the returned page. If you are testing a local file, the
module checks the error log in the temporary directory before and
after the file is fetched from Apache. If messages are written to
the error log during the fetch, the module flags this as an error
and writes the messages to the output test report.
SYNOPSIS
This module can accept input parameters from a parameter file or
subroutine arguments.
TO RUN WEB TESTS DEFINED BY SUBROUTINE ARGUMENTS:
use HTTP::WebTest; run_web_test(\@web_tests, \$num_fail,
\$num_succeed, \%test_options)
or
use HTTP::WebTest; run_web_test(\@web_tests, \$num_fail,
\$num_succeed)
TO RUN WEB TESTS DEFINED BY A PARAMETER FILE:
use sigtrap qw(die normal-signals); # Recommended, not necessary
use HTTP::WebTest; $webtest = HTTP::WebTest->new();
$webtest->web_test('my_web_tests.wt', \$num_fail, \$num_succeed);
The web_test() method has an option to test a local file by
starting Apache on a private port, copying the file to a temporary
htdocs directory and fetching the page from Apache. If you are
testing with multiple parameter files, you can avoid restarting
Apache each time by calling new() only once and recycling the
object:
use sigtrap qw(die normal-signals); # Recommended, not necessary
use HTTP::WebTest;
$webtest = HTTP::WebTest->new();
foreach $file (@ARGV) {
$webtest->web_test($file, \$num_fail, \$num_succeed);
}
TO ENABLE DEBUGGING MESSAGES (OUTPUT TO STDOUT):
If you are calling the web_test method, use the debug parameter.
If you are calling the run_web_test method, do this:
use HTTP::WebTest;
$HTTP::WebTest::Debug = 1; # Diagnostic messages
$HTTP::WebTest::Debug = 2; # Messages and preserve temp Apache dir
run_web_test(\@web_tests, \$num_fail, \$num_succeed)
RESTRICTIONS / BUGS
This module only works on Unix (e.g., Solaris, Linux, AIX, etc.).
The module's HTTP requests time out after 3 minutes (the default
value for LWP::UserAgent). If the file_path parameter is specified,
Apache must be installed. If the file_path parameter is specified,
the directory /tmp cannot be NFS-mounted, since Apache's lockfile
and the SSL mutex file must be stored on a local disk.
VERSION
This document describes version 0.01, release date 13 January 2001.
TODO
Add option to validate HTML syntax using HTML::Validator. Add
option to check links (see
http://world.std.com/~swmcd/steven/perl/pm/lc/linkcheck.html).
AUTHOR
Richard Anderson <Richard.Anderson@unixscripts.com>
COPYRIGHT
Copyright (c) 2000 Richard Anderson. All rights reserved. This
module is free software. It may be used, redistributed and/or
modified under the terms of the Perl Artistic License.
SEE ALSO
perl(1), perlre(1), perldoc Apache::ASP.
------------------------------
Date: 14 Jan 2001 01:32:43 +0000
From: Simon Cozens <simon@brecon.co.uk>
Subject: ANNOUNCE: Mail::Audit 1.6 is available
Message-Id: <t63s0kctu1idc4@corp.supernews.com>
Mail::Audit is a module which helps you create mail filters in Perl;
it's a replacement for procmail. Here's a sample mail filter:
use Mail::Audit;
my $mail = new Mail::Audit;
$mail->resend('william@somewhere.edu')
if ($mail->from =~ /peter/ and $mail->subject =~ /compilers/);
$mail->accept;
For New Users
-------------
This release of Mail::Audit contains a new, experimental tool called
"proc2ma" which attempts to convert your existing .procmailrc into a
Mail::Audit filter. It's not perfect, but it's a good start.
proc2ma requires Parse::RecDescent.
Mail::Audit featured in The Perl Journal; the article is reproduced at
http://simon-cozens.org/writings/mail-audit.html
This is an introduction to mail and news filtering with Perl modules.
For Existing Users
------------------
If you, like me, get most of your mail from a POP3 server, and you've
been using fetchmail, you'll notice that Mail::Audit can drive up your
load average; this is because fetchmail has to fork a new copy of perl
every time it delivers a mail. This is horrific.
This version of Mail::Audit includes popread, a stand-alone POP3 mail
fetcher and filter, which does everything in one process. popread also
checks for and removes duplicate messages on the server before
downloading.
popread requires Mail::POP3Client.
--
Can you sum up plan 9 in layman's terms?
It does everything Unix does only less reliably - kt
------------------------------
Date: 14 Jan 2001 05:57:10 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: Text::Balanced 1.82
Message-Id: <t63s0s8iep28c9@corp.supernews.com>
Keywords: perl, module, release
==============================================================================
Release of version 1.82 of Text::Balanced
==============================================================================
NAME
Text::Balanced - Extract delimited text sequences from strings.
SUMMARY (see Balanced.pod for full details)
Text::Balanced::extract_delimited
`extract_delimited' extracts the initial substring of a string
which is delimited by a user-specified set of single-character
delimiters, whilst ignoring any backslash-escaped delimiter
characters.
Text::Balanced::extract_bracketed
`extract_bracketed' extracts a balanced-bracket-delimited substring
(using any one (or more) of the user-specified delimiter brackets:
'(..)', '{..}', '[..]', or '<..>').
Text::Balanced::extract_quotelike
`extract_quotelike' attempts to recognize and extract any one of the
various Perl quote and quotelike operators (see "perlop(3)"). Embedded
backslashed delimiters, nested bracket delimiters (for the
quotelike operators), and trailing modifiers are all correctly handled.
Text::Balanced::extract_codeblock
`extract_codeblock' attempts to recognize and extract a
balanced bracket-delimited substring which may also contain
unbalanced brackets inside Perl quotes or quotelike
operations. That is, `extract_codeblock' is like a combination
of `extract_bracketed' and `extract_quotelike'.
Text::Balanced::extract_tagged
`extract_tagged' attempts to recognize and extract a
substring between two arbitrary "tag" patterns (a start tag
and an end tag).
INSTALLATION
It's all pure Perl, so just put the .pm file in its appropriate
local Perl subdirectory.
AUTHOR
Damian Conway (damian@cs.monash.edu.au)
COPYRIGHT
Copyright (c) 1997-2000, Damian Conway. All Rights Reserved.
This module is free software. It may be used, redistributed
and/or modified under the terms of the Perl Artistic License
(see http://www.perl.com/perl/misc/Artistic.html)
==============================================================================
CHANGES IN VERSION 1.82
- Fixed nit in extract_variable.t
(tested more cases than it promised to)
- Fixed bug extracting prefix in extract_quotelike (Thanks Michael)
- Added handling of Perl 4 package qualifier: $Package'var, etc.
- Added handling of here docs (see documentation for limitations)
- Added reporting of failure position via $@->{pos} (see documentation)
==============================================================================
AVAILABILITY
Text::Balanced has been uploaded to the CPAN
and is also available from:
http://www.csse.monash.edu.au/~damian/CPAN/Text-Balanced.tar.gz
==============================================================================
------------------------------
Date: Sun, 14 Jan 2001 15:02:16 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Can't associate .PL files in Win98
Message-Id: <slrn963frc.rni.efflandt@efflandt.xnet.com>
On Sat, 13 Jan 2001 12:39:37 -0800, Gary Burton <glburton@mindspring.com> wrote:
> I am a newbie using Win98. I am using ActivePerl v5.6, and working from
> the ActivePerl online documentation. I can run my example programs from
> a DOS window by typing in "Perl filename"; but when I associate the .PL
> extension as the literature suggest, all I get is a DOS window that
> closes so quickly that I can't read the error message.
Your computer is too fast. 8^) Seriously it has been awhile since I have
done Perl in Windows (Perl5 before Activestate), but file association
should work. If you want to see the result, you either need to put a
sleep at the end or something that waits for input like this:
<STDIN>;
Then just hit the enter key after reading the result.
> I followed the instructions in "How do I associate Perl scripts with
> perl?" found in perlwin32faq4. I believe I followed the instructions
> precisely. I researched the archived mail subscription site
> "perl-win32-users" and found a comment to the effect that this will not
> work in Win95 or Win98 although it does work in WinNT.
It did work the last time I tried it in Win95. I could double click on a
Perl script in Explorer (not to be confused with MSIE), to run it. But
that does not allow you to add commandline parameters.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sun, 14 Jan 2001 15:35:58 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: Can't associate .PL files in Win98
Message-Id: <93sh0u$ggt$1@nnrp1.deja.com>
In article <3A60BD09.B0DAA9F6@mindspring.com>,
Gary Burton <glburton@mindspring.com> wrote:
> I am a newbie using Win98. I am using ActivePerl v5.6, and
working from the ActivePerl online documentation. I can run my example
programs from a DOS window by typing in "Perl filename"; but when I
associate the .PL extension as the literature suggest, all I get is a
DOS window that closes so quickly that I can't read the error message.
>
-----------------
this *probably* means you have it working correctly actually... try
putting a
sleep 10;
at the end of your script. when running a script by double-click, the
DOS window only stays open while the script runs, then closes.
on a related note though, I have installed the same version of
ActivePerl on two different PCs, and one of them I have the double-click
working and it uses the dir the script is in as the current working dir,
and on the other it uses the dir where perl.exe is?!
if you figure THAT one out, let me know!
Dan
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sat, 13 Jan 2001 14:32:05 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: converting a form value
Message-Id: <G73v1H.1pp@news.muni.cz>
On Sat, 13 Jan 2001 14:18:09 GMT, sandywadkins123@my-deja.com <sandywadkins123@my-deja.com> wrote:
> problem: when getting a form value that = Black/white it comes out
> Black%2FWhite and is written to file that way.
>
> I can't seem to convert it?? What am I doing wrong
You're not using the CGI.pm module that would do it for you, handle
multiple values, etc etc.
Yours,
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
.project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------
------------------------------
Date: Sun, 14 Jan 2001 12:28:36 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: csv revisited
Message-Id: <mo536t4aigl0so2q2vunbm3qqkke23clmg@4ax.com>
Alex Hart wrote:
>I do not think this is in the faq. The faq deals with comma separated
>values when the entire entry is enclosed in quotes (,"One
>Entry","Another Entry",) . But in email addresses, often only part of
>the entry is enclosed in quotes(,"The Name"<email@domain>,"Num
>2"<second@domain>). The regex in the faq would split up the previous
>examples into 2 entries each.
But I pointed you to the FAQ for one reason: you want to recognize both
"words" without quotes and commas (what about semicolons?), and quoted
strings. The code in the FAQ does that. I thought taking this code, and
modifying it so it does exactly what you want, shouldn't be too hard.
>I wrote a regex to deal with this, but I'd like some validation.
>$recips is a string with a series of email addresses separated by commas
>
>@to should contain one email address per entry when done
>
>$recips = qq( test@test.com,"Dan"<dan@rob.com>,"Someone
>,else",Joe<joe@pete.com> );
>while ($recips =~ m{([^,\"]*(?:".*?")?[^,]*),?}gx) {
> push(@to, $+) if $+;
>}
It looks like it could work. But: you're limiting yourself too much. I'd
only look for sequences of words and quoted strings. That's it.
n.b. I don't like using /".*?"/ too much, because the nongreedy match
does not prevent . from mataching a quote charatcer. For example
$_ = q(He said, "Hi!" and I said "Hi.");
/(".*?")$/ and print "$1\n";
-->
"Hi!" and I said "Hi."
Also, you don't need the while loop. Just match'em all at once.
@to = $recips =~ m{(?:"[^"]*"|[^,\"])+}g;
Apart from possibly including too much whitespace at beginning and
end,it seems to work alright. Excluding excessive whitespace:
@to = $recips =~ m{(?:"[^"]*"|[^," ])(?:\s*(?:"[^"]*"|[^," ]))*}g;
But I'm wondering if that's really worth it.
p.s. There are many notes in Jeffrey Friedl's book "Mastering Regular
Expressions" about avoiding doing stuff that looks like:
/([^",]+)*/
because in case of failure, this can cause a lot of needless
backtracking.
--
Bart.
------------------------------
Date: Sun, 14 Jan 2001 15:12:31 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Help me append
Message-Id: <slrn963gej.rni.efflandt@efflandt.xnet.com>
On Sat, 13 Jan 2001 22:56:45 GMT, E.Neal <eddyneal@earthlink.net> wrote:
>I'm trying to update a text. For some reason the way I'm trying to
>append doesn't work. I have scoured the net and my local help files for the
>answer, but I haven't been able to find it. I can append when running local
>scripts, but through the browser is where I'm running into trouble. I would
>appreciate any help.
Most likely a file permission problem. Checking $! per other replies
could confirm that. If CGI does not run as you, try 666 file permission,
and if that works, try progressively less like 646 or 606. And consider
your data insecure, since anybody who can run CGI on your system can
likely access it. I prefer a web host that runs CGI suexec as me.
But considering that you do not even have a full path to perl in the first
line, it could be that perl is not in the webserver's PATH.
You also might want to close with a newline ("\n"), but I guess it is up
to you how you want to organize your data or read it back.
> Thanks,
> Neal
>
>#!perl
>
>use CGI ':standard';
>
>print header();
>print start_html();
>
>$firstname = param(firstname);
>$lastname = param(lastname);
>$telephone = param(telephone);
>
>open (APPEND, '>> contact.txt');
>print APPEND $firstname," ",$lastname," ",$telephone;
>close APPEND;
>
>print end_html();
>
>
>
>
>
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sun, 14 Jan 2001 12:53:01 -0800
From: "Me" <ja@nee.snee>
Subject: how to test if $a is part of $b??
Message-Id: <tEY8Y#hfAHA.254@asd24-aux-005.raketnet.nl>
Hi someone,
If $a="this is a test"
and $b=" is a"
how would one test if $b is a part of $a ????
Thanks if helping me
------------------------------
Date: Sun, 14 Jan 2001 23:22:12 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: how to test if $a is part of $b??
Message-Id: <slrn9636fk.8ee.mgjv@martien.heliotrope.home>
On Sun, 14 Jan 2001 12:53:01 -0800,
Me <ja@nee.snee> wrote:
>
> If $a="this is a test"
> and $b=" is a"
>
> how would one test if $b is a part of $a ????
You use the index() function as described in perlfunc, or you use a
regular expression. index() is most likely faster.
Martien
--
Martien Verbruggen |
Interactive Media Division | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: Sun, 14 Jan 2001 11:01:32 -0700
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Re: how to test if $a is part of $b??
Message-Id: <5Rl86.1849$Rb1.240189@news.uswest.net>
See if this works for you:
~~~~~
#!/bin/perl
$a="this is a test";
$b=" is a";
if ( $a =~ $b )
{
print "B is a subset of A\n";
}
else
{
print "B is not a subset of A\n";
}
~~~~~
Michael
--
== CigarPool ==
http://www.cigarpool.com
"Me" <ja@nee.snee> wrote in message
news:tEY8Y#hfAHA.254@asd24-aux-005.raketnet.nl...
> Hi someone,
>
> If $a="this is a test"
> and $b=" is a"
>
> how would one test if $b is a part of $a ????
>
> Thanks if helping me
>
>
------------------------------
Date: Sun, 14 Jan 2001 18:14:16 GMT
From: mintcake@my-deja.com
Subject: overload not autogenerating as expected
Message-Id: <93sq9k$n9h$1@nnrp1.deja.com>
I want to use the simplest form of overloading (stringification) but
I'm finding that I have to do far more work than I expected.
I've reproduced the problem in the simplified program below. It fails
on the last statement with the message:
Operation `eq': no method found,
left argument in overloaded package Foo,
right argument has no overloaded magic at foo.pl line 10.
#!/usr/bin/perl -w
package Foo;
use overload qw("") => sub { '*' . $_[0]->{key} . '*' };
sub new { bless {key => 'value'} }
package main;
my $x = Foo->new();
print "$x\n";
print "ok\n" if $x eq '*value*';
I would have thought that the autogeneration mechanism would have come
into play here, simply employing the stringification function to
evaluate the left hand operand. I suspect that my understanding of
what is going on here is a bit flaky. Can anyone explain?
In order to get around the problem I have had to specify a 'cmp'
overload function something like...
cmp => sub { "$_[0]" cmp "$_[1]" }
...which explicitly stringifies both operands (to be safe) before
performing the comparison.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sun, 14 Jan 2001 13:56:02 -0500
From: "Art" <artd@artd3.com>
Subject: Re: overload not autogenerating as expected
Message-Id: <t63tidamk71u1f@corp.supernews.com>
Try putting the if condition in ()
like:
> print "ok\n" if ($x eq '*value*');
<mintcake@my-deja.com> wrote in message news:93sq9k$n9h$1@nnrp1.deja.com...
> I want to use the simplest form of overloading (stringification) but
> I'm finding that I have to do far more work than I expected.
>
> I've reproduced the problem in the simplified program below. It fails
> on the last statement with the message:
>
> Operation `eq': no method found,
> left argument in overloaded package Foo,
> right argument has no overloaded magic at foo.pl line 10.
>
>
> #!/usr/bin/perl -w
>
> package Foo;
> use overload qw("") => sub { '*' . $_[0]->{key} . '*' };
> sub new { bless {key => 'value'} }
>
> package main;
> my $x = Foo->new();
> print "$x\n";
> print "ok\n" if $x eq '*value*';
>
> I would have thought that the autogeneration mechanism would have come
> into play here, simply employing the stringification function to
> evaluate the left hand operand. I suspect that my understanding of
> what is going on here is a bit flaky. Can anyone explain?
>
> In order to get around the problem I have had to specify a 'cmp'
> overload function something like...
>
> cmp => sub { "$_[0]" cmp "$_[1]" }
>
> ...which explicitly stringifies both operands (to be safe) before
> performing the comparison.
>
>
>
>
> Sent via Deja.com
> http://www.deja.com/
------------------------------
Date: Sun, 14 Jan 2001 17:54:25 +0100
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
Subject: Re: Parsing the URL for Hidden variables
Message-Id: <fil36t8i8m8e2k4huula3acqld8f3resan@4ax.com>
On Fri, 12 Jan 2001 16:36:47 GMT, tim allen <timallen449@my-deja.com> wrote:
> # clean up the user_name (I assume user name has to
> # start with letter)
> $user_name =~ s/^[^A-Za-z]*?([A-Za-z]\w+)\W*$/\1/;
> print "<h1>USER_NAME = $user_name</h1>";
>
> #match the first letter of the user_name
> $user_name =~ m/^[^A-Za-z]*?([A-Za-z]).*$/;
^^^^^^^^^^^
How can this match if you removed [^A-Za-z]*? at the beginning of the string?
And even if you hadn't, m/([A-Za-z])/ would have worked equally well due to the
leftmost matching behaviour.
> my $first_letter = $1;
Oops, you didn't check whether the match succeeded at all. Well, undef is a
first letter, too, I suppose (e.g. if the username, as originally entered, was
'123').
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sun, 14 Jan 2001 16:04:38 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Perl's garbage collection
Message-Id: <3A61C006.6C37E1BC@schaffhausen.de>
Hi,
I know that one should never rely on when an object's
DESTROY method is called. However, by definition, END
blocks are called as late as possible. That's why I
wonder whether one can rely one an DESTROY method of an
object which has no references inside an END block being
called before any END block?
Thanx,
->malte
------------------------------
Date: Sun, 14 Jan 2001 11:02:06 GMT
From: robert_meineke@my-deja.com
Subject: Q: Altering wav file speed
Message-Id: <93s0ve$5ra$1@nnrp1.deja.com>
I've poked around Deja.com and freshmeat and
haven't seen the specific answer yet...
Here is what I want to do:
1. Rip an audio track from a CD (can do)
2. Save the track as a wav file (can do)
3. Alter the wav file to play at some
arbitrary percentage of normal speed,
say 80% of normal (?????)
4. Write the slower version to disk as a
wav file (??????)
5. Burn original and slow versions of the
wav file to CD (can do)
Are there any tools that can help me with
steps 3 and 4?
Thanks,
Robert
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sun, 14 Jan 2001 17:44:04 +0100
From: Christopher Kleinheitz <c-kleinheitz@freenet.de>
Subject: Regexp for XML
Message-Id: <3A61D754.E55BFB3A@freenet.de>
Hi,
I have some newbie-questions:
Is there a Regexp for checking if a string contains valid XML?
Is there a website with some common regexp's, or are these questions
here in the wrong ng and should be posted to a regexp-ng.?
TIA
Chris
--
Christopher Kleinheitz Offenburg Germany
http://jahresarbeit.virtualave.net
Die Welt ist eine Datenbank
------------------------------
Date: Sun, 14 Jan 2001 17:20:56 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Regexp for XML
Message-Id: <Ydl86.403$Uz4.19045@eagle.america.net>
On Sun, 14 Jan 2001 17:44:04 +0100, Christopher Kleinheitz
<c-kleinheitz@freenet.de> wrote:
>Is there a Regexp for checking if a string contains valid XML?
I assume you mean a valid XML _document_. This will require a parser.
See XML::Parser and friends. Incidentally, the question of validity
will also require a DTD. I'm not sure how you thought a regular
expression could handle this.
A related FAQ that also illustrates the futility of using regular
expressions on something like HTML: "How do I remove HTML from a
string?" in the perlfaq9 manual page. (Probably one of the most-asked
FAQs in this group. :-)
--
Garry Williams
------------------------------
Date: Sun, 14 Jan 2001 02:08:20 -0800
From: Bald Headed John <baldheadedjohn@SpamAnyone?newsguy.com>
Subject: Re: RegExp substitution w/Array Dereference
Message-Id: <hOxgOmhn1p9KzdLQCCeCtAr=2cGx@4ax.com>
Well, Point well taken, gents!
I should have copied/pasted; So Sorry!
In the meantime, I took your implied suggestion and made a little test
script out of the problem lines.
The wacky thing is, the test script dereffed the array perfectly. So I
went back and tested the real code and guess what... it works. So
somehow my problem vanished, despite the fact that I can't trace where
I changed anything that would affect that. I am using version control,
so maybe I'll go back to yesterday's version at some point and try to
puzzle it out.
As Sam Lowry said in Terry Gilliam's "Brazil"
"I guess it fixed itself."
Sorry for the waste of time, (really!)
tzf
------------------------------
Date: Sun, 14 Jan 2001 09:51:33 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Syntactic symbol for continuing one line into another
Message-Id: <dit26tcb039bevsse8avq1h8hmf27vmdof@4ax.com>
Joseph Maxwell wrote:
>What is the syntactic symbol for continuing one line into another
There isn't one. Statements can just run over multiple lines, you can
even put each symbol on a line of its own, if you like. Strings can be
multi-line too. It's just: comments run to the end of this line. No
continuation onto the next line, ever. You'll just need to start another
comment.
--
Bart.
------------------------------
Date: Sun, 14 Jan 2001 11:32:09 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Syntactic symbol for continuing one line into another
Message-Id: <Pine.LNX.4.30.0101141127111.25909-100000@lxplus003.cern.ch>
On Sun, 14 Jan 2001, Bart Lateur wrote:
> It's just: comments run to the end of this line. No
> continuation onto the next line, ever. You'll just need to start another
> comment.
Didn't I see a suggestion somewhere to write verbose multi-line
comments in a different way?
Or maybe I was confusing myself by mis-remembering this
=head1 Found in /usr/lib/perl5/5.00503/pod/perlfaq7.pod
=head2 How can I comment out a large block of perl code?
Use embedded POD to discard it:
--
You're on your own, kid. You've ripped the safety tag from
the mattress, so the warranty is void. -- Randal Schwartz
------------------------------
Date: Sun, 14 Jan 2001 10:10:51 GMT
From: egwong@netcom.com
Subject: Re: word combinations?
Message-Id: <LWe86.4867$J%.487304@news.flash.net>
Nico F Zigouras <zigouras@mail.med.upenn.edu> wrote:
> Can anyone give me or point me to Perl code on how to find all possible
> combinations of a word? i.e. I have a word:
Hi.
This is a faq. "How do I permute N elements of a list?" in perlfaq4.
Here's another way to do it, although not so efficiently. It just
juggles the letters until all of the permutations are found
(yates_fisher_shuffle() is also in perlfaq4.)
sub permutations2 {
my @word = split(//, shift);
my %seen = ();
while ( int(keys %seen) < factorial(int @word) ) {
yates_fisher_shuffle( \@word );
$seen{join('', @word)}++;
}
return keys %seen;
}
Actually there's a fatal flaw in this sub -- it'll never return for
a certain class of strings. Oh well. No one's perfect.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 59
*************************************