[23997] in Perl-Users-Digest
Perl-Users Digest, Issue: 6198 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 1 14:05:41 2004
Date: Mon, 1 Mar 2004 11:05:07 -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 Mon, 1 Mar 2004 Volume: 10 Number: 6198
Today's topics:
Re: EOL Anchor under Windows <olczyk2002@yahoo.com>
Re: EOL Anchor under Windows <flavell@ph.gla.ac.uk>
Re: EOL Anchor under Windows (Anno Siegel)
Re: finding common words <jgibson@mail.arc.nasa.gov>
Re: Global special variable alternative names <raisin@delete-this-trash.mts.net>
Re: how die in AUTOLOAD <yshtil@cisco.com>
Re: how die in AUTOLOAD (Anno Siegel)
Re: how die in AUTOLOAD <yshtil@cisco.com>
Re: how die in AUTOLOAD (Anno Siegel)
Re: Newbie Need help with if statement <arthur0421@163.com>
Re: Newbie Need help with if statement <ittyspam@yahoo.com>
Re: Newbie Need help with if statement <kasp@epatra.com>
Re: Newbie Need help with if statement (Anno Siegel)
Re: Newbie Need help with if statement <tore@aursand.no>
Re: Opening a unique dat file for each user <arthur0421@163.com>
Re: Opening a unique dat file for each user <usenet@morrow.me.uk>
Re: Opening a unique dat file for each user <g_klinedinst@hotmail.com>
Re: OS Version <jwillmore@remove.adelphia.net>
Re: OS Version <Mark.Fenbers@noaa.gov>
Re: OS Version <tore@aursand.no>
Regex comparison <lpeters@aol.net>
Re: Regex comparison <noreply@gunnar.cc>
Re: Regex comparison <lpeters@aol.net>
Storing numbers in an array from files (aleatory)
Re: Storing numbers in an array from files <noreply@gunnar.cc>
Suggest a suitable image modifying CPAN module <kasp@epatra.com>
Re: Thanks for the advice <nobody@somewhere-else.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 01 Mar 2004 11:05:38 -0600
From: TLOlczyk <olczyk2002@yahoo.com>
Subject: Re: EOL Anchor under Windows
Message-Id: <jlp640tus0j6gpe82uc4glamia0brmmonh@4ax.com>
On Sun, 29 Feb 2004 16:05:37 +0200, "Arifi Koseoglu" <arifi@tnn.net>
wrote:
>What is
>
>grep --extended-regexp --ignore-case '[[:punct:]]{1}[[:alnum:]]{3}$'
>
>supposed to match?
First of all, the guys who responded by slaming you for not specifying
the language are total idiots, don't worry about them. It was clear
from reading the *whole* post exactly what you were asking ( even
in an inappropriate newsgroup ). It actually did you good, because
these guys took themselves out of the running for answering your
questions. In my experience the reply they give is often stupid
precisely because they haven't read your whole post.
Send off. The groups that you asked in seem at least moderately
appropriate. comp.lang.awk seems a bit of a stretch, still not
a bad group to ask a regex question about. comp.lang.perl.misc
given it's reputation, I would not say it is a bad question for that
group. comp.programming, perfect forum, Virtually every modern
PL has a regex library, why's that? For the same reason a regex
question is appropriate here. Certainly more appropriate than
questions about IDEs or such. gnu.utils.help, grep is a gnu util, No?
Given that sometime peoples have questions which do not seem to
fit in an appropriate newsgroup, your choices seemed OK.
Now for the answer to your question.
If "abc" is a matched string, then grep may be trying to match to
the string "abc"$. Regex's are *not standardised* and vary from
implementation to implementation. Many implementations won't
like your :punct:, :alpha: constructs. I've used as delimiters for
grouping (),\(\),\\(\\),\\\\(\\\\). This isn't going to change anytime
soon, since there are literally millions of elisp,awk,sed,perl,...
libraries that use their form of regex, and the users will hound
to death the person that changes it ( better to suggest reducing
Social Security in a seniors home ).
There are other aspects. Someone suggested that there might be
white spaces at thje end. '[[:punct:]]{1}[[:alnum:]]{3}[:white:]*$'
or '[[:punct:]]{1}[[:alnum:]]{3}[ \t]$' should work if that is the
case.
Another suggested that your EOL might not be what grep expects it to
be. I would think that most greps consider the "system" EOL as EOL.
Open the file you are greping in emacs. If it says something like
UNIX in the status line then that may be the case. Otherwise it
probably isn't.
Finally I would create a test file, with text:
"abc$def"
"ghijkl "
"mnopqr"
( spaces are delimiters here ).
Grep for abc, abc$, jkl$,"jkl $","def"
see what kind of results you get.
The reply-to email address is olczyk2002@yahoo.com.
This is an address I ignore.
To reply via email, remove 2002 and change yahoo to
interaccess,
**
Thaddeus L. Olczyk, PhD
There is a difference between
*thinking* you know something,
and *knowing* you know something.
------------------------------
Date: Mon, 1 Mar 2004 17:37:14 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: EOL Anchor under Windows
Message-Id: <Pine.LNX.4.53.0403011727270.2651@ppepc56.ph.gla.ac.uk>
On Mon, 1 Mar 2004, TLOlczyk was observed on comp.lang.perl.misc to
have written:
> On Sun, 29 Feb 2004 16:05:37 +0200, "Arifi Koseoglu" <arifi@tnn.net>
> wrote:
>
> >What is
> >
> >grep --extended-regexp --ignore-case '[[:punct:]]{1}[[:alnum:]]{3}$'
> >
> >supposed to match?
>
> First of all, the guys who responded by slaming you for not specifying
> the language are total idiots,
I'm just a sceptical bystander. I've always found the regulars on
comp.lang.perl.misc to offer sound advice, even when that advice is
"find a better usenet group".
> Now for the answer to your question.
<rhetorical>
You have "the" answer?
</>
> If "abc" is a matched string, then grep may be trying to match to
> the string "abc"$.
Hmmm
> Regex's are *not standardised* and vary from
> implementation to implementation.
Oh, gosh. Are we surprised?
So maybe the specific situation that the questioner is in would
be an essential key to "the" answer, after all.
[...various woffle amputated...]
> Finally I would create a test file, with text:
> "abc$def"
> "ghijkl "
> "mnopqr"
> ( spaces are delimiters here ).
> Grep for abc, abc$, jkl$,"jkl $","def"
> see what kind of results you get.
This must be "the" answer, then, at least according to you.
Me, I think I'd go read the applicable documentation.
f'ups proposed. Have fun.
------------------------------
Date: 1 Mar 2004 18:26:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: EOL Anchor under Windows
Message-Id: <c1vv87$t0r$3@mamenchi.zrz.TU-Berlin.DE>
Arifi Koseoglu <arifi@tnn.net> wrote in comp.lang.perl.misc:
[newsgroups trimmed, irrelevance snipped]
> What is
>
> grep --extended-regexp --ignore-case '[[:punct:]]{1}[[:alnum:]]{3}$'
>
> supposed to match?
What is this, a quiz?
You tell us what you expect it to match and show us an example that
doesn't meet your expectations. Then we can talk.
Anno
------------------------------
Date: Mon, 01 Mar 2004 09:49:00 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: finding common words
Message-Id: <010320040949001712%jgibson@mail.arc.nasa.gov>
In article <6fd673b3.0403010450.74652ae8@posting.google.com>, viv2k
<viv2k@hotmail.com> wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message
> news:<c1id33$1iqib4$1@ID-184292.news.uni-berlin.de>...
> > If you encounter problems, please feel welcome to ask for help here,
> > but now we want to see code that you wrote.
>
> Ok guys, I've got a slightly different requirement now. The lists I
> have to compare have increased to 3 and I need to find out words that
> appear in at least two of the lists. However, if a word appears in
> only 2 list, I need to include it in my third list by giving it a
> default value, like '0'.
>
> Example:
> ListA
> Apple 4, Boy 3, Cat 5
> ListB
> Apple 1.0, Baby 2.1, Cat 3.3
> ListC
> Apple 99, Beef 100, Cow 101
>
> Should give me as result:
> ListA ListB ListC
> Apple 4 Apple 1.0 Apple 99
> Cat 5 Cat 3.3 Cat 0
>
> Right now, my code looks like below but I don't know how to give this
> default value. Any help is much appreciated.
>
[generation of ListA snipped]
>
> my %ListB;
> open my $fh, '< ListB.txt' or die "Couldn't open ListB.txt $!";
> while (<$fh>) {
> for (split /,\s*/) {
> my ($key, $value) = split;
> $ListB{$key} = $value;
Right here put:
$ListC{$key} = 0;
> }
> }
> close $fh;
>
Actual entry in list C will overwrite zero default in loop below.
> my %ListC;
> open my $fh, '< ListC.txt' or die "Couldn't open ListC.txt $!";
> while (<$fh>) {
> for (split /,\s*/) {
> my ($key, $value) = split;
> $ListC{$key} = $value;
> }
> }
> close $fh;
>
[rest of program snipped]
------------------------------
Date: Mon, 1 Mar 2004 11:34:15 -0600
From: Web Surfer <raisin@delete-this-trash.mts.net>
Subject: Re: Global special variable alternative names
Message-Id: <MPG.1aad300ddc28d8679897ba@news.mts.net>
[This followup was posted to comp.lang.perl.misc]
In article <eecd76f9.0403010714.13270ee3@posting.google.com>,
niall.macpherson@ntlworld.com says...
> Is there a 'use' directive I need to include in order to acess these ?
>
> If I use
>
> $!
>
> in my code it runs fine, but if I use
>
> $ERRNO
>
> (which I would prefer, for readability) I get
>
> H:\Perl Scripts>systest.pl
> Global symbol "$ERRNO" requires explicit package name at H:\Perl
> Scripts\systest
> .pl line 15.
> Global symbol "$ERRNO" requires explicit package name at H:\Perl
> Scripts\systest
> .pl line 18.
> Execution of H:\Perl Scripts\systest.pl aborted due to compilation
> errors.
>
> It's not just $ERRNO I cannot access - none of the others (eg $PID,
> $CHILD_ERROR) work either whereas the short versions ( $$, $? ) work
> fine.
>
> I am using Active Perl v5.6.1
I believe that you need to do the following :
use English;
------------------------------
Date: Mon, 01 Mar 2004 08:51:02 -0800
From: Yuri Shtil <yshtil@cisco.com>
Subject: Re: how die in AUTOLOAD
Message-Id: <404369F6.50702@cisco.com>
See inline.
Anno Siegel wrote:
> Yuri Shtil <yshtil@cisco.com> wrote in comp.lang.perl.misc:
>
>>Hi all
>>
>>I wrote the following code to call functions in an another package and
>>process the return value.
>>
>>I check if the computed routine exists in the target package and call
>>die if it does not. When I run this code there is no die message
>>displayed, the program exits silently.
>
>
> You are never calling anything, so AUTOLOAD is never triggered. Add
> a line "gibsnich()" somewhere, and it will die as expected.
>
I do call this from an another module. I traced it with the debugger and
with prints. The die statement gets invoked with no visible effect.
>
>>no strict;
>
>
>
> Why switch off strictures here? Only one statement requires it. Just
> declare $AUTOLOAD with "our", and everything up to then is strict-proof.
>
It is not relevant to the subject, but thank you anyway.
>
>>sub AUTOLOAD
>> {
>> my ($name, $oldsub);
>> my $sub = $oldsub = $AUTOLOAD;
>>
>> $sub =~ s/.*::_(.+)$/package::$1/;
>>
>> $name = $1;
>
>
> Never use $1 when you don't know if the pattern matched. $name may be
> empty or undefined. Well, you're not using it anyway, so why is it here?
>
>
>> if (! defined &$sub) {
>> die "cannot autoload $oldsub";
>>
>> }
>>
>> $AUTOLOAD = $sub;
>
>
> "no strict" should be here, not at file level. Ideally, put it with
> the following statement in a block by itself.
>
>
>> my $ret = &$AUTOLOAD;
>
>
> Why do you put the value into $AUTOLOAD before you call it? Just call
> "&$sub". There's no difference.
>
>
>># Process return value
>>}
>
>
> Anno
------------------------------
Date: 1 Mar 2004 17:51:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how die in AUTOLOAD
Message-Id: <c1vt6a$t0r$1@mamenchi.zrz.TU-Berlin.DE>
Yuri Shtil <yshtil@cisco.com> wrote in comp.lang.perl.misc:
> See inline.
>
> Anno Siegel wrote:
> > Yuri Shtil <yshtil@cisco.com> wrote in comp.lang.perl.misc:
> >
> >>Hi all
> >>
> >>I wrote the following code to call functions in an another package and
> >>process the return value.
> >>
> >>I check if the computed routine exists in the target package and call
> >>die if it does not. When I run this code there is no die message
> >>displayed, the program exits silently.
> >
> >
> > You are never calling anything, so AUTOLOAD is never triggered. Add
> > a line "gibsnich()" somewhere, and it will die as expected.
> >
>
> I do call this from an another module. I traced it with the debugger and
> with prints. The die statement gets invoked with no visible effect.
Then how about showing us that mystery call? The code you showed behaves
exactly as expected. So far this has been a waste of time.
> >>no strict;
> >
> > Why switch off strictures here? Only one statement requires it. Just
> > declare $AUTOLOAD with "our", and everything up to then is strict-proof.
>
> It is not relevant to the subject, but thank you anyway.
How do you know it isn't?
[rest of fullquote snipped]
Anno
------------------------------
Date: Mon, 01 Mar 2004 10:34:56 -0800
From: Yuri Shtil <yshtil@cisco.com>
Subject: Re: how die in AUTOLOAD
Message-Id: <40438250.2020500@cisco.com>
Anno Siegel wrote:
> Yuri Shtil <yshtil@cisco.com> wrote in comp.lang.perl.misc:
>
>>See inline.
>>
>>Anno Siegel wrote:
>>
>>>Yuri Shtil <yshtil@cisco.com> wrote in comp.lang.perl.misc:
>>>
>>>
>>>>Hi all
>>>>
>>>>I wrote the following code to call functions in an another package and
>>>>process the return value.
>>>>
>>>>I check if the computed routine exists in the target package and call
>>>>die if it does not. When I run this code there is no die message
>>>>displayed, the program exits silently.
>>>
>>>
>>>You are never calling anything, so AUTOLOAD is never triggered. Add
>>>a line "gibsnich()" somewhere, and it will die as expected.
>>>
>>
>>I do call this from an another module. I traced it with the debugger and
>>with prints. The die statement gets invoked with no visible effect.
>
>
> Then how about showing us that mystery call? The code you showed behaves
> exactly as expected. So far this has been a waste of time.
>
I apologize for wasting your time. It was unintentional.
You can assume it was PACKAGE::foo(bla);
Where foo was nowhere to exist.
Where PACKAGE is the package the AUTOLOAD is in.
As I said I saw the autload routine hit, but die exited silently.
>
>>>>no strict;
>>>
>>>Why switch off strictures here? Only one statement requires it. Just
>>>declare $AUTOLOAD with "our", and everything up to then is strict-proof.
>>
>>It is not relevant to the subject, but thank you anyway.
>
>
> How do you know it isn't?
Ok, I suppose you will explain why it is relevant.
>
> [rest of fullquote snipped]
>
> Anno
------------------------------
Date: 1 Mar 2004 18:56:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: how die in AUTOLOAD
Message-Id: <c2010n$t0r$4@mamenchi.zrz.TU-Berlin.DE>
Yuri Shtil <yshtil@cisco.com> wrote in comp.lang.perl.misc:
>
>
> Anno Siegel wrote:
> > Yuri Shtil <yshtil@cisco.com> wrote in comp.lang.perl.misc:
[...]
> >>I do call this from an another module. I traced it with the debugger and
> >>with prints. The die statement gets invoked with no visible effect.
> >
> > Then how about showing us that mystery call? The code you showed behaves
> > exactly as expected. So far this has been a waste of time.
>
> I apologize for wasting your time. It was unintentional.
>
> You can assume it was PACKAGE::foo(bla);
> Where foo was nowhere to exist.
Assume? I don't want assumptions, I want to see the exact code that
calls main::AUTOLOAD and doesn't die. (Your "assumption" doesn't call
main::AUTOLOAD, which was the only AUTOLOAD in your original code.)
> Where PACKAGE is the package the AUTOLOAD is in.
> As I said I saw the autload routine hit, but die exited silently.
You have been claiming this in three postings now, but never shown
code that demonstrates it. Now please show the code or shut up.
[...]
Anno
------------------------------
Date: Tue, 02 Mar 2004 00:40:54 +0800
From: Regent <arthur0421@163.com>
Subject: Re: Newbie Need help with if statement
Message-Id: <c1vp4a$og$1@mail.cn99.com>
Ed wrote:
> I need help with the if statement below. What I need instead of three if
> statements is one if and two "or" or something similar. Pseudo code would be
>
> if
> $areacode is blank or
> $exchange is blank or
> $phone is blank
> then
> $er_phone = $er_message
> $er_count = $er_count + 1
>
> T.I.A.
> Ed
> ----------------------------------------------------
>
>
> if ($areacode eq "") {
> $er_areacode = $er_message;
> $er_count = $er_count + 1
> }
> if ($exchange eq "") {
> $er_exchange = $er_message;
> $er_count = $er_count + 1
> }
> if ($phone eq "") {
> $er_phone = $er_message;
> $er_count = $er_count + 1
> }
>
>
try this:
if (! ($areacode and $exchange and $phone))
{
$er_phone = $er_message;
$er_count = $er_count + 1;
}
Regent
------------------------------
Date: Mon, 1 Mar 2004 12:09:54 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Newbie Need help with if statement
Message-Id: <20040301120834.I27834@dishwasher.cs.rpi.edu>
On Tue, 2 Mar 2004, Regent wrote:
> > if
> > $areacode is blank or
> > $exchange is blank or
> > $phone is blank
> > then
> > $er_phone = $er_message
> > $er_count = $er_count + 1
> >
> try this:
>
> if (! ($areacode and $exchange and $phone))
> {
> $er_phone = $er_message;
> $er_count = $er_count + 1;
> }
>
Please note that's not the same as what the OP asked for. This code is
simply checking to see if any of the three variables have false values
(including 0 or "0"), not necessarily that they're blank.
Paul Lalli
------------------------------
Date: Mon, 1 Mar 2004 17:54:04 -0000
From: "Kasp" <kasp@epatra.com>
Subject: Re: Newbie Need help with if statement
Message-Id: <c1vt8o$t66$1@newsreader.mailgate.org>
"Ed" <elpedro@mindspring.com> wrote in message
news:c1vjri$1nnle6$1@ID-201461.news.uni-berlin.de...
> I need help with the if statement below. What I need instead of three if
> statements is one if and two "or" or something similar. Pseudo code would
be
>
<snipped>
if ( condition_1 or condition_2 or condition3){
#do stuff
}
Read more on OR, AND etc.
------------------------------
Date: 1 Mar 2004 17:59:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Newbie Need help with if statement
Message-Id: <c1vtmn$t0r$2@mamenchi.zrz.TU-Berlin.DE>
Kasp <kasp@epatra.com> wrote in comp.lang.perl.misc:
> "Ed" <elpedro@mindspring.com> wrote in message
> news:c1vjri$1nnle6$1@ID-201461.news.uni-berlin.de...
> > I need help with the if statement below. What I need instead of three if
> > statements is one if and two "or" or something similar. Pseudo code would
> be
> >
> <snipped>
>
> if ( condition_1 or condition_2 or condition3){
> #do stuff
> }
>
> Read more on OR, AND etc.
Read about *what*?
Anno
------------------------------
Date: Mon, 01 Mar 2004 19:25:33 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Newbie Need help with if statement
Message-Id: <pan.2004.03.01.16.02.05.729363@aursand.no>
On Mon, 01 Mar 2004 08:11:46 -0700, Ed wrote:
> I need help with the if statement below. What I need instead of three if
> statements is one if and two "or" or something similar. Pseudo code
> would be
>
> if
> $areacode is blank or
> $exchange is blank or
> $phone is blank
> then
> $er_phone = $er_message
> $er_count = $er_count + 1
Why didn't you try to implement this pseudo-code? It would have worked,
most probably;
if ( $areacode eq '' or $exchange eq '' or $phone eq '' ) {
$er_phone = $er_message;
$er_count = $er_code + 1; # Can be written as $er_code++
}
--
Tore Aursand <tore@aursand.no>
"First, God created idiots. That was just for practice. Then He created
school boards." -- Mark Twain
------------------------------
Date: Tue, 02 Mar 2004 00:33:49 +0800
From: Regent <arthur0421@163.com>
Subject: Re: Opening a unique dat file for each user
Message-Id: <c1vomf$c1$1@mail.cn99.com>
ko wrote:
> Don't top-post. Look at how your post was re-arranged - it makes it
> easier for people to follow the thread...
>
> Regent wrote:
>
>> Dave Cross wrote:
>>
>>>> open (F, ">> $root/$path/$uid.dat") or die "$!\n";
>>
>>
>>> How do the variables $root, $path and $uid get set? You probably need to
>>> untaint one of those.
>>>
>>> See "perldoc perlsec" for more details.
>>>
>>> Dave...
>
> >
> > $root and $path are consants, the only variable is $uid, getting its
> > value in this way:
> >
> > use CGI qw(:standard);
> > my $q = new CGI;
> > my $uid = $q->param('uid');
> >
> > perlsec tells me that $uid is tainted; but how can I untaint it, if
> > the received value is to be used, dynamically, as part of a filename?
>
> Did you just read the whole document, specifically the section
> 'Laundering and Detecting Tainted Data'?
>
> Create a regular expression and use the subpattern(s) from the match.
> But make *sure* that you use a regex that tests for what you consider
> *valid* values. For example, you could technically do something like:
>
> # *don't* do this
> $uid = $1 if $uid =~ /(.*)/;
>
> And your program will run, assuming there aren't any other errors. But
> that defeats the purpose of using taint mode, since it matches
> everything. You need to make a *careful* decision on what values you
> feel are appropriate within the context of your application, and then
> apply the regex to $uid.
>
> > Thanks for the reply but I don't seem to get the knack...
>
> And since you're doing CGI, re-read perlsec till you do 'get the knack'.
> That should have been step one in the process...
>
> HTH - keith
Thanks really. In fact before being used as part of the filename, $uid
is validated beforehand. So
$uid = $1 if $uid =~ /(.*)/;
should be no problem. I tried this, and the script seems sound and safe.
But is there any other potential danger in doing this? I see none at the
moment now.
Regent
------------------------------
Date: Mon, 1 Mar 2004 17:29:02 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Opening a unique dat file for each user
Message-Id: <c1vrsu$2mr$1@wisteria.csv.warwick.ac.uk>
Regent <arthur0421@163.com> wrote:
[tainting, and not simply using /(.*)/]
> Thanks really. In fact before being used as part of the filename, $uid
> is validated beforehand. So
>
> $uid = $1 if $uid =~ /(.*)/;
>
> should be no problem. I tried this, and the script seems sound and safe.
> But is there any other potential danger in doing this? I see none at the
> moment now.
Whenever possible you should make your untaint regex do at least a
reasonable validation: it's *much* *much* safer. At least exclude /:
$uid = $1 if $uid =~ m:([^/]*):;
Ben
--
Razors pain you / Rivers are damp
Acids stain you / And drugs cause cramp. [Dorothy Parker]
Guns aren't lawful / Nooses give
Gas smells awful / You might as well live. ben@morrow.me.uk
------------------------------
Date: Mon, 01 Mar 2004 10:10:39 -0800
From: Greg Klinedinst <g_klinedinst@hotmail.com>
Subject: Re: Opening a unique dat file for each user
Message-Id: <hcu640dg98t6erosa3ouc9ef1pmi6rg9lg@4ax.com>
On Tue, 02 Mar 2004 00:33:49 +0800, Regent <arthur0421@163.com> wrote:
>Thanks really. In fact before being used as part of the filename, $uid
>is validated beforehand. So
>
> $uid = $1 if $uid =~ /(.*)/;
>
>should be no problem. I tried this, and the script seems sound and safe.
>But is there any other potential danger in doing this? I see none at the
>moment now.
>
>Regent
I am not sure if you mean that you were validating $uid earlier in
your Perl program or by some external means before it gets submitted
such as with Javascript running client-side. I just wanted to point
out that you should never trust data coming from the client, even if
you check it with JS or something.
Anyone familiar with web programming at all could read the source of
your front end(the HTML) and make their own version which sends back
whatever they want, and call it uid(which you are trusting). There are
even programs out there you can download which will automate this
process of hacking web forms. I have even gone to a conference where
they discussed how to hack web forms in detail.
As I said, it wasn't clear to me if you were validating that variable
in your Perl code or checking it before your Perl gets it but if it is
the latter you should check it thoroughly in your Perl anyway.
-Greg
------------------------------
Date: Mon, 01 Mar 2004 11:08:21 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: OS Version
Message-Id: <pan.2004.03.01.16.08.19.453961@remove.adelphia.net>
On Mon, 01 Mar 2004 10:04:30 -0500, Mark J Fenbers wrote:
> $^O gives the O/S name, in my case : 'linux', but I want to run my Perl script
> on RH 7.X and RH 9.x of Linux. How can my script determine which version of the
> O/S it is running on?
Why should your script care about the distro of Linux?
More importantly, why are you coding to a certain distro of Linux?
That a little like making tall kitchen garbage bags to fit only a certain
vendor's tall kitchen garbage can :-)
--
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 ...
Are you a turtle?
------------------------------
Date: Mon, 01 Mar 2004 12:14:08 -0500
From: Mark J Fenbers <Mark.Fenbers@noaa.gov>
To: jwillmore@adelphia.net
Subject: Re: OS Version
Message-Id: <40436F5F.7D9FCB93@noaa.gov>
This is a multi-part message in MIME format.
--------------9E7D2BC334C3166C9F904D19
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Well, because I have third-party software that I call from my script and that
software has to be called with different environmental settings on RH 9 than it does
for RH 7.
Mark
James Willmore wrote:
> On Mon, 01 Mar 2004 10:04:30 -0500, Mark J Fenbers wrote:
>
> > $^O gives the O/S name, in my case : 'linux', but I want to run my Perl script
> > on RH 7.X and RH 9.x of Linux. How can my script determine which version of the
> > O/S it is running on?
>
> Why should your script care about the distro of Linux?
>
> More importantly, why are you coding to a certain distro of Linux?
> That a little like making tall kitchen garbage bags to fit only a certain
> vendor's tall kitchen garbage can :-)
>
> --
> 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 ...
> Are you a turtle?
--------------9E7D2BC334C3166C9F904D19
Content-Type: text/x-vcard; charset=us-ascii;
name="Mark.Fenbers.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Mark J Fenbers
Content-Disposition: attachment;
filename="Mark.Fenbers.vcf"
begin:vcard
n:Fenbers;Mark
tel;work:937-383-0430
x-mozilla-html:TRUE
org:National Weather Service;Ohio River Forecast Center
adr:;;;;;;
version:2.1
email;internet:Mark.Fenbers@noaa.gov
title:Sr. HAS Meteorologist
fn:Mark J Fenbers
end:vcard
--------------9E7D2BC334C3166C9F904D19--
------------------------------
Date: Mon, 01 Mar 2004 19:25:33 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: OS Version
Message-Id: <pan.2004.03.01.15.45.39.792685@aursand.no>
On Mon, 01 Mar 2004 10:04:30 -0500, Mark J Fenbers wrote:
> $^O gives the O/S name, in my case : 'linux', but I want to run my Perl
> script on RH 7.X and RH 9.x of Linux.
Why? And have in mind that Red Hat is just a Linux distribution; The OS
is Linux no matter what distribution (of Linux) you're running.
--
Tore Aursand <tore@aursand.no>
"First, God created idiots. That was just for practice. Then He created
school boards." -- Mark Twain
------------------------------
Date: Mon, 01 Mar 2004 13:44:10 -0500
From: Les Peters <lpeters@aol.net>
Subject: Regex comparison
Message-Id: <4043847A.5090302@aol.net>
Hey:
I am working on a bit of code that will compare two regexen
to see if one will match a superset of the other. Trying to
take pattern-1 and transform it into a string, then try to match
it against pattern-2 is getting really hard... any better methods?
TIA,
Les
------------------------------
Date: Mon, 01 Mar 2004 19:47:12 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regex comparison
Message-Id: <c200re$1n5vd2$1@ID-184292.news.uni-berlin.de>
Les Peters wrote:
> I am working
Good.
> on a bit of code that will compare two regexen to see if one will
> match a superset of the other. Trying to take pattern-1 and
> transform it into a string, then try to match it against pattern-2
> is getting really hard...
Is it? Maybe. Why don't you show us the code you have so far, and it
will be much easier to understand how hard it is.
> any better methods?
Methods for doing what? You didn't tell us what it is you are trying
to accomplish!
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 01 Mar 2004 14:01:42 -0500
From: Les Peters <lpeters@aol.net>
Subject: Re: Regex comparison
Message-Id: <40438896.4010007@aol.net>
Gunnar Hjalmarsson wrote:
> Les Peters wrote:
>
>> I am working
>
>
> Good.
Yes, it is good.
>
>> on a bit of code that will compare two regexen to see if one will
>> match a superset of the other. Trying to take pattern-1 and
>> transform it into a string, then try to match it against pattern-2
>> is getting really hard...
>
>
> Is it? Maybe. Why don't you show us the code you have so far, and it
> will be much easier to understand how hard it is.
Ok...
sub pattern_check {
#my ($p1, $p2) = @_;
my ($p1) = @_;
# transform p1 into s1 that matches p1
my $s1;
$s1 = $p1;
print "I $p1\n";
$s1 =~ s/\\d[\+\*]?/0/g; # replace \d, \d+, \d*
$s1 =~ s/\\s[\+\*]?/ /g; # replace \s, \s+, \s*
$s1 =~ s/\\S[\+\*]?/-/g; # replace \S, \S+, \S*
$s1 =~ s/\.[\+\*]/-/g; # replace .+, .*
$s1 =~ s/\\\+/+/g; # replace \+
while ($s1 =~ /([^\\])\[(.)[^]]*?\]/) {
$s1 =~ s/([^\\])\[(.)[^]]*?\]/\1\2/; # replace character range
}
$s1 =~ s/\\\[(.)[^]]*?\\\]/\[\1\]/g; # replace bracketed character range
$s1 =~ s/\((.+?)\|.+?\)/\1/g; # replace alternation
$s1 =~ s/([^\\])[()]/\1/g;
$s1 =~ s/\\([\[\]\(\)\/\.'"])/\1/g; # replace backslashed []()/.'"
print "O $s1\n";
if ($s1 =~ /$p1/) {
print "match\n";
} else {
print "NO\n";
}
print "\n";
# attempt to match s1 with p2
# if successful, conflict
}
>
>> any better methods?
>
>
> Methods for doing what? You didn't tell us what it is you are trying
> to accomplish!
>
I am trying to properly order a series of regexen so that a general pattern
will not match all the lines of a more specific pattern, as part of a log
monitoring script.
Les
------------------------------
Date: 1 Mar 2004 08:50:42 -0800
From: aleatory@hotmail.com (aleatory)
Subject: Storing numbers in an array from files
Message-Id: <a68a4ee0.0403010850.54a6e6fa@posting.google.com>
Hi perl gurus,
I've been struggling for maniplating a line of
numbers. I'd greatly appreciate if you could
offer me some help.
A file, for instance, contains a bunch of numbers:
| 1218, 8, 29
| 3211, 9, 15
I would like to first read in a line of numbers
and then would like to uniquely store each number
in an array as:
For 1st loop
| print "$my_array[0]"; <--displays 1218
| print "$my_array[1]"; <--displays 8
| print "$my_array[2]"; <--displays 29
For 2nd loop
| print "$my_array[0]"; <--displays 3211
| print "$my_array[1]"; <--displays 9
| print "$my_array[2]"; <--displays 15
However, I've been having difficulty uniquely
storing each number in an array. The following
is my code:
| #!/usr/bin/perl
| use strict;
| use warnings;
|
| open IN, 'infile' || die$!;
|
| my @line;
| my @my_array;
|
| while ( <IN> )
| {
| @line = $_; <--@line contains 1218, 8, 29
| @my_array = @line How could I store each as:
| } $my_array[0] = 1218
| $my_array[1] = 8
| $my_array[2] = 29
Then after separating each, how could I put
them together as a line of numbers separated
by a comma?
I'm quite desperate and any information is
highly appreciated.
Many thanks in advance,
alea
------------------------------
Date: Mon, 01 Mar 2004 17:59:54 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Storing numbers in an array from files
Message-Id: <c1vqhm$1n8oe0$1@ID-184292.news.uni-berlin.de>
aleatory wrote:
> A file, for instance, contains a bunch of numbers:
>
> | 1218, 8, 29
> | 3211, 9, 15
>
> I would like to first read in a line of numbers
> and then would like to uniquely store each number
> in an array as:
>
> For 1st loop
> | print "$my_array[0]"; <--displays 1218
> | print "$my_array[1]"; <--displays 8
> | print "$my_array[2]"; <--displays 29
>
> For 2nd loop
> | print "$my_array[0]"; <--displays 3211
> | print "$my_array[1]"; <--displays 9
> | print "$my_array[2]"; <--displays 15
>
> However, I've been having difficulty uniquely
> storing each number in an array. The following
> is my code:
>
> | #!/usr/bin/perl
> | use strict;
> | use warnings;
> |
> | open IN, 'infile' || die$!;
> |
> | my @line;
> | my @my_array;
> |
> | while ( <IN> )
> | {
> | @line = $_; <--@line contains 1218, 8, 29
> | @my_array = @line How could I store each as:
> | } $my_array[0] = 1218
> | $my_array[1] = 8
> | $my_array[2] = 29
perldoc -f split;
But if you just use @my_array, only the last line will be preserved.
You'd better use an array of arrays.
perldoc perllol
perldoc perlreftut
> Then after separating each, how could I put
> them together as a line of numbers separated
> by a comma?
perldoc -f join
> I'm quite desperate and any information is
> highly appreciated.
Happy reading. :)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 1 Mar 2004 17:46:57 -0000
From: "Kasp" <kasp@epatra.com>
Subject: Suggest a suitable image modifying CPAN module
Message-Id: <c1vsrg$sod$1@newsreader.mailgate.org>
Hello,
Problem: I need a module that will put a user specified string in the bottom
right corner of an image (bmp, jpg, gif etc). Height of text will be 1/10
height of image.
I found Image::Size can help me determine the size of image. But what can I
use to super-impose a string on the image so as to achieve the desired
effect.
Thanks.
------------------------------
Date: Mon, 01 Mar 2004 16:28:06 -0000
From: "Pope Bob" <nobody@somewhere-else.com>
Subject: Re: Thanks for the advice
Message-Id: <1046p4m9t21o2ba@corp.supernews.com>
Tad McClellan <tadmc@augustmail.com> wrote:
>
>4) so people don't continue to snicker at you because you can't
> even spell the name of the language you are using.
The amount of time and energy people waste complaining about
nonsense such as this is what's laughable.
------------------------------
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 6198
***************************************