[22143] in Perl-Users-Digest
Perl-Users Digest, Issue: 4364 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 8 09:07:43 2003
Date: Wed, 8 Jan 2003 06:05:08 -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 Wed, 8 Jan 2003 Volume: 10 Number: 4364
Today's topics:
/g is not working in counting substring globally (ashish anand)
Re: A Good Perl Book <sjcole@no_spam.hotmail.com>
How do you use cgi.pm to parse multiple records of data (Entfred)
Re: How to use the function of "Regular Expression Sear <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: How to use the function of "Regular Expression Sear <mgjv@tradingpost.com.au>
Re: Lexical scope bug in eval()? <nobull@mail.com>
Re: Need to enter to finish perl script <nobull@mail.com>
No such file or directory error (Rondoggung)
Re: OO primer, please! <bik.mido@tiscalinet.it>
Re: OO primer, please! <tassilo.parseval@post.rwth-aachen.de>
Re: perl efficiency tip <comdog@panix.com>
Perl Modules (Jason Singleton)
Re: Perl Modules <bart.lateur@pandora.be>
Re: reading output of tar in blocks <nobull@mail.com>
Re: Reg Expression help <Jodyman@hotmail.com>
Re: Reg Expression help <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: Reg Expression help (Tad McClellan)
Taint check question <md0nilhe@mdstud.DIESPAMchalmers.se>
Re: the length of empty? <bongie@gmx.net>
Re: the length of empty? <bart.lateur@pandora.be>
Re: These are discouraging stats to Perlistas & Pythoni (Sara)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 Jan 2003 05:49:37 -0800
From: a.atul@angelfire.com (ashish anand)
Subject: /g is not working in counting substring globally
Message-Id: <9b07efc1.0301080549.4e45c5ee@posting.google.com>
hi,
counting substring TT in pattern ATTTAG through /g is not working. It
gives only 1 occurance of TT while there are 2 occurances of TT. how
to solve this problem.
thanks
------------------------------
Date: Wed, 8 Jan 2003 12:47:15 -0000
From: "Steve C" <sjcole@no_spam.hotmail.com>
Subject: Re: A Good Perl Book
Message-Id: <v1o7dn888mkoc7@corp.supernews.com>
Thank you all for your comments and assistance.
I think I'll plug for the Lama book to start of with and then get one of the
reference books once I start to get a hang of things.
I had about 6 months experience doing some C coding about 10 years ago, but
I didn't list that as one of the languages I'd worked with, as 6 months C
didn't get me very far at all ;-)
Thanks again
Steve.
"Steve C" <sjcole@hotmail.com> wrote in message
news:1041892886.117181@ananke.eclipse.net.uk...
> Hiya Folks,
>
> I'm just about to order the O'Reilly book: Programming Perl (Authors Larry
> Wall, Tom Christiansen, Jon Orwant)
> I know there's plenty of online material - but you know, I like to be able
> to read something in the local pub / bar ! (sad !!)
>
> Is this book to be recommended by the many perl gurus on this NG, or
should
> I be considering something different ?
> For information: I have only ever programmed in PASCAL, BASIC, COBOL,
Visual
> Basic (Arrgghh!) and more recntly dabbled with PHP4
>
> Many Thanks
>
> Steve C.
>
>
>
>
------------------------------
Date: 8 Jan 2003 01:19:55 -0800
From: entfred@hotmail.com (Entfred)
Subject: How do you use cgi.pm to parse multiple records of data entered on an html screen?
Message-Id: <d6e12cad.0301080119.1e61ee42@posting.google.com>
I am trying to program a form that allows multiple lines entered on
the screen to be saved in a data structure for future processing.
For example, a user might enter 4 records on an HTML screen having
track, artist, CD. When the user presses the submit button, the fields
are passed to a CGI program to parse the fields.
I have something like the following working, but I would rather use
CGI.PM to do this. I didn't see any built-in functions in CGI.PM to do
this. My next step was to go through all the cgi.pm source and, perhaps,
modify the lines that do the actual parsing, but before doing that,
I was wondering if there is a function I overlooked when reading all
the cgi.pm documentation.
Thanks for any hints or tips on this!
foreach $entry (@entries) {
local($name, $value) = split(/=/, $entry);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
if (defined $noDisplay{$name} ) {
$noDisplay{$name} = $value;
} elsif ($Form{$name} && $value) {
$Form{$name} = "$Form{$name}\n$value";
} elsif ($value) {
push(@fieldOrder,$name);
$Form{$name} = $value;
}
if ($name eq "track") {
$track = $value;
} elsif ($name eq "artist") {
$artist = $value;
} elsif ($name eq "cd") {
$cd = $value
}
if ($name eq "cd") {
print "reached last field in a record<br>\n";
#process record - store in flat file or database
#..........
#..........
}
}
--- Entfred
------------------------------
Date: Wed, 8 Jan 2003 08:41:27 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: How to use the function of "Regular Expression Search/Replace"?
Message-Id: <avgo7n$j50$1@korweta.task.gda.pl>
In article <324590c7.0301071703.2fa374d@posting.google.com>, niudou
wrote:
> When use it every time, there will be a prompt message, showing "You
> must select some text first". So where and how to "select" the text,
> and what does the "text" mean?
What are you talking about?
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Wed, 8 Jan 2003 20:03:31 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: How to use the function of "Regular Expression Search/Replace"?
Message-Id: <slrnb1nqb3.j6h.mgjv@martien.heliotrope.home>
On 7 Jan 2003 17:03:12 -0800,
niudou <niudou@hotmail.com> wrote:
> When use it every time, there will be a prompt message, showing "You
> must select some text first". So where and how to "select" the text,
> and what does the "text" mean?
Perl does not prompt when you use s/// (which I suspect is the
"Search/Replace" you're talking about in the subject), and Perl has no
concept of selecting text.
Maybe you should explain what you are doing exactly, but before
reposting, make sure that you are indeed talking about Perl.
Martien
--
|
Martien Verbruggen | Since light travels faster than sound, isn't
| that why some people appear bright until you
| hear them speak?
------------------------------
Date: 08 Jan 2003 12:04:49 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Lexical scope bug in eval()?
Message-Id: <u97kdfrgny.fsf@wcl-l.bham.ac.uk>
mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow) writes:
> I have come across something which I can only explain as a bug in
> perl.
If you take a look at some of the numerous previous threads on this
subject you'll see it's not a bug but a necessary feature.
For example see message <76e4509c.0207020902.3dd6a3a3@posting.google.com>
http://groups.google.com/groups?selm=76e4509c.0207020902.3dd6a3a3%40posting.google.com
> sub foo {
> # $var = $var; # uncommenting this removes the bug.
> eval "print defined(\$var) ? 'yes' : 'no'";
> }
> My guess would be this is some bug in setting up the function's lexical pad? I
> don't know enough perl internals to attempt to verify this.
Fixing this "bug" in the interactions between closures and eval would
mean that all file-scoped lexicals would get copied to the pads of all
subroutines that contain eval(STRING).
Think about the implications that would have for memory usage and the
timely calling of DESTROY methods.
> Should I go ahead and report this?
No.
> Is it known already?
Yes.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 08 Jan 2003 12:33:41 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Need to enter to finish perl script
Message-Id: <u9vg0zq0re.fsf@wcl-l.bham.ac.uk>
Uri Guttman <uri@stemsystems.com> writes:
> >>>>> "cz" == c0rum z <c0rum_z@yahoo.com> writes:
>
> cz> Attached is my script which I did not write.
>
> long and very poorly written. a few notes follow.
[ snip many valid criticisms ]
> cz> if ($nzr > 0) {
> cz> "0"x$nzr . ($val);
> cz> }
> cz> else {
> cz> $val;
> cz> }
>
> gack! default returning a val from an if/else is horrible.
You are free to dislike the use of if/else in a non-void context but I
beg to differ. I quite like the construct. If I have...
EXPR ? EXPR : EXPR
...in a script and I find the expressions are getting too long to be
easily readable I'll often re-write it as...
do {
if ( EXPR ) {
EXPR;
} else {
EXPR;
}
}
> so the best thing to do is delete this script and find a better
> one.
This is a valid conclusion.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 8 Jan 2003 05:28:34 -0800
From: fmmpd@hotmail.com (Rondoggung)
Subject: No such file or directory error
Message-Id: <f0eaf5d1.0301080528.3b8c72d0@posting.google.com>
Hello,
I am setting up a click tracking script (Ultimate Ad Tracker). The
script used to work on all my previous servers but not on my new
server.
I can actually access the admin.cgi login page but it wouldn't let me
set the admin password on first installation. It produces this error
Cant open /var/www/cgi-bin/track/data/adps.txt(No such file or
directory)!
I know the path and perl location (#!/usr/bin/perl) are correct
because I can run the script via web browser. It just unable to create
or access the adps.txt (password file) in the data directory. This
file is created by the script which contains the encrypted admin
password.
I chmod the data directory to 777, tried to create a blank adps.txt
file and chmod it to 777, throw it to data directory but nothing seems
to work.
One thing I realised though, on my new server, the location of the
cgi-bin is
/home/p2pmusic/mainwebsite_cgi
which is shown when I pwd using ssh (is that what they call a symbolic
link?). But the real location is /var/www/cgi-bin.
I tried changing the path using both but still doesn't work. Other
scripts in the cgi-bin work perfectly fine though. The server is
running RedHat Linux 7.2.
Any ideas how I can correct the error?
Thanks in advance.
Rondoggung
------------------------------
Date: Wed, 08 Jan 2003 09:18:48 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: OO primer, please!
Message-Id: <s1nn1vcnhk0eo1875a7127cdssugpfvu6t@4ax.com>
On 6 Jan 2003 09:18:54 GMT, "Tassilo v. Parseval"
<tassilo.parseval@post.rwth-aachen.de> wrote:
>A common skeleton is to have one constructor in which you bless
>something into the class and the instance methods.
[code snipped]
Thanks, that was a *primer* indeed... now I'm looking into the docs!!
> my ($self, $x, $y) = @_;
> return $self->[$x]->[$y];
Just one minor question: why didn't you omit the second arrow?
Wouldn't it psychologically help to distinguish between the "actual"
dereferentiation and what can be perceived intuitively as a
multi-dimensional index?
>put() is a good candidate for a chained method, something like:
That was not what I was thinking of, but... no harm done pointing it
out!
>Making entry() lvaluable looks natural. You have to change it only
>slightly to achieve this, basically by adding the 'lvalue' attribute:
Did seem *very* natural to me too: was not sure wether an experienced
programmer would have agreed. Your placet was an in(l)valuable
encouragement.
>Even though the skeleton layed out here is already quite flexible
>(despite its simplicity) you should read the supplied documents. The
I'm *also* reading the two freely distributed chapters of Damian
Conway's book (that another poster suggested).
>This can easily be turned into a method. Remember that $self is a
>reference to the blessed array that contains the data:
>
> sub print {
> my $self = shift;
> local ($,, $\) = ("\t", "\n");
> print @$_ for @$self;
> }
unluckily it can't be that simple since we cannot be sure that the
table is filled completely. For its current purpose, the most simple
variation (that yields a satisfactory result for me) I could devise
is:
sub print {
my $self = shift;
local ($^W, $\, $,) = (0, "\n", "\t");
defined $_ and print @$_ for @$self;
}
Also, to yield an intuitive layout, I had to switch $x and $y in
storing the values, for even though the order "(x,y)" is etched in our
cortex, we do naturally "write" by rows, that is, "y first".
Believe it or not, these two minor details with the print sub were the
most instructive part of my "experiment": the conclusion I got at is
that even if mine is a naive exaple, it exemplifies the kind of
dilemmas one is probably faced with continuously when designing bigger
applications.
I would expand more on this subject, but as of now I really can't, so
I'll just list some of the questions that I posed to myself:
(i) should I switch the internal order of storage, thus making the
underlying logic a little clumsier (hey, I do know what comments are
for!) or should I change the printing method? This also naturally
leads to the next point:
(ii) should I rely on Perl's automagic recognition of "boundaries" as
in the code above for print() or write explicit cycles? But then I
should change the other methods to keep track of some critical
parameters and possibly making the whole mechanism more robust: but
would it be worth?
I think that the answer to both questions, or better, to their
possible generalizations, strongly depends on the actual size and
charachteristics of the application one is developing: the
psychological feeling is that at least in some cases one will have to
give up with tecniques commonly used for "casual programming", but
then it is my understanding that OO philosophy in general is
especially aimed at supporting programming in large.
Michele
--
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth. See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"
------------------------------
Date: 8 Jan 2003 09:46:39 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: OO primer, please!
Message-Id: <avgs1v$glh$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Michele Dondi:
> On 6 Jan 2003 09:18:54 GMT, "Tassilo v. Parseval"
><tassilo.parseval@post.rwth-aachen.de> wrote:
>
>>A common skeleton is to have one constructor in which you bless
>>something into the class and the instance methods.
>
> [code snipped]
>
> Thanks, that was a *primer* indeed... now I'm looking into the docs!!
>
>> my ($self, $x, $y) = @_;
>> return $self->[$x]->[$y];
>
> Just one minor question: why didn't you omit the second arrow?
> Wouldn't it psychologically help to distinguish between the "actual"
> dereferentiation and what can be perceived intuitively as a
> multi-dimensional index?
In this case, yes: $self->[$x][$y] might make it clearer. Always using
the arrow (even where it could be left off) is a habit of me. This here
is actually a good example that I should revise my coding style at some
points. The other notion looks more suitable here.
>>Making entry() lvaluable looks natural. You have to change it only
>>slightly to achieve this, basically by adding the 'lvalue' attribute:
>
> Did seem *very* natural to me too: was not sure wether an experienced
> programmer would have agreed. Your placet was an in(l)valuable
> encouragement.
The reason why not every Perl hacker would agree on lvaluable
subroutines is not so much the concept of it (at least so I think) but
rather the 'experimental' flag attached to it. I, on the other hand,
never had any problems with it. I'd be interested in a comment from
someone being more familiar with perl's internals on how experimental
this really is and under which circumstances it could break.
>>(despite its simplicity) you should read the supplied documents. The
>
> I'm *also* reading the two freely distributed chapters of Damian
> Conway's book (that another poster suggested).
The whole book is useful when you are very serious about OO-Perl. It
demonstrates some nifty techniques (especially the usage of closures to
achieve very strong encapsulation). But the later chapters on multiple
dispatch etc. are a little bit too in-depth for me.
>>This can easily be turned into a method. Remember that $self is a
>>reference to the blessed array that contains the data:
>>
>> sub print {
>> my $self = shift;
>> local ($,, $\) = ("\t", "\n");
>> print @$_ for @$self;
>> }
>
> unluckily it can't be that simple since we cannot be sure that the
> table is filled completely. For its current purpose, the most simple
> variation (that yields a satisfactory result for me) I could devise
> is:
>
> sub print {
> my $self = shift;
> local ($^W, $\, $,) = (0, "\n", "\t");
> defined $_ and print @$_ for @$self;
> }
More flexible would be using the warnings pragma:
#! /usr/bin/perl
# ^^ no -w switch
use warnings;
...
And:
sub print {
my $self = shift;
local ($\, $,) = ("\n", "\t");
no warnings 'uninitialized';
print @$_ for @$self;
}
All the warning categories are described in perllexwarn.pod.
> Also, to yield an intuitive layout, I had to switch $x and $y in
> storing the values, for even though the order "(x,y)" is etched in our
> cortex, we do naturally "write" by rows, that is, "y first".
>
> Believe it or not, these two minor details with the print sub were the
> most instructive part of my "experiment": the conclusion I got at is
> that even if mine is a naive exaple, it exemplifies the kind of
> dilemmas one is probably faced with continuously when designing bigger
> applications.
These details are the things you will constantly struggle with. Unlike
big issues, they get only a little attention. Say you have five of these
details and all solve them in a bad manner: this can destroy a whole
API.
> I would expand more on this subject, but as of now I really can't, so
> I'll just list some of the questions that I posed to myself:
>
> (i) should I switch the internal order of storage, thus making the
> underlying logic a little clumsier (hey, I do know what comments are
> for!) or should I change the printing method? This also naturally
> leads to the next point:
Switching the order internally should even be clear without a comment.
'$self->[$x][$y]' would become '$self->[$y][$x]'. It would have one
other convenience. Whenever you are debugging the data are already in a
natural format. You may find that you will be using Data::Dumper quite a
lot for this purpose.
> (ii) should I rely on Perl's automagic recognition of "boundaries" as
> in the code above for print() or write explicit cycles? But then I
> should change the other methods to keep track of some critical
> parameters and possibly making the whole mechanism more robust: but
> would it be worth?
Making things robust is never wrong. You could add a private method that
normalizes your table before printing it out:
sub _normalize {
my $self = shift;
for my $row (@$self) {
$row = [ map { defined $_ ? $_ : "<undef>" } @$row ];
}
}
Call this from print(). This however is destructive so it will change
your table permanently. You can make _normalize() return a copy of
@$self (with Storable::dclone() for instance) and print out this copy,
of course.
> I think that the answer to both questions, or better, to their
> possible generalizations, strongly depends on the actual size and
> charachteristics of the application one is developing: the
> psychological feeling is that at least in some cases one will have to
> give up with tecniques commonly used for "casual programming", but
> then it is my understanding that OO philosophy in general is
> especially aimed at supporting programming in large.
Quite so. Fortunately, OO in Perl doesn't require very verbose
preparations and imposes low overhead (on the programmer!) so its
benefits come quite cheap.
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Wed, 08 Jan 2003 03:35:02 -0600
From: brian d foy <comdog@panix.com>
Subject: Re: perl efficiency tip
Message-Id: <080120030335023089%comdog@panix.com>
In article <avgk8t$7df$1@canopus.cc.umanitoba.ca>, Walter Roberson
<roberson@ibd.nrc-cnrc.gc.ca> wrote:
> So... the tip for today is that if you are doing a lot of matches,
> processing large files, then multiple matches in succession might be
> MUCH faster for you then using .*'s to join required subsequences.
Jefffrey Freidl has a wonderfully clear explanation of this in
_Mastering Regular Expressions_. :)
--
brian d foy, comdog@panix.com
------------------------------
Date: 8 Jan 2003 04:55:07 -0800
From: jsn@microlib.demon.co.uk (Jason Singleton)
Subject: Perl Modules
Message-Id: <5b7e0283.0301080455.2c2ba83a@posting.google.com>
Is it possible to use modules with out installing them?
I need to use the DBI interface on varying servers and not all support
installation of the module they arn't all the same platform either
some unix/linux and some win32.
------------------------------
Date: Wed, 08 Jan 2003 13:11:41 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Perl Modules
Message-Id: <788o1vgtnmtj079s5fj03snqvbvt6asfbi@4ax.com>
Jason Singleton wrote:
>Is it possible to use modules with out installing them?
With Pure Perl modules, yes. Just copy the modules' source to the proper
location in a directory tree visible in @INC. Watch out for modules that
depend on AutoSplit. You'll have to remove the dependency on
AUTOLOAD/AutoLoader, or split it up yourself. You need to be knowing
what you're doing, then.
>I need to use the DBI interface on varying servers and not all support
>installation of the module they arn't all the same platform either
>some unix/linux and some win32.
The best thing would be to use plain DBI if it's available.
Unfortunately for you, it is also an XS module, meaning it requires a C
compiler for installation, or a precompiled DLL (to use the Windows
term).
I think they're currently working on a Pure Perl version for where
that's not an option, see DBI::PurePerl on CPAN.
Be careful that you also use the PurePerl versions for the necessary DBD
drivers, if available. It's a recent, growing project, so more should be
available in the future. Inquire on the DBI-users mailing list, if you
can't find everything you need.
<http://lists.perl.org/showlist.cgi?name=dbi-users>
--
Bart.
------------------------------
Date: 08 Jan 2003 12:11:52 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: reading output of tar in blocks
Message-Id: <u93co3rgc7.fsf@wcl-l.bham.ac.uk>
Marek Zawadzki <mzawadzk@man.poznan.pl> writes:
> open(TAR, "tar -cf - $local_file|");
That's good, and should work on any version of Perl but, FYI, in Perl
5.8 there's a more elegant form:
open(my $tar, '-|', 'tar', '-cf', '-', $local_file)
or die "Could not fork tar suprocess: $!";
This uses a lexically scoped filehandle (or at least gives the
impression of doing so) and is not confused by shell metacharacters in
$local_file.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 08 Jan 2003 11:25:04 GMT
From: "Jodyman" <Jodyman@hotmail.com>
Subject: Re: Reg Expression help
Message-Id: <kUTS9.22670$9N5.2069507@newsread2.prod.itd.earthlink.net>
"Uri Guttman" <uri@stemsystems.com> wrote in message
> >>>>> "J" == Jodyman <Jodyman@hotmail.com> writes:
>
> J> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> J> news:slrnb1m7j8.h15.tadmc@magna.augustmail.com...
>
> >> You would use tr///
>
> J> foreach (@letters) {
> J> if ($_ eq '+') { push (@newletters, " ") }
> J> else { push (@newletters, $_) };
> J> };
>
> gack. if you are going to write bad code, do it well.
>
> push @newletters, $_ eq '+' ?, ' ' : $_ ;
>
> J> Very elegant and it works.
>
> not that elegant.
>
uri,
It was a joke. If you read the original message, obviously
the OP hadn't read any manuals and posted a question without
thinking. tr/+/ /; or s/+/ /g; was the easiest and correct answers.
LOL,
Jody
------------------------------
Date: Wed, 8 Jan 2003 11:43:59 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Reg Expression help
Message-Id: <avh2tv$g8g$2@korweta.task.gda.pl>
In article <kUTS9.22670$9N5.2069507@newsread2.prod.itd.earthlink.net>,
Jodyman wrote:
> "Uri Guttman" <uri@stemsystems.com> wrote in message
>> >>>>> "J" == Jodyman <Jodyman@hotmail.com> writes:
>>
>> J> "Tad McClellan" <tadmc@augustmail.com> wrote in message
>> J> news:slrnb1m7j8.h15.tadmc@magna.augustmail.com...
>>
>> >> You would use tr///
>>
>> J> foreach (@letters) {
>> J> if ($_ eq '+') { push (@newletters, " ") }
>> J> else { push (@newletters, $_) };
>> J> };
>>
>> gack. if you are going to write bad code, do it well.
>>
>> push @newletters, $_ eq '+' ?, ' ' : $_ ;
>>
>> J> Very elegant and it works.
>>
>> not that elegant.
>>
>
> uri,
>
> It was a joke. If you read the original message, obviously
> the OP hadn't read any manuals and posted a question without
> thinking.
Uri knows it was a joke. He only pointed out (correctly) that the joke
was bad and could have been done better.
> tr/+/ /; or s/+/ /g; was the easiest and correct answers.
Don't patronise.
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Wed, 8 Jan 2003 00:35:53 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Reg Expression help
Message-Id: <slrnb1nhm9.joe.tadmc@magna.augustmail.com>
Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "J" == Jodyman <Jodyman@hotmail.com> writes:
> J> if ($_ eq '+') { push (@newletters, " ") }
> J> else { push (@newletters, $_) };
> gack. if you are going to write bad code, do it well.
>
> push @newletters, $_ eq '+' ?, ' ' : $_ ;
^
^ wassat?
> J> Very elegant and it works.
>
> not that elegant.
not that works either. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 08 Jan 2003 12:53:06 +0100
From: henrik nilsson <md0nilhe@mdstud.DIESPAMchalmers.se>
Subject: Taint check question
Message-Id: <3E1C1122.4090907@mdstud.DIESPAMchalmers.se>
Hello
(Perl-CGI, taint check, Apache)
There are two things regarding the -T option that I'd like to know a bit
more about.
1. My script relies on a couple of old programs which only read infiles
in progdir and with a fixed name, INFILE. Hence, for the script to
potentially run in parallell, I have to make a tempdir for every script
instance and copy and run the programs there.
The taint check of course freaks out and asks me do the PATH thing. I
assume that I should indeed not reset PATH every time I run the script,
especially not if the script is run several times in parallell.
Is there any chance that my script will ever pass a taint check, and if
so, what should I do to make it happen?
2. Why do the lines
unlink <*.dnd>;
generate the taint check report
[Wed Jan 08 12:38:44 2003] [error] [client 127.0.0.1] [Wed Jan 8
12:38:44 2003] search.cgi: Insecure
dependency in unlink while running with -t switch at
/myapachedir/cgi-bin/script.cgi line 406., referer:
http://localhost/tst.html
I thought deletion from inside Perl was "safe"?
Thanks for your time,
Henrik N
------------------------------
Date: Wed, 08 Jan 2003 09:18:34 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: the length of empty?
Message-Id: <1540442.IjVkuPAY5h@nyoga.dubu.de>
qjzhu wrote:
> @test = undef;
undef() creates an undefined value, which is a valid scalar. Assigning
that to an array creates an array with one (undefined) entry, not an
empty array.
> print scalar @test; #print 1
>
> @test = ();
This way, you assign an empty list to the array.
> print scalar @test; #print 0
>
> what's the difference?
See "perldoc -f undef" and "perldoc -f defined".
Ciao,
Harald
--
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
++$sheep while !$asleep;
------------------------------
Date: Wed, 08 Jan 2003 10:16:59 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: the length of empty?
Message-Id: <1jun1vcn4qi2lmhras1ohvtdpqufmqjcbk@4ax.com>
qjzhu wrote:
> @test = undef;
> print scalar @test; #print 1
>
> @test = ();
> print scalar @test; #print 0
>
> what's the difference?
undef is a scalar. The first is like:
$foo = undef;
@test = ($foo);
--
Bart.
------------------------------
Date: 8 Jan 2003 05:35:54 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: These are discouraging stats to Perlistas & Pythonistas...
Message-Id: <776e0325.0301080535.121f3c93@posting.google.com>
Mike Meyer <mwm@mired.org> wrote in message news:<x7heckyeti.fsf@guru.mired.org>...
> "Robert Oschler" <Oschler@earthlink.net> writes:
>
> > I can't look at dice.com anymore, too depressing. Some appx stats:
> >
> > Date C++ jobs Java jobs
> > 3/2000 42000 31000
> > 10/2003 2200 2800
>
> Ok, where did you get the numbers for October 2003? Or is that 1/2003
> or 10/2002?
>
> Thanks,
> <mike
> --
> Mike Meyer <mwm@mired.org> http://www.mired.org/home/mwm/
> Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Sorry Mike this is all of the data I have. A friend emailed me this
table in a message and that's what I got. He wanted to "rub it in"
about how I'm "wasting my career" with Perl, PHP, and Python.
The way I look at it, if I was an artiste and everyone was working in
fingerpaints, I'd stil rather work in oils if that was the medium I
preferred. ASP is the fingerpaint, Perl is oils. Hope my ears survive
this quest!
Still, it would be comforting to know that there was a "market" for my
work.
-Gx
------------------------------
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 4364
***************************************