[23601] in Perl-Users-Digest
Perl-Users Digest, Issue: 5808 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 15 14:05:44 2003
Date: Sat, 15 Nov 2003 11:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 15 Nov 2003 Volume: 10 Number: 5808
Today's topics:
Re: arrange form data in same order as on form <noreply@gunnar.cc>
Re: arrange form data in same order as on form <noreply@gunnar.cc>
Re: arrange form data in same order as on form (Randal L. Schwartz)
Re: arrange form data in same order as on form <flavell@ph.gla.ac.uk>
Re: arrange form data in same order as on form <noreply@gunnar.cc>
Re: arrange form data in same order as on form <noreply@gunnar.cc>
Re: Echo '*' chars instead of what's typed (Tad McClellan)
Re: extracting Javascript from a web page (Tad McClellan)
Re: Help <tore@aursand.no>
Re: Help <jurgenex@hotmail.com>
Re: Help <usenet@morrow.me.uk>
Re: Help <jurgenex@hotmail.com>
Re: Help <jwillmore@remove.adelphia.net>
Re: Help <usenet@morrow.me.uk>
Re: Is a value a decimal number or not? (Anno Siegel)
Re: long running perl programs & memory untilization <usenet@morrow.me.uk>
Re: my command (sorry newbe question) <usenet@morrow.me.uk>
Re: my command (sorry newbe question) <bmb@ginger.libs.uga.edu>
Re: Programming Pointer (William Herrera)
Re: regex to convert 1000000 -> 1,000,000 ? (Tad McClellan)
Re: regex to convert 1000000 -> 1,000,000 ? <jurgenex@hotmail.com>
Re: regex to convert 1000000 -> 1,000,000 ? <jwillmore@remove.adelphia.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 15 Nov 2003 15:10:27 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: arrange form data in same order as on form
Message-Id: <bp5cl1$1lbpp5$1@ID-184292.news.uni-berlin.de>
Tintin wrote:
> I agree with you about not calling code buggy to a certain degree.
> ... however, the typical newbie or person that writes "limited" CGI
> parsing code, generally does not write it deliberately with
> limitations. In most cases, I think it is fair to say they are
> writing code which they think works for all occasions.
Probably true. In those cases they have probably copied and tweaked
code that they don't fully understand. *That* is what's blameworthy,
not necessarily the code in itself.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 15 Nov 2003 15:10:33 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: arrange form data in same order as on form
Message-Id: <bp5cl7$1l1qb6$1@ID-184292.news.uni-berlin.de>
Eric J. Roode wrote:
> Gunnar Hjalmarsson wrote:
>> ... all potential variations are not applicable in all programs
>> that parse CGI data. For instance, if you want that a program
>> only parses POSTed data, it's not buggy because it isn't prepared
>> to handle potential variations in data submitted via GET.
>> Limited? Yes. Unflexible? Yes. Buggy? No.
>
> I just can't believe that anyone would advocate writing one's own
> limited CGI parsing code from scratch, against using the robust,
> flexible CGI.pm off the shelf.
One situation where doing so makes sense is when efficiency matters.
I have a program, where I believe it would be indefensible to have it
load CGI.pm. Maybe that's why I'm so sensible about this. :)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 15 Nov 2003 15:32:06 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: arrange form data in same order as on form
Message-Id: <8a045a7ee9ceb95f979f858e5228bb51@news.teranews.com>
>>>>> "Gunnar" == Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
Gunnar> One situation where doing so makes sense is when efficiency matters.
Gunnar> I have a program, where I believe it would be indefensible to have it
Gunnar> load CGI.pm. Maybe that's why I'm so sensible about this. :)
You *do* realize that CGI.pm uses a "compile as you go" mechanism?
Very little of the file is loaded unless you specifically ask for it.
Do not be confused by its sheer size.
I'd bet it'd be hard to get something that is even *twice* as efficient
that has all the security provisions and knowledge accumulated over
the years in CGI.pm.
Please show me your code that is more than twice as efficient as CGI.pm,
and yet as still as secure.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sat, 15 Nov 2003 15:46:24 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: arrange form data in same order as on form
Message-Id: <Pine.LNX.4.53.0311151541220.11512@ppepc56.ph.gla.ac.uk>
On Sat, 15 Nov 2003, Gunnar Hjalmarsson wrote:
> I have a program, where I believe it would be indefensible to have it
> load CGI.pm.
Then it's probably indefensible to run it from the traditional CGI in
the first place: you should be looking to run it from mod_perl or
other persistent environment, where the overhead of loading CGI.pm is
no longer of any relevance since it's not being done per-invocation
any more.
> Maybe that's why I'm so sensible about this. :)
"sensitive", maybe. "sensible"? - I'd have to reserve judgment until
I saw the full implications, including the security review and some
sensible assessment of the implications for long-term maintainability.
But since I probably couldn't afford the effort to do that security
review and maintainability assessment, I'd probably go with CGI.pm
anyway. I fear this is going to stir up the trolls again, but they're
fairly well plonked, so I'm just going to have my say and then leave
it at that.
cheers
------------------------------
Date: Sat, 15 Nov 2003 19:36:40 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: arrange form data in same order as on form
Message-Id: <bp5s90$1lat31$1@ID-184292.news.uni-berlin.de>
Randal L. Schwartz wrote:
> Gunnar Hjalmarsson writes:
>> One situation where doing so makes sense is when efficiency matters.
>>
>> I have a program, where I believe it would be indefensible to have it
>> load CGI.pm. Maybe that's why I'm so sensible about this. :)
>
> You *do* realize that CGI.pm uses a "compile as you go" mechanism?
Yep. Actually it was you who called my attention to it a few months
ago. :)
> I'd bet it'd be hard to get something that is even *twice* as efficient
> that has all the security provisions and knowledge accumulated over
> the years in CGI.pm.
>
> Please show me your code that is more than twice as efficient as CGI.pm,
> and yet as still as secure.
I don't claim it to be as secure as CGI.pm, but I believe that the
security of the program *as a whole* is sufficient. (Neither do I
claim it to serve as a general purpose code for parsing CGI data, of
course.)
This is the code I'm currently using *in that particular program*:
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read (STDIN, $rlmain::data, $ENV{'CONTENT_LENGTH'});
} else {
$rlmain::data = $ENV{'QUERY_STRING'};
}
$rlmain::data =~ tr/+/ /;
for (split /[&;]/, $rlmain::data) {
my ($name, $value) = split /=/;
$name = 'ringid' if lc $name eq 'ringid';
$name = 'siteid' if lc $name eq 'siteid';
$name = 'offset' if lc $name eq 'offset';
$value =~ s/%(..)/pack("c",hex($1))/ge;
$value =~ tr/\r//d; # Windows fix
$rlmain::data{$name} = $value;
}
Comments:
- I should probably have it check the size of STDIN and whether the
read() statement is successful.
- The program does not acknowledge any field names that don't match
/^\w+$/, so I don't unescape the names.
- The program does not contain any multi-value fields.
- The program is run in taint mode.
This is the web site for the program: http://www.ringlink.org/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 15 Nov 2003 19:36:43 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: arrange form data in same order as on form
Message-Id: <bp5s93$1jt6om$1@ID-184292.news.uni-berlin.de>
Alan J. Flavell wrote:
> Gunnar Hjalmarsson wrote:
>> I have a program, where I believe it would be indefensible to
>> have it load CGI.pm.
>
> Then it's probably indefensible to run it from the traditional CGI
> in the first place:
Some may claim it is. (For some reason that comment wasn't unexpected.
;-) )
> you should be looking to run it from mod_perl or other persistent
> environment, where the overhead of loading CGI.pm is no longer of
> any relevance since it's not being done per-invocation any more.
I have already done that, so the program is prepared to be (and is
actually in a few cases) run under mod_perl. However, there are
hundreds or 1,000+ users, and most of them don't have access to
mod_perl...
>> Maybe that's why I'm so sensible about this. :)
>
> "sensitive", maybe.
Hmm.. Yes, of course. It wasn't my intention to claim that I'm
sensible, even if *I* think I am. :)
> "sensible"? - I'd have to reserve judgment until I saw the full
> implications, including the security review and some sensible
> assessment of the implications for long-term maintainability.
Even if I provided a link in my reply to Randal, I ask you to please
not do that, Alan, at least not yet...
I started to write that program more than three years ago, and at that
time my programming experience basically consisted of having modified
a couple of Matt's Scripts. :) One thing that bothers me is all those
global scalar variables, so I'm sure you wouldn't find the program
easily maintained. Sooner or later I'll do a redesign, but I'll wait
until I have learned the basics of OOP.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 15 Nov 2003 11:25:43 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Echo '*' chars instead of what's typed
Message-Id: <slrnbrcocn.t03.tadmc@magna.augustmail.com>
Andrew DeFaria <Andrew@DeFaria.com> wrote:
> OK where do I get perldoc?
It is installed along with perl itself.
If you have a properly installed perl, then you already have it.
Looks like wherever it got installed is not in your path...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 15 Nov 2003 08:20:19 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: extracting Javascript from a web page
Message-Id: <slrnbrcdh3.qtk.tadmc@magna.augustmail.com>
Alex <aturchin@iname.com> wrote:
> I have a perl script which tries to read a web page and then submit
> data to a form using LWP::UserAgent. The page has some Javascript in
> the header which does not show when I look at the page's source, and
> which - I suspect - is crucial to filling the form out correctly (I
> keep getting 500 Server Error otherwise).
Run it through the Web Scraping Proxy to see what is really
being passed back and forth:
http://www.research.att.com/~hpk/wsp/
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 15 Nov 2003 16:33:21 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Help
Message-Id: <pan.2003.11.15.15.19.58.879109@aursand.no>
On Sat, 15 Nov 2003 06:09:56 -0800, Rob wrote:
> I have a small CGI script that attempts to create a file on the fly.
First of all: Your subject is not the subject of your posting. The
subject should be the _subject_ of the posting.
> The script runs successfully from the command prompt.
Which means that there are no errors in the script, right?
> Although when I execute in a browser [...]
No browsers - that I'm aware of - supports execution of Perl scripts. I
might be wrong, though.
What you actually mean, I guess, is that the web server executes, or tries
to execute, the script. Right?
Conclusion: There is obviously nothing wrong with your script as it runs
fine from the command line. When the (web) server is trying to execute
it, however, something fails. With this in mind, your question doesn't
seem to be related to Perl at all, right?
You should have posted your question in a newsgroup related to the (web)
server which executes your Perl scripts.
Am I totally wrong? If so, you should a described your problem better.
> system("./list $dbin _ list.$$") || print "Bad Return Code from system
> system("rm ./list.$$");
Are you sure these system calls are necessary? For the latter, you could
simple have used 'unlink';
"Deletes a list of files. Returns the number of files success-
fully deleted."
Anyway: I'm pretty tried right now, and I didn't try to run your code,
but I didn't see anywhere in the code that you try to create a file?
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Sat, 15 Nov 2003 15:46:32 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Help
Message-Id: <sTrtb.56761$p9.24409@nwrddc02.gnilink.net>
Rob wrote:
[Subject: Help]
The Perl help is called "perldoc". You use it by simply calling the command
"perldoc" from the command line.
Try "perldoc perldoc" for an explanation of options.
> I have a small CGI script that attempts to create a file on the fly.
> The script runs successfully from the command prompt.
Then I guess your Perl program is correct.
Please see "perldoc -q 500" for further trouble shooting information for CGI
scripts.
> Although when I execute in a browser
I may be wrong but IFAIK there is no browser that could execute a Perl
program.
> the file does not get created [...]
[program snipped]
I may be wrong but there doesn't seem to be any command in that program that
would create a file.
jue
------------------------------
Date: Sat, 15 Nov 2003 15:51:58 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Help
Message-Id: <bp5i2u$en2$1@wisteria.csv.warwick.ac.uk>
Tore Aursand <tore@aursand.no> wrote:
> No browsers - that I'm aware of - supports execution of Perl scripts. I
> might be wrong, though.
If you install PerlScript which comes with AS perl then IE will... ;)
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: Sat, 15 Nov 2003 15:53:38 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Help
Message-Id: <6_rtb.56764$p9.30018@nwrddc02.gnilink.net>
Ben Morrow wrote:
> Tore Aursand <tore@aursand.no> wrote:
>> No browsers - that I'm aware of - supports execution of Perl
>> scripts. I might be wrong, though.
>
> If you install PerlScript which comes with AS perl then IE will... ;)
Perlscript != Perl script
Or do you also believe that Javascript is the same as a Java script
jue
------------------------------
Date: Sat, 15 Nov 2003 16:01:27 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Help
Message-Id: <20031115110128.7a18e34e.jwillmore@remove.adelphia.net>
On 15 Nov 2003 06:09:56 -0800
roberie_g@yahoo.com (Rob) wrote:
Pick a more descriptive subject line next time :-)
<snip>
> use CGI ':standard';
use CGI qw(:standard -debug);
Using '-debug' will allow you to test at the command line. Now you'll
get:
jim@maxine:~> perl news4.pl
(offline mode: enter name=value pairs on standard input)
database=X
<CTRL-D> in *NIX or <CTRL-Z> in Windows
Notice that I did not pass the parameters _at_ the command line, but
was prompted for them. A lot easier to test :-)
perldoc CGI
<snip>
> system("./list $dbin _ list.$$") || print "Bad Return Code from
> system call: $?\n";
What is './list'? Can you execute just that at the command line?
And why '||' instead of 'or'? 'or' is more readable. And why not
'die' here? Later, you want to do something (it appears) with
'list.$$'. Is this a check to make sure you're not overwriting a file
that already exists?
If so, then why not
die "File exists\n" if(-e "list.$$");
> open(FCELST, "list.$$") || print "Database $dbin is currently
> unavailable: $!";
Again, why 'print' instead of 'die'?
<snip>
> system("rm ./list.$$");
More idiomatic Perl .....
unlink "list.$$" or die "Remove of file failed\n";
<snip>
This, should, get you started.
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Trying to be happy is like trying to build a machine for which
the only specification is that it should run noiselessly.
------------------------------
Date: Sat, 15 Nov 2003 16:09:34 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Help
Message-Id: <bp5j3u$f03$1@wisteria.csv.warwick.ac.uk>
"Jürgen Exner" <jurgenex@hotmail.com> wrote:
> Ben Morrow wrote:
> > Tore Aursand <tore@aursand.no> wrote:
> >> No browsers - that I'm aware of - supports execution of Perl
> >> scripts. I might be wrong, though.
> >
> > If you install PerlScript which comes with AS perl then IE will... ;)
>
> Perlscript != Perl script
> Or do you also believe that Javascript is the same as a Java script
Of course not. PerlScript is simply Perl, though, with all the MS COM
objects available as global variables as they are in Javascript.
Ben
--
The cosmos, at best, is like a rubbish heap scattered at random.
- Heraclitus
ben@morrow.me.uk
------------------------------
Date: 15 Nov 2003 17:20:01 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Is a value a decimal number or not?
Message-Id: <bp5n81$hgv$1@mamenchi.zrz.TU-Berlin.DE>
Ben Morrow <usenet@morrow.me.uk> wrote in comp.lang.perl.misc:
>
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> > In any case, the difference is in the internal representation of the
> > numbers -- a subject I had hoped to keep out of this discussion of
> > "decimals". Conceptually, there is no difference between 1 and 1.0.
>
> There can be. There is no difference between 1-as-a-member-of-the-
> set-of-reals and 1.0-as-a-member-of-the-set-of-reals. But 1-as-a-
> member-of-the-set-of-integers is a quite different beast. For
> instance, there is no such thing as the '1.0'th element of an array,
> for that would imply that there was also a '1.1'th element, which is
> clearly nonsense.
Here it is my turn to argue that, for any real x, "the x-th element of
an array" can be quite meaningful, if we extend the meaning of "array"
sufficiently. Hashes do that, in some ways.
> Sorry, as a mathematician I tend to be a little picky about such
> things :).
As a co-mathematician I agree that "no conceptual difference" was saying
the wrong thing.
Mathematics builds the number system in conventional steps:
natural -> integer -> rational -> real -> complex. At each step,
the newly introduced "numbers" have little to do with what was known
as numbers before, they are not only conceptually, but structurally
different.
However, after each step, mathematics goes out of its way to embed
(isomorphically) the old, smaller system into the new one, doing away
with structural differences. For instance, constructing the rationals
from the integers, these become just part of the newly constructed
rationals. Thus "1 = 1.0", and not only "consider_as_real( 1) = 1.0".
What I should have said is that "1" and "1.0" denote the same number (as
do "0x01", and a lot of other strings, under common conventions). After
mapping the strings to numbers, the values can't be distinguished.
It would have been correct to say the difference between 1 and 1.0
is *only* conceptual.
Anno
------------------------------
Date: Sat, 15 Nov 2003 15:25:44 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: long running perl programs & memory untilization
Message-Id: <bp5gho$e4a$1@wisteria.csv.warwick.ac.uk>
Stan Brown <stanb@panix.com> wrote:
> In <bp1547$h0a$2@wisteria.csv.warwick.ac.uk> Ben Morrow
> <usenet@morrow.me.uk> writes:
> >Stan Brown <stanb@panix.com> wrote:
> >> In <20031113163837.417$N1@newsreader.com> ctcgag@hotmail.com writes:
> >>
> >> >Stan Brown <stanb@panix.com> wrote:
> >> >>
> >> >> Thanks. The latest one of these "long running" scripts to
> >> >> exhibit this behavior, is really quite simple, in what it
> >> >> does, and has no real complex data structures.
> >> >>
> >> >> I suppose it would be inappropriate to post it here for
> >> >> criticism, right?
> >>
> >> >As long as the script is short and strict, it wouldn't be at all
> >> >inappropriate. Does the script run full-bore for months, or is
> >> >it some kind of server-like thing that spends most of it's time
> >> >waiting?
> >>
> >> It does setup stuff (a lot of that), and then goes into a loop. In this
> >> loop it does a system call
>
> >This is a little confusing... when I first read it, I parsed it as
> >'system call' in the sense of something like fcntl(2). It would be
> >better to say 'it runs v4lctl with system()' or something :).
>
> >> to v4lctl to capture an image, then goes bacl to
> >> sleep and waits. Curently it's one image every 10 seconds. Running since
> >> moday, it had grown to a size of 1/2 a gig :-(
>
> >What does it do with the image? Are you sure you aren't keeping them
> >all in memory somewhere by mistake?
>
> >Post just the loop for us to have a look at.
>
> Well, since I aparantely ofended all of you by posting it all, as I judge
> from zero reolies, here is the cut down version:
Well, speaking for myself, I was hardly offended :). I just couldn't
see anything obvious, and didn't really feel like trying to understand
all that code.
> use strict;
> use AppConfig::File;
> use IO::Handle;
> use Getopt::Mixed "nextOption" ;
> use Time::HiRes qw( gettimeofday tv_interval);
> use Data::Dumper;
> use Term::ANSIColor qw(:constants);
> use Date::Calc qw( Today Day_of_Week );
> use Time::Local;
> use Time::CTime;
> use Time::HiRes qw(gettimeofday);
> use Image::Magick;
> use File::Path;
> use File::lockf;
> use Term::ANSIColor qw(:constants);
> use Video::Capture::V4l;
> use Imager;
> use Devel::Leak;
Part of providing a minimal example is removing all modules that can
be removed while still leaking. IMHO (and not really having much
justification for this beyond instinct), the only modules likely to
cause leaks here are Image::Magick, Imager and V::C::V4l. As you say
below that it still leaks if you use system() to run v4lctl, I reckon
your problem may be with Image::Magick. What happens if you just run
your addtime() routine in a loop?
If that doesn't leak, then try again, cutting out *absolutely*
*everything* you can that doesn't stop the leak.
> $::cfg_file = "/opt/local/lib/webcam.conf";
On an unrelated subject, doing this rather defeats the point of
strictures. You shoould write
our $cfg_file = "/opt/local/lib/webcam.conf";
and then refer to $cfg_file thereafter.
Ben
--
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~ Jorge Luis Borges, 'The Babylon Lottery'
------------------------------
Date: Sat, 15 Nov 2003 15:03:57 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: my command (sorry newbe question)
Message-Id: <bp5f8t$dn7$1@wisteria.csv.warwick.ac.uk>
Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
> On Sat, 15 Nov 2003, Ben Morrow wrote:
> > Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
> > > On Wed, 12 Nov 2003, Chris Mattern wrote:
> > > > Chris Lynch wrote:
> > > > > You don't always need the "my" when you declare a variable.
> > > >
> > > > If you program with strict (and you should *always* program with
> > > > strict), then you will need *something*--my, our, global, whatever...
> > >
> > > my, our, local, PACKAGE::, what else?
> >
> > use vars
> >
> > *var = \$var;
> >
> > These are equivalent, and both have been obsoleted by our().
>
> Yes, I should have included use vars with our.
Well, I wouldn't really say so, given that it's obsolete.
> But I don't follow the second example, so I'm sure I'm missing
> something that I ought to know.
>
> In the first case below, I took your example literally, though I feel you
> didn't mean it that way. In the second case, I changed it to what I
> thought you meant. But I don't catch how this would be used to avoid the
> other ways to declare ...
Sorry, I was being somewhat facetious and my example was unclear :).
Try
perl -Mstrict -e'BEGIN {package vars; *main::var = \$main::var} $var=1'
which is exactly what vars.pm does. Yes, theoretically the BEGIN
block does precisely nothing, but nevertheless it keeps strict happy.
Ben
--
Although few may originate a policy, we are all able to judge it.
- Pericles of Athens, c.430 B.C.
ben@morrow.me.uk
------------------------------
Date: Sat, 15 Nov 2003 11:11:54 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: my command (sorry newbe question)
Message-Id: <Pine.A41.4.58.0311151107430.18910@ginger.libs.uga.edu>
On Sat, 15 Nov 2003, Ben Morrow wrote:
>
> Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
> > On Sat, 15 Nov 2003, Ben Morrow wrote:
> > > Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
> > > > On Wed, 12 Nov 2003, Chris Mattern wrote:
> > > > > Chris Lynch wrote:
> > > > > If you program with strict (and you should *always* program with
> > > > > strict), then you will need *something*--my, our, global, whatever...
> > > > my, our, local, PACKAGE::, what else?
> > > use vars
> > > *var = \$var;
> > > These are equivalent, and both have been obsoleted by our().
> > Yes, I should have included use vars with our.
>
> Well, I wouldn't really say so, given that it's obsolete.
Just that I suspect there's a lot of code folks might see that still uses
it, so it's still good to know about.
> Sorry, I was being somewhat facetious and my example was unclear :).
> Try
>
> perl -Mstrict -e'BEGIN {package vars; *main::var = \$main::var} $var=1'
>
> which is exactly what vars.pm does. Yes, theoretically the BEGIN
> block does precisely nothing, but nevertheless it keeps strict happy.
Fair enough, thanks. :-)
Regards,
Brad
------------------------------
Date: Sat, 15 Nov 2003 14:48:04 GMT
From: wherrera@lynxview.com (William Herrera)
Subject: Re: Programming Pointer
Message-Id: <3fb63b28.388925416@news2.news.adelphia.net>
On Sat, 15 Nov 2003 08:19:39 -0500, "Gary" <reachus@netlink.info> wrote:
>Are you saying that the crude way I have described here is the way.
>
>i.e There is no changed record status maintained or clever little technique
>for doing this update. You have to actually code it (Updates)manually in
>full every time.
How would you do this in straight SQL queries on the database in question?
>
>Assuming you do not buy the tools where it is already written for your use.
Unless you arrange to cache the updates yourself (that is, create a duplicate
database and just sync the two datasets occasionally), yes, you need to inform
the database of the changes each time. I beleieve this would be true no matter
what SQL interface you were using, of course.
In addition, there is the question of whether your changes are to result in a
changed record (I guess you mean to do that?) or add a new one.
---
Use the domain skylightview (dot) com for the reply address instead.
------------------------------
Date: Sat, 15 Nov 2003 08:17:10 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regex to convert 1000000 -> 1,000,000 ?
Message-Id: <slrnbrcdb6.qtk.tadmc@magna.augustmail.com>
bad_knee <bl8n8r@yahoo.com> wrote:
> bl8n8r@yahoo.com (bad_knee) wrote in message news:<e817ca4d.0311141105.1cc58788@posting.google.com>...
>> I was wondering if anyone had a quick one for "commatizing" a
>> number in perl?
> Sheesh.. thought this would be an easy one for you guys.
It _is_ easy, we'd just look it up in the Perl FAQ.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 15 Nov 2003 15:03:59 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: regex to convert 1000000 -> 1,000,000 ?
Message-Id: <zfrtb.56751$p9.14375@nwrddc02.gnilink.net>
bad_knee wrote:
> bl8n8r@yahoo.com (bad_knee) wrote in message
> news:<e817ca4d.0311141105.1cc58788@posting.google.com>...
>> I was wondering if anyone had a quick one for "commatizing" a
>> number in perl?
>
> Sheesh.. thought this would be an easy one for you guys.
What do you mean?
Is there anything wrong with the answer given in the FAQ?
perldoc -q comma: "How can I output my numbers with commas added?"
jue
------------------------------
Date: Sat, 15 Nov 2003 15:18:21 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: regex to convert 1000000 -> 1,000,000 ?
Message-Id: <20031115101823.6a14633a.jwillmore@remove.adelphia.net>
On 15 Nov 2003 05:38:41 -0800
bl8n8r@yahoo.com (bad_knee) wrote:
> bl8n8r@yahoo.com (bad_knee) wrote in message
> news:<e817ca4d.0311141105.1cc58788@posting.google.com>...
> > Hello,
> > I was wondering if anyone had a quick one for "commatizing" a
> > number in perl?
> >
> > Thanks
>
> Sheesh.. thought this would be an easy one for you guys.
> Oh well, for anyone interested...
>
> $number = "10001324512461346234500";
> $sep = ",";
> $number =~
> s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1$sep/g; print
> "num:$number\n";
>
> cheers!
I'm glad to see you looked at the FAQ for yourself - since this is
where you got the answer to your own question.
perldoc -q 'How can I output my numbers with commas added'
If this was supposed to be a test, you should have said so in your
post - so we could plonk you earlier :-)
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Eighty percent of air pollution comes from plants and trees. --
Ronald Reagan, famous movie star
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5808
***************************************