[8678] in Perl-Users-Digest
Perl-Users Digest, Issue: 2296 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 10 22:07:32 1998
Date: Fri, 10 Apr 98 19:01:37 -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 Fri, 10 Apr 1998 Volume: 8 Number: 2296
Today's topics:
Getopt::Long version 2.16 released (Johan Vromans)
Global variables and Modules problem <webmaster@musiciansfriend.com>
Re: help with delimiters james@lucent.com
Re: How to get a Perl CGI to perform a POST action <durant@negia.net>
Re: Info Regarding Perl 5.005 <merlyn@stonehenge.com>
Re: Multi-dimensional Array Access (Andre L.)
Re: Numeric validation (Craig Berry)
Re: Numeric validation <ppp-support@canelle.telecom.uqam.ca>
Re: Perl Compiler for NT (Mark Waterous)
Re: Perl Puzzle: How Many Contexts? (Ilya Zakharevich)
Problem with SRC attribute when writing HTML file <hairball@erols.com>
PWS url change? <jay.blaise@clear.net.nz>
Q: Form CGI script and sender's e-mail address <hitman@3lefties.com>
Re: Regular expression strangeness <lr@hpl.hp.com>
Re: Regular expression strangeness <melo@co.telenet.pt>
Re: Regular expression strangeness <lr@hpl.hp.com>
Re: RMS should be invited to O'Reilly's "Free Software <rra@stanford.edu>
Re: RMS should be invited to O'Reilly's "Free Software <pinard@iro.umontreal.ca>
Re: Sharing a constant between scripts (Chris Sherman)
stdin/out/err redirection in system() ??? <theodod8@cti.ecp.fr>
Re: substitution question (Mark-Jason Dominus)
Tied hashes (was: Re: General Rudeness, e.g. Re: Need a <rra@stanford.edu>
Re: Week of Month <gwynne@utkux.utk.edu>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Apr 1998 00:55:51 GMT
From: JVromans@Squirrel.nl (Johan Vromans)
Subject: Getopt::Long version 2.16 released
Message-Id: <6gmf2n$c$1@news.neta.com>
Version 2.16 of module Getopt::Long is now available via CPAN. It
should soon appear in directory authors/Johan_Vromans as file
GetoptLong-2.16.tar.gz. It will be standard part of Perl 5.005 or later.
Module Getopt::Long implements an extended getopt function called
GetOptions(). This function implements the POSIX standard for command
line options, with GNU extensions, while still capable of handling
the traditional one-letter options (including option bundling).
The README document is attached to this message.
The best way to download from CPAN is to use a Web browser and point
it to http://www.perl.com/CPAN/ (include the final slash!). It will
automagically be redirected to a CPAN site in your neighborhood.
URL: http://www.perl.com/CPAN/authors/Johan_Vromans
Changes in version 2.16
-----------------------
* A couple of small additional fixes to the $` $& $' fixes.
* The option prefix can be set using config("prefix=...") or, more
powerful, with config("prefix_pattern=..."); see the documentation
for details.
* More 'perl -w' warnings eliminated for obscure cases of bundling.
Previous released version was 2.13.
---- README ----
Module Getopt::Long - extended processing of command line options
=================================================================
Module Getopt::Long implements an extended getopt function called
GetOptions(). This function implements the POSIX standard for command
line options, with GNU extensions, while still capable of handling
the traditional one-letter options.
In general, this means that command line options can have long names
instead of single letters, and are introduced with a double dash `--'.
Optionally, Getopt::Long can support the traditional bundling of
single-letter command line options.
Getopt::Long::GetOptions() is part of the Perl 5 distribution. It is
the successor of newgetopt.pl that came with Perl 4. It is fully
upward compatible. In fact, the Perl 5 version of newgetopt.pl is just
a wrapper around the module.
For complete documentation, see the Getopt::Long POD document or use
the command
perldoc Getopt::Long
FEATURES
========
* Long option names
Major advantage of using long option names is that it is much easier
to memorize the option names. Using single-letter names one quickly
runs into the problem that there is no logical relationship between
the semantics of the selected option and its option letter.
Disadvantage is that it requires more typing. Getopt::Long provides
for option name abbreviation, so option names may be abbreviated to
uniqueness. Also, modern shells like Cornell's tcsh support option
name completion. As a rule of thumb, you can use abbreviations freely
while running commands interactively but always use the full names in
scripts.
Examples (POSIX):
--long --width=80 --height=24
Extensions:
-long (convenience) +width=80 (deprecated) -height 24 (traditional)
By default, long option names are case insensitive.
* Single-letter options and bundling
When single-letter options are requested, Getopt::Long allows the
option names to be bundled, e.g. "-abc" is equivalent to "-a -b -c".
In this case, long option names must be introduced with the POSIX "--"
introducer.
Examples:
-lgAd (bundle) -xw 80 (bundle, w takes a value) -xw80 (same)
even -l24w80 (l = 24 and w = 80)
By default, single-letter option names are case sensitive.
* Flexibility:
- options can have alternative names, using an alternative name
will behave as if the primary name was used;
- options can be negatable, e.g. "debug" will switch it on, while
"nodebug" will switch it off.
- options can set values, but also add values producing an array
of values instead of a single scalar value, or set values in a hash.
* Options linkage
Using Getopt::Long gives the programmer ultimate control over the
command line options and how they must be handled:
- by setting a global variable in the calling program;
- by setting a specified variable;
- by entering the option name and the value in an associative array
(hash) or object (if it is a blessed hash);
- by calling a user-specified subroutine with the option name and
the value as arguments;
- combinations of the above.
* Customization:
The module contains a special method, Getopt::Long::config, to control
configuration variables to activate (or de-activate) specific
behavior. It can be called with one or more names of options:
- default
Restore default settings.
- auto_abbrev
Allow option names to be abbreviated to uniqueness.
- getopt_compat
Allow '+' to start options.
- permute
- require_order
Whether non-options are allowed to be mixed with options.
permute means that
-foo arg1 -bar arg2 arg3
is equivalent to
-foo -bar arg1 arg2 arg3
(provided -foo does not take an argument value).
require_order means that options processing
terminates when the first non-option is encountered.
-foo arg1 -bar arg2 arg3
is equivalent to
-foo -- arg1 -bar arg2 arg3
- bundling
Setting this variable to a non-zero value will allow
single-character options to be bundled. To distinguish bundles
from long option names, long options must be introduced with
"--" and single-character options (and bundles) with "-".
- ignore_case
Ignore case when matching options.
- pass_through
Do not issue error messages for unknown options, but leave
them (pass-through) in @ARGV.
- prefix
The string that starts options. See also prefix_pattern.
- prefix_pattern
A Perl pattern that identifies the strings that introduce
options. Default is (--|-|\+) unless environment variable
POSIXLY_CORRECT has been set, in which case it is (--|-).
* Usable variables
- $Getopt::Long::error
Internal error flag. May be incremented from a call-back
routine to cause options parsing to fail.
- $Getopt::Long::debug
Enable copious debugging output. Default is 0.
AVAILABILITY
============
The official version for module Getopt::Long comes with the Perl 5
distribution.
Newer versions will be made available on the Comprehensive Perl Archive
Network (CPAN), see "http://www.perl.com/CPAN/authors/Johan_Vromans".
COPYRIGHT AND DISCLAIMER
========================
Module Getopt::Long is Copyright 1990,1997 by Johan Vromans.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
-------------------------------------------------------------------
Johan Vromans jvromans@squirrel.nl
Squirrel Consultancy Haarlem, the Netherlands
http://www.squirrel.nl http://www.squirrel.nl/people/jvromans
------------------ "Arms are made for hugging" --------------------
------- End of forwarded message -------
------------------------------
Date: Fri, 10 Apr 1998 16:00:05 -0700
From: Christopher James <webmaster@musiciansfriend.com>
Subject: Global variables and Modules problem
Message-Id: <352EA475.FEA@musiciansfriend.com>
Question:
#1 How can all global variables be seen by my all modules without doing
this:
$main::home/$main::cgiprog/$main::sid?search
#2 What is an easy way to do a quazy perl .conf for setting up a big
script
with a lot of global variables, and then making them available to all
modules.
Pages of stuff like this.
EXAMPLE:
$webmaster = qq|<a
href="mailto:webmaster\@musiciansfriend.com">webmaster</a>|;
$lines_per_page = "20";
$mailprog = "/usr/sbin/sendmail";
$basedir = "/usr/local/www/cgi-bin";
$baseurl = "/mfsc";
$sensitivedatadir = "/home/stuff/data";
$emaillogfile= "emailnames.dat";
$stuff = "things";
#3 Am I setting things up correctly in both the main program and the
modules?
This is an excerpt from the main program that is called first:
.................................................................
#!/usr/local/bin/perl
use lib "/usr/local/www/cgi-bin/lib";
use Commerce;
$home = "http://www.musiciansfriend.com";
$cgiprog = "cgi-bin/shop.dll";
# .
# (a heck of a lot more code)
# .
# Then I call a routine that is in
/usr/local/www/cgi-bin/lib/Commerce.pm
&menuline1;
end;
Here is an excerpt from Commerce.pm
.................................................................
package Commerce;
use Exporter;
use Fonts;
use Commerce;
@ISA = qw(Exporter);
@EXPORT = qw(menuline);
sub menuline1 {
print qq|<a href
="$main::cgiurlSEC/$main::sid?checkout">Checkout</a>\n|;
print qq|<a href ="$main::home/$main::cgiprog/$main::sid?editcart">view
edit</a>\n|;
print qq|<a href
="$main::home/$main::cgiprog/$main::sid?emptycart">empty cart</a>\n|;
print qq|<a href
="$main::home/$main::cgiprog/$main::sid?search">SEARCH</a>\n|;
print qq|<a href
="$main::home/$main::cgiprog/$main::sid?doc=blems.html">blems</a>\n|;
print qq|<a href
="$main::home/$main::cgiprog/$main::sid?companysearch">companies</a>\n|;
print qq|<a href ="$main::home">home</a>\n|;
}
1;
.................................................................
I would really appreciate anyone who could shed some light who is heavy
with perl5.
If you can please email me at work as well
mailto:webmaster@musiciansfriend.com
------------------------------
Date: Fri, 10 Apr 1998 19:35:29 -0600
From: james@lucent.com
Subject: Re: help with delimiters
Message-Id: <6gmdsi$uht$1@nnrp1.dejanews.com>
One way to do it:
open (DATA, "data") or die;
while ($line = <DATA>)
{
@array = split ':' , $line;
print $array[item number] , "\n";
# Example: print $array[4] , "\n";
}
close (DATA) or die;
Another way to do it: uses the $_ variable.
open (DATA, "data") or die;
while (<DATA>)
{
@array = split ':';
print $array[4] , "\n";
}
close (DATA) or die;
I don't know what this is for?
print "$x\n";
A couple of books that have helped me a lot:
Learning Perl
Programming Perl
Advanced Perl programming
Effective Perl Programming
Web client programming with Perl
CGI programming on the WWW in Perl
If your interested just do a search on amazon.com for any of these titles.
I hope this helps.
In article <6gk2nq$bhg@nntp1.erinet.com>,
Nick Bradaschia <cyborg@eri.erinet.com> wrote:
>
> I am stuck! (and a newbie too!)
> I am trying to read just a certain data from a file.
> i.e.
> from the string:
> log:name:connect:transmit:receive:protocol
> I want to obtain only the "connect" value (which happens to be bounded by 2
> ":"'s). I have attempted to do a split
> procedure, but it does not appear to work!
> here is my code:
>
> open (DATA, "data");
> while ($line=<DATA>) {
> ($rx)=split((':'),$line);
> print "$rx\n";
> }
> }
> close (DATA);
> print "$x\n";
>
> this is what i think it's doing: i open the file, set $line to read every
line
> from the file <DATA> set $rx to equal everything bounded before the first
":".
> right? how can I set the delimiter so it reads the xth ":" instead of the
1st
> one? Any help is appreciated!!
> (by e-mail please)
> Nick
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 10 Apr 1998 21:01:19 -0400
From: "mark&amy durant" <durant@negia.net>
Subject: Re: How to get a Perl CGI to perform a POST action
Message-Id: <6gmfm7$rl$1@okra.negia.net>
I've got a similar need (I think) for something like this, but can't seem to
find out if it's possible. What I'm trying to do is to have form data
passed to a perl script from one page, and then have the perl script post
the data to another page (one which could contain .asp server-side
processes, so I can't just have the perl create the second page ... it's
needs to be able to post to any given page blindly anyway, i.e. not knowing
what that second page will be).
Will these modules do that for me? And what exactly would be involved in
doing it? I'm wanting to be able to post to the second page and then have
its response directed to the user's browser as seamlessly as possible.
Any help's appreciated!
Mark
Tony Curtis wrote in message <7x90pgrd7s.fsf@beavis.vcpc.univie.ac.at>...
>Re: How to get a Perl CGI to perform a POST action, Jim
><eviljim@megsinet.net> said:
>
>Jim> good information on how to make a Perl program simulate
>Jim> a POST action (most likely to another Perl program).
>
> perldoc LWP
>
>and more specifically...
>
> perldoc LWP::UserAgent
> perldoc HTTP::Request
>
>(and related modules).
>
>Jim> I also tried a CPAN search but couldn't find anything
>Jim> on the subject (I could have bungled up the search,
>Jim> though).
>
>Look for the WWW modules.
>
>hth
>--
>Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax -
13
>Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/
>
>"You see? You see? Your stupid minds! Stupid! Stupid!" ~ Eros, Plan9 fOS.
------------------------------
Date: Sat, 11 Apr 1998 01:46:03 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
To: jgloudon@bbn.com
Subject: Re: Info Regarding Perl 5.005
Message-Id: <8czphtuo5k.fsf@gadget.cscaper.com>
>>>>> "Jason" == Jason Gloudon <jgloudon@manitoba.bbn.com> writes:
Jason> Allen Choy <achoy@us.oracle.com> wrote:
>> Anyone know what kind of features will be available in perl 5.005?
Jason> Big new feature : Multi-Threading.
... but only on platforms that support it. And it slows down your
perl (whether you're using it or not) by 30%.
Unix users have already had threads for three decades now, though --
It's called "fork".
Just another guy not waiting for the new release...
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 143 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
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: Fri, 10 Apr 1998 19:12:48 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Multi-dimensional Array Access
Message-Id: <alecler-1004981912480001@dialup-640.hip.cam.org>
In article <alecler-1004981217110001@dialup-525.hip.cam.org>,
alecler@cam.org (Andre L.) wrote:
> In article <352E1E31.70B7@firstunion.com>, Jerome Bradenbaugh
> <jerome.bradenbaugh@firstunion.com> wrote:
>
> > Dear Readers:
> >
> > Accessing the last element of a single-dimension array is pretty
> > straightforward:
> >
> > @stuff = qw(monday tuesday wednesday thursday friday);
> >
> > $stuff[$#stuff] represents the last element (friday in this case).
> >
> >
> > However, consider the following multi-dimensioanl array:
> >
> > @morestuff = ([1,2,3,4], [5,6,7,8], [9,10,11,12]);
> >
> > Does anyone know the syntax for accessing the last element of each of
> > the sub arrays (in this case, the 4, 8, or 12)?
>
> =========
>
> @morestuff = ([1,2,3,4], [5,6,7,8], [9,10,11,12]);
>
> @lastElements = ();
>
> foreach (@morestuff) {
> push (@lastElements, $_->[$#$_]);
> }
>
> # lastElements is (4,8,12)
Rats! This answer of mine is no good. Forgot about $_->[-1]. I'm such an idiot.
What can I say, but sorry. I'll learn, I'll learn...
A.L.
------------------------------
Date: 10 Apr 1998 23:02:18 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Numeric validation
Message-Id: <6gm8dq$5es$1@marina.cinenet.net>
ppp-support (ppp-support@canelle.telecom.uqam.ca) wrote:
: How can i validate that $num actualy contain a number?
: The best i got, is :
: $num =~ /[0-9]/
:
: But it's not exactly what i'm looking for. Any help appreciate.
I believe this is a FAQ...let's see...yes, perlfaq4, "How do I determine
whether a scalar is a number/whole/integer/float?" Took me 30 seconds to
find that, and you have the faq on your local machine, too. How long
have you been waiting for this answer on Usenet?
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Sat, 11 Apr 1998 01:27:09 GMT
From: ppp-support <ppp-support@canelle.telecom.uqam.ca>
Subject: Re: Numeric validation
Message-Id: <352EC5DE.4C57C6C3@canelle.telecom.uqam.ca>
Because I dont understand the FAQ!! Thats why i post here.
Well, how do i use this stuff, if i want to check if the content of $num is
or not numeric. Call me stupid if you want, but i will still dont get it :-)
The faq4 say...
warn "has nondigits" if /\D/;
warn "not a whole number" unless /^\d+$/;
warn "not an integer" unless /^-?\d+$/; # reject +3
warn "not an integer" unless /^[+-]?\d+$/;
warn "not a decimal number" unless /^-?\d+\.?\d*$/; # rejects .2
warn "not a decimal number" unless /^-?(?:\d+(?:\.\d*)?|\.\d+)$/;
warn "not a C float"
unless /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/;
Craig Berry wrote:
> I believe this is a FAQ...let's see...yes, perlfaq4, "How do I determine
> whether a scalar is a number/whole/integer/float?" Took me 30 seconds to
> find that, and you have the faq on your local machine, too. How long
> have you been waiting for this answer on Usenet?
>
> ---------------------------------------------------------------------
> | Craig Berry - cberry@cinenet.net
> --*-- Home Page: http://www.cinenet.net/users/cberry/home.html
> | Member of The HTML Writers Guild: http://www.hwg.org/
> "Every man and every woman is a star."
Rene
------------------------------
Date: Fri, 10 Apr 1998 23:25:41 GMT
From: mail@silas.hypermart.net (Mark Waterous)
Subject: Re: Perl Compiler for NT
Message-Id: <352e9016.25718795@news.bctel.ca>
On 9 Apr 1998 15:54:01 GMT, smcdow@arlut.utexas.edu (Stuart McDow)
wrote:
>"Grinch" <grinch@whoville.com> writes:
>> Mark Kucera wrote in message ...
>> >IS THERE a PERL Compiler for NT or win95. if so what is it called, and
>> >where can i get it...
>>
>> No (but there is an interpreter), Perl, http://www.perl.com
>
>Perl is a compiler, but not usual kind. It's a "compile and run"
>compiler.
So in otherwords it is an interpretor. Thanks for clearing
that up. :)
_________________________________
Mark Waterous - Silas Productions Online
"Your entrance to a world of information..."
http://silas.hypermart.net/
------------------------------
Date: 11 Apr 1998 00:32:07 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl Puzzle: How Many Contexts?
Message-Id: <6gmdm7$a4o$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Chris Nandor
<pudge@pobox.com>],
who wrote in article <pudge-1004981811430001@dynamic500.ply.adelphia.net>:
> How about faux multidimensional context, as in $hash{1, 2, 3}? That's not
> list context in there.
Good eye! Overloading may steal this context too. Probably after the
"overloaded contants" patch makes it into the core...
This may greately simplify access to multidimensional arrays, as in
$arr[1,2,3] and $hash{1,2,3}.
Ilya
------------------------------
Date: 11 Apr 1998 00:24:40 GMT
From: "hairball" <hairball@erols.com>
Subject: Problem with SRC attribute when writing HTML file
Message-Id: <01bd64e8$167e2d00$8657accf@default>
Hi.
I'm using perl to write some HTML. The code is:
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>Whatever</title>\n";
print "<script language=\"JavaScript\" src=\"include.js\"></script>\n";
. . . etc
I get the following error message (Netscape 3)
Not Found
The requested object does not exist on this server. The link you followed
is either outdated, inaccurate, or the server has been instructed not to
let you have it.
This works, however:
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>Whatever</title>\n";
print "<script language=\"JavaScript\">\n";
<the code in include.js, surrounded by prints>
print "</script>\n";
. . . etc
I know the problem is with the SRC attribute, because I have an image that
also does not load later in the code
print "<img src=\"theimage.gif\">";
Thanks for your help/suggestions.
------------------------------
Date: Sat, 11 Apr 1998 13:21:20 +1200
From: Jay and/or Blaise <jay.blaise@clear.net.nz>
Subject: PWS url change?
Message-Id: <352EC590.77FA1C33@clear.net.nz>
Hi all
I am trying to use MS Personal web server to test a perl script on a
stand alone machine.
i have both Perl and the pws server setup, but when i try to run
anything it tries to open an url called
http://jay (jay is the name of the workstation WHEN it is connected to
a network) any ideas how to change this so that the browser looks
locally for the url?
I have checked help, properties, ini files until red eyed...
Would appreciate any help in this area, especially via an Email in this
oh so busy NG ;o)
Thanks
Jay
--
Web Development: http://www.ipnz.com
Weblinks: http://www.ipnz.com/weblinks
Web Design:-:Web Hosting:-:Domain Registrations
------------------------------
Date: Fri, 10 Apr 1998 18:21:01 -0600
From: "Hitman" <hitman@3lefties.com>
Subject: Q: Form CGI script and sender's e-mail address
Message-Id: <6gmd3r$2a0@news.3lefties.com>
How do I modify a part of the script (below) so that the sender's e-mail
address will automatically be sent to me instead of
Internet.User@43.Cyberhost.net?
read(STDIN, $namevalues, $ENV{'CONTENT_LENGTH'});
open (MAIL, "|$mailprog $youmail") || die "Can't open $mailprog!\n";
print MAIL ("To: $youmail\n");
print MAIL ("From: Internet User\n");
print MAIL ("Subject: Form Response\n\n");
Any help is greatly appreciated, Chris Hendee
------------------------------
Date: Fri, 10 Apr 1998 16:04:17 -0700
From: Larry Rosler <lr@hpl.hp.com>
To: Pedro Melo <melo@co.telenet.pt>
Subject: Re: Regular expression strangeness
Message-Id: <352EA571.BC1F5BD4@hpl.hp.com>
Pedro Melo wrote:
>
> Hi!
>
> perl -e 'print "Ok\n" if "asd.df" =~ /^.*$/'
>
> prints Ok
> but when I do this
>
> perl -e 'print "Ok\n" if "as\nd.df" =~ /^[.\n]*$/'
>
> it no longer prints Ok (??)
> the dot (.) matches everything except a newline, but a character class
> with a dot and a newline should match, right?
>
> Melo
No. In a character class, dot matches ".". The only characters with
special meanings are "^" as the first character (negate the class), "-"
between two characters to indicate a range, and "\" to escape these
special meanings (and it retains its usual uses, such as \n or \\).
This is all documented clearly in several places.
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: Sat, 11 Apr 1998 01:27:49 +0100
From: Pedro Melo <melo@co.telenet.pt>
To: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regular expression strangeness
Message-Id: <352EB905.7D58053D@co.telenet.pt>
Larry Rosler wrote:
>
> Pedro Melo wrote:
> >
> > Hi!
> >
> > perl -e 'print "Ok\n" if "asd.df" =~ /^.*$/'
> >
> > prints Ok
> > but when I do this
> >
> > perl -e 'print "Ok\n" if "as\nd.df" =~ /^[.\n]*$/'
> >
> > it no longer prints Ok (??)
> > the dot (.) matches everything except a newline, but a character class
> > with a dot and a newline should match, right?
> >
> > Melo
>
> No. In a character class, dot matches ".". The only characters with
> special meanings are "^" as the first character (negate the class), "-"
> between two characters to indicate a range, and "\" to escape these
> special meanings (and it retains its usual uses, such as \n or \\).
Ok, I see. But...
> This is all documented clearly in several places.
... this I dont see :)
Can you please specify where? I searched perlre before asking and could
not
find it. I would assume that it should be there, right?
Melo
------------------------------
Date: Fri, 10 Apr 1998 18:53:06 -0700
From: Larry Rosler <lr@hpl.hp.com>
To: Pedro Melo <melo@co.telenet.pt>
Subject: Re: Regular expression strangeness
Message-Id: <352ECD02.6F472951@hpl.hp.com>
Pedro Melo wrote:
> <snip>
> Larry Rosler wrote:
> >
> > No. In a character class, dot matches ".". The only characters with
> > special meanings are "^" as the first character (negate the class), "-"
> > between two characters to indicate a range, and "\" to escape these
> > special meanings (and it retains its usual uses, such as \n or \\).
>
> Ok, I see. But...
>
> > This is all documented clearly in several places.
>
> ... this I dont see :)
>
> Can you please specify where? I searched perlre before asking and could
> not
> find it. I would assume that it should be there, right?
>
> Melo
>From perlre:
You can specify a character class, by enclosing a list of characters in
[], which will match any one of the characters in the list. If the first
character after the ``['' is ``^'', the class matches any character not
in the list. Within a list, the ``-'' character is used to specify a
range, so that a-z represents all the characters between ``a'' and
``z'', inclusive.
>From me:
This says what it means, and no more -- "a list of characters" --
"match any one of the characters." Elsewhere, there is a discussion
about "\" followed by another character being the representation for a
single character, including "\b" as back-space (not "word break" as in
an RE but outide of a character class).
The tutorial books, such as the masterly "Mastering Regular
Expressions," say the same, of course, but are more explicit about what
perlre does *not* say (for example, no metacharacter interpretations,
ways to include "-" or "]" in a character class, etc.). Which is why
I've spent my company's money on several of them.
HTH,
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 10 Apr 1998 16:43:11 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <m3n2dtuttc.fsf@windlord.Stanford.EDU>
In comp.lang.perl.misc, Tim Smith <tzs@halcyon.com> writes:
> But if you want to share without strings attached, don't use GPL. When
> I feel like giving something of mine as a gift to other programers, I
> want it to really be like a gift.
Precisely. People with that perspective shouldn't use the GPL; people who
do want there to be strings attached should. People obviously can argue
this point either way. RMS just posted a very good explanation of why he
personally would prefer to attach strings.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Sat, 11 Apr 1998 01:20:06 GMT
From: =?ISO-8859-1?Q?Fran=E7ois_Pinard?= <pinard@iro.umontreal.ca>
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <vraf9tf942.fsf@raptor.IRO.UMontreal.CA>
nvp@shore.net (Nathan V. Patwardhan) writes:
> =?ISO-8859-1?Q?Fran=E7ois_Pinard?= (pinard@iro.umontreal.ca) wrote:
>
> : One known thing is that Richard does not praise the fact that O'Reilly sells
> : books for which the real sources are not available. For this reason, he
>
> Whatever do you mean? Most of the books have the examples available
> online. Perhaps I misunderstood what you meant, but ...
I meant the full sources of the books themselves.
--
Frangois Pinard mailto:pinard@iro.umontreal.ca
Join the free Translation Project! http://www.iro.umontreal.ca/~pinard
------------------------------
Date: Fri, 10 Apr 1998 23:04:25 GMT
From: sherman@unx.sas.com (Chris Sherman)
Subject: Re: Sharing a constant between scripts
Message-Id: <Er803D.Es5@unx.sas.com>
In <1d78n3x.md661l36dsg0N@slip166-72-108-123.ny.us.ibm.net> kpreid@ibm.net (Kevin Reid) writes:
>Robert Goheen <rsgoheen@pobox.com> wrote:
>Another way to make constants is this:
>*Constant1 = \'rsgoheen@pobox.com';
>You can then use $Constant1.
>(This might be slightly less efficient, I'm not sure)
The problem is that I couldn't get this to work like you would
expect it to.
You see, the reason one would normally want to require a
file full of constants is if you are doing that require inside
of different packages. If you were working just within, say,
main, then you would only have to do the require once, and all
the other files would pick it up.
But...
If you do the require of the constant file once, then its name
goes into %INC, and you can never require it again inside
of any other package (nothing would happen).
So before I do a require of the constant file, I have to do this:
package newPackage;
local(%INC); # so require constants can work
require constants;
Then everything seems to work just fine. Each constant exists
in each package (there isn't that many of them, so this isn't
a major problem). So far, this file only contains:
*abort = \2;
*true = \1;
*false = \0;
Of course, there has to be a better way, but anyone saying
that I should simply use $main::contant, give up. Don't even
send me e-mail. That's ugly... $main::true? Not... :-)
--
____/ / / __ / _ _/ ____/
/ / / / / / / Chris Sherman
/ ___ / _/ / /
_____/ __/ __/ __/ _\ _____/ _____/ sherman@unx.sas.com
------------------------------
Date: Sat, 11 Apr 1998 03:24:40 +0200
From: Theodossiou Denis <theodod8@cti.ecp.fr>
Subject: stdin/out/err redirection in system() ???
Message-Id: <Pine.GSO.3.96.980411030508.15667A-100000@puma>
Hi!
I've just started 4 weeks ago using perl to make small cgi scripts, and I am
really impressed by its functionnality... Simple, yet powerfull... Ideal for
small programmes!But, I've now reached a point, where my perl book doesn't
really help and I would like your help...
I need to execute an external command (say 'doit'), to which I want to feed
$msg through STDIN, and at the same time capture STDOUT into $result and
STDERR into $error.
At first, I tried a simple :
$result = ` echo \"$msg\" | doit `;
but I can't capture STDERR...
I also tried : $result = ` echo \"$msg\" | doit 2>&1 `, but the two outputs
get mixed up and I cannot parse them...
So, for now, I'm doing it though three temporary files
system ("doit <$temp1 1>$temp2 2>$temp3");
and then parse the two output files , which is CLEARLY insufficient and
DIRTY.
I think the answer is creating a pipe, but how can I use it ? I read my
book, but haven't been able to understand how I can make it work...
Sorry if this is a regular question - if it is answered in some kind of FAQ,
please give me a link...
Have a wonderful PERL !
PS: I would really appreciate it if you could e-mail me directly, because
our newsservers have quite strange ... exm... personalities and we don't get
all the messages all the time...
____________________________________________________________________________
Denis Theodossiou - Computer Engineer | Murphy's Law :
Master Ecole Centrale Paris - 1998 | If anything can go wrong, it WLIL!
-----Networks & Telecommunications-----+------------------------------------
Contact: denis.theodossiou@bigfoot.com | www.bigfoot.com/~denis.theodossiou/
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
------------------------------
Date: 10 Apr 1998 19:43:56 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: substitution question
Message-Id: <6gmars$5hm$1@monet.op.net>
In article <01bd648a$f96a4e40$d5c7aec7@bazzle>,
Barry Kaplan <barry@megaspace.com> wrote:
>Is there a way to take instances of repeating text such as:
>Embedded RoutersEmbedded RoutersEmbedded Routers
>and substitute out the redundancies?
$string =~ s/(.+)\1+/$1/g;
Not too efficient, but without a more complete problem specification,
you're unlikely to do better.
Warning: This replaces the above with
Embeded Routers
(`dd' turns into `d')
You may want to adjust those quantifiers:
s/(.{3,})\1{2,}/$1/g;
------------------------------
Date: 10 Apr 1998 16:41:22 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Tied hashes (was: Re: General Rudeness, e.g. Re: Need a web login script)
Message-Id: <m3pviputwd.fsf_-_@windlord.Stanford.EDU>
sonny <sonny@88net.net> writes:
> My point is help'em or ignore'm (which is what I prefer to do). Just
> don't add to the general hub-bub by telling folks that they're lame or
> too lazy to look it up for themselves.
Although Abigail did tell them where to find the answer, indirectly (go to
a different newsgroup). And maybe some of the people reading will learn
from that if frequently repeated.
Plus, the people who complain about the people complaining don't answer
the question either, and generally add even less technical content than
the original post.
ObPerl: In the process of writing a module I've been working on for a
while, it occurred to me that something that would be very nice to have
would be a transparent interface to a "hash" stored on disk, such that it
could handle a flat-file read in and converted to a hash, a db file, a dbm
file, or whatever else people would care to throw at it. It also occurred
to me that it would be really convenient for what I was doing to be able
to have a tied hash that I could modify without having those modifications
affect the database on disk.
So I started thinking about this, and it ended up not being all that hard
to do.
The primary problem that I'm running into is that I'm not sure how to
implement iterators (which I actually don't need for what I'm doing). Any
good idea on how to implement iterators across a hash that has both a tied
db file and a supporting internal memory hash that contains both values
overriding the values in the tied db file and possibly new keys that the
tied db file doesn't have?
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Fri, 10 Apr 1998 19:29:55 -0400
From: "Bob Gwynne" <gwynne@utkux.utk.edu>
Subject: Re: Week of Month
Message-Id: <6gma3j$ji7$1@gaia.ns.utk.edu>
I R A Aggie wrote in message ...
>In article <01bd63ff$2bc9d5e0$053763c3@dns.btinternet.com>, "Duncan
>Cameron" <dcameron@nospam.bcs.org.uk> wrote:
>Twould appear that there are 4 Sundays in every month, with most months
>having days spread out over 5 weeks. The only exception is a non-leap
>year February that starts on a Sunday -- 4 weeks exactly.
>
There are 5 Sundays in March '98.
Bob Gwynne
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 2296
**************************************