[24207] in Perl-Users-Digest
Perl-Users Digest, Issue: 6399 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 14 03:05:52 2004
Date: Wed, 14 Apr 2004 00:05:09 -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, 14 Apr 2004 Volume: 10 Number: 6399
Today's topics:
Re: 3x3 simple puzzle ctcgag@hotmail.com
CGI Perl on IIS <daveharney@wi.rr.com>
Re: Changing from C thought to Perl <rob_perkins@hotmail.com>
Re: Changing from C thought to Perl <nmihai_year_2000@yahoo.com>
eval running external script <shailesh@nothing.but.net>
fixed the bbs... <robin @ infusedlight.net>
Re: foreach loop test <pinyaj@rpi.edu>
Re: foreach loop test <tzz@lifelogs.com>
Re: Initializing an anonymous hash (repost) <bmb@ginger.libs.uga.edu>
Re: Installing DBD::Sybase when there is no compiler <MrReallyVeryNice.NOVIRUS@NoSpam.yahoo.com>
IRC Trivia Bot <ZedGama3@nospam.com>
Re: Multiple replaces (Motti)
Need advice on include-like file for Perl Amanda aman_DO_da345@al_THE_ter_OBVIOUS_n.org
Re: Need advice on include-like file for Perl <jurgenex@hotmail.com>
Re: Need advice on include-like file for Perl <tore@aursand.no>
Re: Need advice on include-like file for Perl <aman_DO_da345@al_THE_ter_OBVIOUS_n.org>
Re: Need advice on include-like file for Perl <mb@uq.net.au.invalid>
Re: Need advice on include-like file for Perl <tore@aursand.no>
Re: perl's severe lack of in-line comment ability <bmb@ginger.libs.uga.edu>
Re: the code for bbs 3 <uri@stemsystems.com>
Re: Tough (for me) regex case <rob_perkins@hotmail.com>
Re: Tough (for me) regex case <matthew.garrish@sympatico.ca>
Re: Tough (for me) regex case <rob_perkins@hotmail.com>
Re: Tough (for me) regex case <dave@dave.org.uk>
wow...jackpot. <robin @ infusedlight.net>
Re: wow...jackpot. <tore@aursand.no>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Apr 2004 01:45:09 GMT
From: ctcgag@hotmail.com
Subject: Re: 3x3 simple puzzle
Message-Id: <20040413214509.695$fs@newsreader.com>
Matija Papec <perl@my-header.org> wrote:
> X-Ftn-To: ctcgag@hotmail.com
>
> ctcgag@hotmail.com wrote:
> >> Ok, there are two solutions for these turtles,
> >> http://globalnet.hr/~mpapec/perl/turtles3x3.jpg
> >> They have to be in 3x3 matrix so that colors and body parts match
> >> (head/tail).
> >>
> >> I wrote a perl script which finds them in 8min (Duron 750mhz); anyone
> >> interested in some turtle solving?
> >
> >Do you get to move tiles around, or only rotate them in place?
>
> Both. :)
I found 16 solutions (I didn't canonicalize, so 4 "distinct" solutions,
each one repeated in 4 major orientations). Two of them you can get just
moving pieces without rotating them and two that require rotations.
It took 2 minutes on 1.13GHz pentium III. (30 seconds of that was
generating permutations of 0..8 using my rather inefficient subroutine.)
I had started righting a very complicated decision-tree process with
rules for quick pruning, but I discovered that that was unnecessary because
no piece has the same color/anatomy combo on it more than once. That made
things much simpler.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Wed, 14 Apr 2004 03:33:42 GMT
From: "dave h" <daveharney@wi.rr.com>
Subject: CGI Perl on IIS
Message-Id: <qi2fc.92227$4B1.38911@twister.rdc-kc.rr.com>
Hi,
I have this page called index.shtml ----
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>index</title>
</head>
<body>
The date is<br>
<!--#echo var="DATE_LOCAL" --> <br>
A Perl Print result is<br>
<!--#exec cgi="/perltest/perltest.pl" --> <br>
end of test
</body>
</html>
---------------------------------------
and this perl script call perltest.pl --
#!c:\perl\bin
print "Content-type: text/html\n\n";
print "xxx\n";
#exit;
--------------------------------------------------------
when I run the index.shtml page the perl script returns a long string of
header info in front of the "xxx" that I was looking for. The W2K IIS host
I running on recommends using <meta name="hideHeader" content=""> before the
<!--#exec cgi="/perltest/perltest.pl" --> statement to eliminate these
unwanted headers. I've not been successful in getting rid of the headers
with this approach..
Any suggestions for getting rid of the unwanted headers - the actual line
returned looks like -> "HTTP/1.1 200 OK Date: Wed, 14 Apr 2004 00:09:47 GMT
Server: Microsoft-IIS/5.0 Content-type: text/html xxx "
thanks
------------------------------
Date: Wed, 14 Apr 2004 02:13:10 GMT
From: Rob Perkins <rob_perkins@hotmail.com>
Subject: Re: Changing from C thought to Perl
Message-Id: <kf6p70pdkcf4lh9bea3tj0st77bh86gddl@4ax.com>
Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
>Global variables are not a bad thing per se. Side effects are not a bad
>thing per se.
Suppose you write The Program, something so dang useful that people
all over the world want to cookbook it. So you throw it in a module.
Well, you used a couple of global variables. No big deal, not a bad
thing per se, it never interfered with your use of The Program, and it
solved all your problems very quickly.
Oops, you start giving away/selling/selling support for your "The
Program" module, and one of those pesky users wants to use your module
in two threads of the same process.
Oopsie. Suddenly that global variable has a *bad* side effect, and The
Program is worthless. Hapless user has to roll his own, or get your
source code.
OK, fine, you're a mangnanimous guy who GPL'ed his source, so he can
get it.
Oopsie. He's doing government work, and can't GPL/LGPL his mods to
your source. Now he has to roll his own. Or he doesn't want to (L)GPL
it for other good reasons. If he's Microsoft or the government, no big
deal; he can afford to roll his own. But if he's that guy in a garage
two towns down, or your buddy three cubes over, working on something
you'll eventually find very very useful in your ongoing efforts, you
just screwed him with that global.
No, not a bad thing, per se. Unless you need/want to share your code.
Side effects? I've already run into one: regex's don't behave the same
on every platform. Side effects aren't a bad thing per se. Unless you
want cross platform capability. Then you're screwed.
Rob
------------------------------
Date: Wed, 14 Apr 2004 06:17:19 GMT
From: "Mihai N." <nmihai_year_2000@yahoo.com>
Subject: Re: Changing from C thought to Perl
Message-Id: <Xns94CAECEB9CE40MihaiN@216.148.227.77>
> Has anyone else moved from C to Perl who has some advice. (I know
> the best advice is to write and read and I am doing that.) Maybe
> it will just take time and all these things will become second
> nature.
I did this about 5 years ago. Not really moved to Perl, just
added it to C/C++.
I did find it tricky, but my solution was "write and read."
For a while my Perl code was like C (you can write C in any language :)
But in time it evolved. Reading now some of my old scripts is funny.
Just don't loose your patience. Perl is strong enough to do the job
even if you write it C style, until you get used to it.
Good luck!
--
Mihai
-------------------------
Replace _year_ with _ to get the real email
------------------------------
Date: Wed, 14 Apr 2004 03:02:08 GMT
From: Shailesh <shailesh@nothing.but.net>
Subject: eval running external script
Message-Id: <QQ1fc.9990$B%4.8198@fe2.columbus.rr.com>
In an eval statement, I am executing an external perl script, and I
want to trap its errors. However, when I do this, the errors are not
trapped in the $@ variable. Is there a better way to do this? Do I
need to read in the perl script into a string, and then execute it?
The problem with that is I don't want any of the scripts' variables to
be shared. My goal is for the task_scheduler to be simple, reliable,
and run forever running tasks, while the run_task script may change
from time to time. (Only one parameter needs to be passed to the
run_task script via the command line--not shown below.) The exact
code and output of my two scripts is below.
-----------------------------
task_scheduler.pl
------------------------------
#!/usr/bin/perl -W
eval {
$output = `perl run_task.pl`;
print "output is: $output\n";
};
print "eval returned: ".$@."\n";
-----------------------------
run_task.pl
------------------------------
#!/usr/bin/perl -W
# Purposely do a division by zero.
$i = 0;
$a = 1 / $i;
print "vals: ".$a.$i."\n";
------------------------------
OUTPUT of task_scheduler.pl
------------------------------
Illegal division by zero at run_task.pl line 5.
output is:
eval returned:
------------------------------
------------------------------
Date: Tue, 13 Apr 2004 20:51:57 -0700
From: "Robin" <robin @ infusedlight.net>
Subject: fixed the bbs...
Message-Id: <c5idnk$nl6$4@reader2.nmix.net>
I think I figured ouit taint mode, so try to hack me now...
http://www.infusedlight.net/cgi-bin/bbs.pl
thanks in advance.
--
Regards,
-Robin
--
robin @ infusedlight.net
------------------------------
Date: Tue, 13 Apr 2004 22:15:55 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: foreach loop test
Message-Id: <Pine.SGI.3.96.1040413221501.233839A-100000@vcmr-64.server.rpi.edu>
On Tue, 13 Apr 2004, Steven Kuo wrote:
>On Tue, 13 Apr 2004, Robin wrote:
>
>> foreach (@test)
>> {
>> print;
>> }
>>
>> for this code, I'd like some way to test if $_ is the last first or middle
>> of the array without having to use a while loop....any suggestions?
>
>One way would be to use references:
>
>my @foo = ( 99, 86, 7, 99, 007 );
This method is fine -- I use it too -- IF YOUR DATA does not have two
references to the same data:
my @foo = (\$a, \$b, \$c, \$b);
will cause this method to break.
--
Jeff Pinyan RPI Acacia Brother #734 2004 IT Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Tue, 13 Apr 2004 23:40:12 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: foreach loop test
Message-Id: <4nptabxm5f.fsf@lifelogs.com>
On Tue, 13 Apr 2004, robin @ infusedlight.net wrote:
> foreach (@test)
> {
> print;
> }
>
> for this code, I'd like some way to test if $_ is the last first or
> middle of the array without having to use a while loop....any
> suggestions?
To me, this question 95% of the time indicates a suboptimal approach
to the problem.
You can use the index, as Matija Papec showed.
You can also use pop() or shift() to shrink the array dynamically, and
see what's left in it to see where you are.
You can take the first and last elements off beforehand (with shift()
and pop()) and then process the middle normally.
If, however, you show a more complete example of what you're trying
to do, you may get a better solution that will help you improve your
Perl. Your example, as it is, does not need to know where in the
array it's working.
Ted
------------------------------
Date: Tue, 13 Apr 2004 21:46:41 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Initializing an anonymous hash (repost)
Message-Id: <Pine.A41.4.58.0404132133390.8796@ginger.libs.uga.edu>
On Tue, 13 Apr 2004, Neil Shadrach wrote:
> ctcgag@hotmail.com wrote in message
>
> > warn "Ugly, but works";
>
> You're being too modest.
>
> > @{$a[@a]}{@k}=@v;
>
> If I rework my original problem to be a little closer to your solution
> :)
>
> I wanted to eliminate %h from
> @h{@k}=@v; $a[@a]=\%h;
>
> I can just about convince myself that I understand if I allow the
> pseudo-step of dereferencing both sides of the second statement as
> arrays and then substitute in the first
> @{$a[@a]}=@h; # ok I know I couldn't actually use @h like that - I did
> say 'just about'
>
> I'm not going to offer to stand up and jsutify that at a perl
> conference though.
I'm not sure that describes it well. I'm not sure this does either. :-)
But ...
o scalar @a is always just beyond the end of the array, so
o assigning to $a[@a] is essentially the same as push @a, ...
o you said, "If my next step is push @a,\%h;", so
o @{$a[@a]}{@k}=@v is autovivifying an anonymous hash at element $a[@a]
just as @h{@k}=@v would autovivify %h if it didn't exist before (and
strictures didn't block it).
Regards,
Brad
------------------------------
Date: Tue, 13 Apr 2004 22:52:57 -0700
From: "MrReallyVeryNice" <MrReallyVeryNice.NOVIRUS@NoSpam.yahoo.com>
Subject: Re: Installing DBD::Sybase when there is no compiler
Message-Id: <IbqdnTkmO4QUTuHdRVn-gQ@comcast.com>
While I'm unable to answer your real question about building the perl module
on your dev. machine
so that the packaged module does not depend on the location of the libraries
it uses, I may help a little. Let's say that in a previous life I was very
much involved with Configuration Management teams. One of the big tasks of
my Configuration Management teams was to deliver software packages on
computers for our internal/external customers. Just trying to hint that I
have a bit of practice in this area but take everything I say with a grain
(or a spoon) of salt. Consider that what was acceptable in our corporation
would/might not be acceptable in another corporation. You have to know your
customer and work with them. But enough about the high level stuff, let's
talk about a process driven solution.
Contact your customer sys admins and negotiate with them the location of the
libtds.sl.3 and other potential supporting software. With that information,
compile your application with libtds.sl.3 in the appropriate location and
write a little "Installation Note". At install time, the sys admin will
simply have to follow your notes (I would be surprised if they let you
install the application by yourself). If something goes wrong, they have the
documentation as a support and you have the documentation to prove that you
followed some kind of agreed process. CYA :-) This approach is not really
flexible to move libraries and applications around. It also requires up
front communication (not a bad thing in any case) with your customer. Based
on your confidence level on the sys admins skill set, you might decide to
package and install libtds.sl.3 in a sub-directory of where your application
would be installed. While most sys admin are really knowledgeable and
skilled, you might deal with a small corporation where "cow-boys" are
running the show. It means that they might have little
control/knowledge/information about where various pieces gets installed over
time. Corporations that keep good logs of system changes are always too
rare. :-( In the case of a disorganized customer , it is possible that a
sys admin would upgrade/downgrade libtds.sl.3 in the process of supporting
another application. In which case, you are taking the risk of getting your
application broken in the process. Packaging libtds.sl.3 within your
application - if acceptable for your customer - would alleviate future
headaches but might led to duplication of library. It is a tradeoff that you
will have to assess.
I hope that someone out there will give 'the real' answer that you are
looking for. I would love to learn how it can be done.
You most likely already figured out a solution but let me know if this
posting helps.
Mr ReallyVeryNice.
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
Just trying to catch the attention of people about this wonderful document.
This reference does not specifically pertain to my reply or to the OP. :-)
------------------------------
Date: Wed, 14 Apr 2004 05:30:37 GMT
From: "ZedGama3" <ZedGama3@nospam.com>
Subject: IRC Trivia Bot
Message-Id: <104fc.32960$xn4.82581@attbi_s51>
Does anyone know of a counterpart for Trivia.pm for POE::Component::IRC?
From what I read POE::Component::IRC is supposed to be alot better than
Net::IRC because it's event driven rather than loop driven ( if I understand
that correctly ).
So far I've already setup a bot with POE::Component::IRC and wouldn't be
opposed to making my own trivia component but I don't know how to setup a
timed event so the tivia bot will keep going without making other items
wait. So if no one gets it right in 10sec it gives a hint, 10sec later
another hint, until it tells you the answer and picks a new question or if
someone gets it right the bot automaticly congratulates the user and picks a
new question.
------------------------------
Date: 13 Apr 2004 22:23:37 -0700
From: kzin@myrealbox.com (Motti)
Subject: Re: Multiple replaces
Message-Id: <173891e8.0404132123.68068165@posting.google.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<c5h2bp$6ro$1@mamenchi.zrz.TU-Berlin.DE>...
> Motti <kzin@myrealbox.com> wrote in comp.lang.perl.misc:
> > anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> > news:<c5gcvu$mb4$1@mamenchi.zrz.TU-Berlin.DE>...
> > > Motti <kzin@myrealbox.com> wrote in comp.lang.perl.misc:
>
> [...]
>
> > > > s/$$re[0]/$$re[1]/g;
> > >
> > > "$$re[0]" would more commonly be written "$re->[0]". "$$re[0]" is correct,
> > > but slightly ambiguous.
> >
> > I'm used to using -> only when dealing with blessed objects. I suppose
> > it's a matter of taste. I don't see where ambiguity comes into it.
>
> "$$re[ 0]" could either be "${ $re[ 0]}" (array @re contains a scalar ref),
> or "${ $re}[ 0]" (arrayref $re contains a scalar). Only the notoriously
> hard-to-remember precedence rules make sure it's the latter. That's
> why arrow notation is preferred.
Good point.
I just assumed it had the right behaviour and since it worked I didn't think twice.
------------------------------
Date: Wed, 14 Apr 2004 03:45:52 +0000 (UTC)
From: Amanda aman_DO_da345@al_THE_ter_OBVIOUS_n.org
Subject: Need advice on include-like file for Perl
Message-Id: <c5ic5g$qtc$3@reader2.panix.com>
Hi!
I've done most of my programming in C/C++ and a little in Perl,
though until recently I have stayed away from Perl OOP. Now I'm
writing my first suite of classes in Perl, and I wonder how best
to set up something analogous to an include file in C/C++ consisting
of definitions of constants to be used by all the classes in this
suite. The main class in this suite is called SMS. My idea was
to create a file SMS_Constants.pm to collect all these constants:
# file SMS_Constants.pm
package SMS; # keep "prefix" short
our $Constant_1 = 'some value';
our $Constant_2 = 'another value';
our $Constant_3 = 'you get the picture';
# etc.
1;
so that other code could access these constants as $SMS::Constant_1,
etc. after first invoking "use SMS_Constants.pm" in a spirit similar
C/C++ programs' use of '# include "some_constants.h"'.
Is this what's usually done in Perl? Are there any obvious problems
with this approach? I suppose that TMTOWTDI, but it would be
instructive to read who different Perl programmers go about doing
this.
Many thanks in advance!
Amanda
--
------------------------------
Date: Wed, 14 Apr 2004 03:58:54 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Need advice on include-like file for Perl
Message-Id: <2G2fc.30071$hd3.22997@nwrddc03.gnilink.net>
Amanda aman_DO_da345@al_THE_ter_OBVIOUS_n.org wrote:
[...]
> writing my first suite of classes in Perl, and I wonder how best
> to set up something analogous to an include file in C/C++
[...]
Depending upon the details of what you want to do
perldoc -f use
perldoc -f require
perldoc -f do
jue
------------------------------
Date: Wed, 14 Apr 2004 06:13:35 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Need advice on include-like file for Perl
Message-Id: <pan.2004.04.14.04.13.05.221835@aursand.no>
On Wed, 14 Apr 2004 03:45:52 +0000, wrote:
> I wonder how best to set up something analogous to an include file in
> C/C++ consisting of definitions of constants to be used by all the
> classes in this suite. The main class in this suite is called SMS. My
> idea was to create a file SMS_Constants.pm to collect all these
> constants:
Excellent. It's always a good idea to keep constants and common variables
in one place.
But why keep it in a module? Why not take a look at one of the modules at
CPAN [1] which lets you have these values in configuration files?
[1] <http://www.cpan.org/>
> # file SMS_Constants.pm
> package SMS; # keep "prefix" short
Well. If you're to call the file 'SMS_Constants.pm', you should also call
the package 'SMS_Constants'. Or maybe the constants thing is a part of
the SMS namespace? In that case, you should call your package
'SMS::Constants';
package SMS::Constants;
use strict;
use warnings;
> our $Constant_1 = 'some value';
> our $Constant_2 = 'another value';
> our $Constant_3 = 'you get the picture';
Funny names for variables, don't you think? Take a look at the use of
"real" constants in Perl;
perldoc constant
> Is this what's usually done in Perl?
Genereally: To find out how things are usually done in Perl, download
some of the modules from CPAN and consult them.
--
Tore Aursand <tore@aursand.no>
"There are three kinds of lies: lies, damn lies, and statistics." --
Benjamin Disraeli
------------------------------
Date: Wed, 14 Apr 2004 04:59:28 +0000 (UTC)
From: Amanda <aman_DO_da345@al_THE_ter_OBVIOUS_n.org>
Subject: Re: Need advice on include-like file for Perl
Message-Id: <c5igfg$sf6$1@reader2.panix.com>
In <pan.2004.04.14.04.13.05.221835@aursand.no> Tore Aursand <tore@aursand.no> writes:
>On Wed, 14 Apr 2004 03:45:52 +0000, wrote:
>> I wonder how best to set up something analogous to an include file in
>> C/C++ consisting of definitions of constants to be used by all the
>> classes in this suite. The main class in this suite is called SMS. My
>> idea was to create a file SMS_Constants.pm to collect all these
>> constants:
>Excellent. It's always a good idea to keep constants and common variables
>in one place.
>But why keep it in a module? Why not take a look at one of the modules at
>CPAN [1] which lets you have these values in configuration files?
Well, these are not user-configurable parameters, so I saw no
particular benefit in putting them in a separate configuration
file. They are constants such as pi, pi/2, sqrt(2), log(10),
Boltzmann's constant, standard error messages, standard urls, etc.
Thanks,
Amanda
--
------------------------------
Date: Wed, 14 Apr 2004 15:43:52 +1000
From: Matthew Braid <mb@uq.net.au.invalid>
Subject: Re: Need advice on include-like file for Perl
Message-Id: <c5ij2p$d53$1@bunyip.cc.uq.edu.au>
Amanda wrote:
> Hi!
>
> I've done most of my programming in C/C++ and a little in Perl,
> though until recently I have stayed away from Perl OOP. Now I'm
> writing my first suite of classes in Perl, and I wonder how best
> to set up something analogous to an include file in C/C++ consisting
> of definitions of constants to be used by all the classes in this
> suite. The main class in this suite is called SMS. My idea was
> to create a file SMS_Constants.pm to collect all these constants:
>
> # file SMS_Constants.pm
> package SMS; # keep "prefix" short
> our $Constant_1 = 'some value';
> our $Constant_2 = 'another value';
> our $Constant_3 = 'you get the picture';
> # etc.
> 1;
>
> so that other code could access these constants as $SMS::Constant_1,
> etc. after first invoking "use SMS_Constants.pm" in a spirit similar
> C/C++ programs' use of '# include "some_constants.h"'.
>
> Is this what's usually done in Perl? Are there any obvious problems
> with this approach? I suppose that TMTOWTDI, but it would be
> instructive to read who different Perl programmers go about doing
> this.
>
> Many thanks in advance!
>
> Amanda
I often have a package like:
package SMS::Constants;
use strict;
# use warnings; # when developing
use base qw/Exporter/;
use vars qw/@EXPORT_OK %EXPORT_TAGS/;
BEGIN {
@EXPORT_OK = qw/THIS THAT OTHER/;
%EXPORT_TAGS = (ALL => [qw/THIS THAT OTHER/],
STARTS_WITH_TH => [qw/THIS THAT/]);
Exporter::export_ok_tags(qw/ALL STARTS_WITH_TH/);
}
use constant THIS => 'this value';
use constant THAT => 'that value';
use constant OTHER => 'other value';
1;
__END__
So you can now do:
use SMS::Constants qw/THIS/; # Imports THIS
use SMS::Constants qw/:STARTS_WITH_TH/; # Imports THIS and THAT
MB
------------------------------
Date: Wed, 14 Apr 2004 08:12:21 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Need advice on include-like file for Perl
Message-Id: <pan.2004.04.14.05.54.51.7245@aursand.no>
On Wed, 14 Apr 2004 04:59:28 +0000, Amanda wrote:
>> But why keep it in a module? Why not take a look at one of the modules
>> at CPAN which lets you have these values in configuration files?
> Well, these are not user-configurable parameters, so I saw no particular
> benefit in putting them in a separate configuration file.
But you _did_ that, didn't you? :) My point is that it's generally a good
idea to keep pre-defined variables (and constants) away from the Perl
code.
But - as always - I guess it's a matter of taste, really.
--
Tore Aursand <tore@aursand.no>
"What we see depends mainly on what we look for." -- Sir John Lubbock
------------------------------
Date: Tue, 13 Apr 2004 21:04:26 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: perl's severe lack of in-line comment ability
Message-Id: <Pine.A41.4.58.0404132055511.8796@ginger.libs.uga.edu>
On Tue, 13 Apr 2004, Dan Jacobson wrote:
> Gentlemen, "#" until the end of the line is not good enough for
> comments.
>
> Found in perlfaq7.pod
> How can I comment out a large block of perl code?
>
> Yes, but what about the very smallest pieces of code? C's */ /* can
> be used almost anywhere, but what about perl?
>
> For instance, say I want to comment out "$F[0]," in
> perl -nalwe 'print $F[0],$F[1]'
> with out otherwise disturbing anything or being interrogated as to my
> motives or being told to make it into two lines:
I'd like to interrogate your motives.
> #perl -nalwe 'print $F[0],$F[1]'
> perl -nalwe 'print $F[1]'
Looks smart to me, but I'd comment why I'm doing that.
> It seems perl might be in need of a new operator c{}, modeled on q{},
> that will comment stuff in-line:
> perl -nalwe 'print c{$F[0],}$F[1]'
> or something like that.
Why?
> Of course I didn't check if the name "c" has been used already, or if
> this "is impossible to implement", I'm just saying is that Larry
> forgot something.
Probably not.
Regards,
Brad
------------------------------
Date: Wed, 14 Apr 2004 01:05:25 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: the code for bbs 3
Message-Id: <x7ekqre5d7.fsf@mail.sysarch.com>
>>>>> "R" == Robin <robin @ infusedlight.net> writes:
R> i don't know whether to laugh or fuckin' cry...haha. waaaahhh...
just stop posting your code. no one cares to see any more of it.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 14 Apr 2004 01:42:14 GMT
From: Rob Perkins <rob_perkins@hotmail.com>
Subject: Re: Tough (for me) regex case
Message-Id: <qb5p70p7l720ajrjto1g3kfsr6j5568vfu@4ax.com>
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote:
>> It makes me wonder if this .NET implementation approach is shared by
>> other implementations. IOW, is the desirable (for my problem) behavior
>> unique to Perl 5, or is the undesirable behavior unique to .NET?
>>
>
>To put it bluntly, who cares?
comp.lang.perl... what again?
Ohyeah! MISC.
Hmm.
>You should figure out if you're using the .net framework or if you're
>writing a perl script and write your code according the rules of the
>language. I have no idea how regular expressions are implemented within
>.net, and am not going to figure them out for you.
What of those using ActivePerl on the .NET framework? Which
implementation will they hit?
>Chances are you've misread the documentation (i.e., for all I know there may
>be an implicit capture around the entire pattern in .net). It could also be
>a poorly written program you're using to test with.
Anything, I see, except the notion that Perl's regex implementation
might be bugged. Well, OK, if that's the way you want it, but...
> If you run into any perl
>problems with your regex feel free to post again, otherwise please stick to
>the appropriate forum.
You're leaving me with a really bad impression of the perl aficionados
around here. People must be far more interested in evangelism and
computing mysticism here than in solving decently complex problems.
You saw the thread title. You saw that I'd asked the question of two
groups who might know practical somethings about regex's. For the
record, the folks over in the .NET groups have not berated me for also
talking about Perl.
The best approach would likely have been a silent plonking, I'd
estimate, either of the thread or of me, but the public "get offa my
cloud" is a bit much, dontcha think?
Rob
------------------------------
Date: Wed, 14 Apr 2004 00:17:37 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Tough (for me) regex case
Message-Id: <wX2fc.7671$2Z6.713035@news20.bellglobal.com>
"Rob Perkins" <rob_perkins@hotmail.com> wrote in message
news:qb5p70p7l720ajrjto1g3kfsr6j5568vfu@4ax.com...
> "Matt Garrish" <matthew.garrish@sympatico.ca> wrote:
>
> >> It makes me wonder if this .NET implementation approach is shared by
> >> other implementations. IOW, is the desirable (for my problem) behavior
> >> unique to Perl 5, or is the undesirable behavior unique to .NET?
> >>
> >
> >To put it bluntly, who cares?
>
> comp.lang.perl... what again?
>
> Ohyeah! MISC.
>
> Hmm.
>
Yes, it's for miscellaneous *Perl* questions. Stop being a dolt and figure
out that Perl and .net are not the same thing. Python has regular
expressions, why aren't you bugging the Python people? Even javascript has
them. I'm sure the people in those groups would love to hear about your .net
woes.
> >You should figure out if you're using the .net framework or if you're
> >writing a perl script and write your code according the rules of the
> >language. I have no idea how regular expressions are implemented within
> >.net, and am not going to figure them out for you.
>
> What of those using ActivePerl on the .NET framework? Which
> implementation will they hit?
>
Are you really this stupid, or are you just trolling?
> >Chances are you've misread the documentation (i.e., for all I know there
may
> >be an implicit capture around the entire pattern in .net). It could also
be
> >a poorly written program you're using to test with.
>
> Anything, I see, except the notion that Perl's regex implementation
> might be bugged. Well, OK, if that's the way you want it, but...
>
There is nothing buggy about Perl's implementation. It does exactly what
it's supposed to do. You have yet to show how it doesn't. According to you,
Perl's regexes are buggy because they don't capture text they're not
supposed to capture. All that has come from this thread is confirmation that
you are an idiot.
>
> You're leaving me with a really bad impression of the perl aficionados
> around here. People must be far more interested in evangelism and
> computing mysticism here than in solving decently complex problems.
>
There is nothing complex about your problem, and it was answered a long time
ago. That it was not answered to *your* satisfaction is no one's problem but
your own.
Matt
------------------------------
Date: Wed, 14 Apr 2004 06:43:01 GMT
From: Rob Perkins <rob_perkins@hotmail.com>
Subject: Re: Tough (for me) regex case
Message-Id: <efmp701m9kl8kicpl3vffibgobq4b2uo03@4ax.com>
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote:
>Yes, it's for miscellaneous *Perl* questions. Stop being a dolt and figure
>out that Perl and .net are not the same thing. Python has regular
>expressions, why aren't you bugging the Python people?
Didn't know Python had regular expressions.
> Even javascript has
>them.
Didn't know that, either.
>> What of those using ActivePerl on the .NET framework? Which
>> implementation will they hit?
>
>Are you really this stupid, or are you just trolling?
Niether. I'm genuinely curious about that one, what with my current
Perl engine being the ActivePerl stuff.
>All that has come from this thread is confirmation that
>you are an idiot.
Well, we'll just let stand that I haven't called anyone any names yet,
I guess.
And you're wrong about one thing: The other thing that came from this
thread was a workable regular expression that I could use for my
problem, and the revelation that regular doesn't mean "the same across
platforms."
For that, I thank all those who took time to educate me without
casting aspersions. I've learned quite a lot.
>There is nothing complex about your problem, and it was answered a long time
>ago. That it was not answered to *your* satisfaction is no one's problem but
>your own.
Then I have to ask, rhetorically of course, since I'm going to stick
your name in my bit bucket right after this, why do you keep
responding?
And I'll add that even the most self-important of those on the .NET/MS
newsgroups have never taken a misplaced question or a simplistic (to
them) problem and used that as a springboard to call me a dolt, an
idiot, a simpleton, a bad programmer, a non-reader of documentation,
or any other dehumanizing and overgeneralizing name.
There's just a precious few (two so far, around here) who insist that
the novices at their specialty are idiots, or that those who use
Microsoft stuff are clearly "agin' us."
Bubbye, Matt! <plonk>
Rob
------------------------------
Date: Wed, 14 Apr 2004 07:55:10 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: Tough (for me) regex case
Message-Id: <pan.2004.04.14.06.55.08.82851@dave.org.uk>
On Wed, 14 Apr 2004 06:43:01 +0000, Rob Perkins wrote:
> "Matt Garrish" <matthew.garrish@sympatico.ca> wrote:
>
>>Yes, it's for miscellaneous *Perl* questions. Stop being a dolt and figure
>>out that Perl and .net are not the same thing. Python has regular
>>expressions, why aren't you bugging the Python people?
>
> Didn't know Python had regular expressions.
>
>> Even javascript has
>>them.
>
> Didn't know that, either.
>
>>> What of those using ActivePerl on the .NET framework? Which
>>> implementation will they hit?
>>
>>Are you really this stupid, or are you just trolling?
>
> Niether. I'm genuinely curious about that one, what with my current
> Perl engine being the ActivePerl stuff.
ActivePerl is Perl. It is am implementation of the Perl language.
Therefore it uses regular expressions in the way defined by Perl.
Dave...
------------------------------
Date: Tue, 13 Apr 2004 20:33:50 -0700
From: "Robin" <robin @ infusedlight.net>
Subject: wow...jackpot.
Message-Id: <c5icl6$nag$1@reader2.nmix.net>
http://sunsite.iisc.ernet.in/virlib/cgi/week/ewtoc.html
I suppose the editors know about this?
haha...great site...
--
Regards,
-Robin
--
robin @ infusedlight.net
------------------------------
Date: Wed, 14 Apr 2004 06:13:35 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: wow...jackpot.
Message-Id: <pan.2004.04.14.04.05.25.380100@aursand.no>
On Tue, 13 Apr 2004 20:33:50 -0700, Robin wrote:
> http://sunsite.iisc.ernet.in/virlib/cgi/week/ewtoc.html
> I suppose the editors know about this?
I don't know, but I don't think they would bother, either. The book is
from 1996, and - therefore - quite outdated.
And: Every book which has a title that promises you to learn something in
x weeks, day or even hours is lying.
--
Tore Aursand <tore@aursand.no>
"The purpose of all war is ultimately peace." -- Saint Augustine
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6399
***************************************