[17861] in Perl-Users-Digest
Perl-Users Digest, Issue: 21 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 9 00:25:34 2001
Date: Mon, 8 Jan 2001 21:25:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979017913-v10-i21@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 8 Jan 2001 Volume: 10 Number: 21
Today's topics:
Re: Sorting/matching trouble <jhelman@wsb.com>
Re: Sorting/matching trouble <matt.stoker@motorola.com>
Re: Sorting/matching trouble <matt.stoker@motorola.com>
Re: Sorting/matching trouble <uri@sysarch.com>
Re: Stopping users from exploiting Perl 'interpreter' o <carvdawg@patriot.net>
Re: Stopping users from exploiting Perl 'interpreter' o <harrisr@bignet.net>
Re: Stopping users from exploiting Perl 'interpreter' o (Jerome O'Neil)
sub process of perl cgi can't get filehandle speedpk@my-deja.com
Re: sub process of perl cgi can't get filehandle speedpk@my-deja.com
Re: sub process of perl cgi can't get filehandle (Jerome O'Neil)
Re: sub process of perl cgi can't get filehandle <wyzelli@yahoo.com>
Re: What do you call the => operator? (Jerome O'Neil)
Win32 Alarm equivalent - timeout system calls <dave_at_hm@hotmail.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 09 Jan 2001 03:40:27 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Sorting/matching trouble
Message-Id: <hu1l5ts16dl545b9ums1ng7913eq5dcilt@4ax.com>
On Mon, 8 Jan 2001 22:40:50 +0100, "xarbosa" <xarbosa@yahoo.com>
wrote:
>I first sort the arrays using: @array = sort(@array);
>However, when I test it the arrays are not sorted by the value (higher
>values appear under lower values ?!?)
And what did you expect to happen? This is the default sorting order
for sort(). If you want to reverse this, use:
@array = reverse sort(@array);
If this isn't what you want, then I must confess that I am confused.
A more comprehensive description of what you mean by "sort by value"
would be helpful.
JH
------------------------------
Date: Mon, 08 Jan 2001 20:42:54 -0700
From: Matthew Stoker <matt.stoker@motorola.com>
Subject: Re: Sorting/matching trouble
Message-Id: <3A5A88BE.33305B36@motorola.com>
xarbosa wrote:
>
> Please assist....
>
> I have 2 arrays containing about 15.000 filenames each.
> I first sort the arrays using: @array = sort(@array);
> I then compare both arrays based on the value of the string by doing
> something like this:
>
> if ($left lt $right) {
> do something;
> compare next $right;
> } else {
> do something else;
> compare next $left;
> }
>
> However, when I test it the arrays are not sorted by the value (higher
> values appear under lower values ?!?)
> Anybody know how to get them sorted by value (using lt and gt, not < and >).
>
> Any help is highly appreciated,
>
> Xarbosa.
I'm not really sure what you're asking or what the problem is that
you're having. You can add a code block to the sort command to have it
do the sort in any way you like. See the sample code below for a few
examples (note some text wrapping has likely occured):
#!/usr/local/bin/perl
use Data::Dumper;
@sortme =
(dog,cat,kate,dog5,dog6,dog1,dog4,dog10,dog18,dog45,dog18cat26,dog05cat3,dog5cat03,dog5cat002);
@sortme = sort @sortme; # Normal sort
print "First sort:\n";
print Dumper (@sortme);
print "\nSecond sort:\n";
@sortme = sort {$b cmp $a} @sortme; # Reverse sort
print Dumper (@sortme);
@sortme = sort # Alternate string/numeric sort
{
@a = split /(\d+)/, $a; # Split sort string into component strings
and numbers
@b = split /(\d+)/, $b; # Split sort string into component strings
and numbers
foreach $acmp (@a)
{
$bcmp = shift @b;
if ($acmp ne $bcmp) # Process components that are not equal
(otherwise get next components)
{
if ($acmp =~ /\d/ && $bcmp =~ /\d/) # If components are numeric,
do numeric compare
{
$test = $acmp <=> $bcmp;
return $test if ($test); # Return numeric compare, unless
components are equal
} else { # If components are strings,
do string compare
$test = $acmp cmp $bcmp;
return $test;
}
}
}
# If you made it this far then either $a equals $b or $a is a
substring of $b
if (shift @b) {$test = -1;} else {$test = 0;}
return $test;
}
@sortme;
print "\nThird sort:\n";
print Dumper (@sortme);
Results:
First sort:
$VAR1 = 'cat';
$VAR2 = 'dog';
$VAR3 = 'dog05cat3';
$VAR4 = 'dog1';
$VAR5 = 'dog10';
$VAR6 = 'dog18';
$VAR7 = 'dog18cat26';
$VAR8 = 'dog4';
$VAR9 = 'dog45';
$VAR10 = 'dog5';
$VAR11 = 'dog5cat002';
$VAR12 = 'dog5cat03';
$VAR13 = 'dog6';
$VAR14 = 'kate';
Second sort:
$VAR1 = 'kate';
$VAR2 = 'dog6';
$VAR3 = 'dog5cat03';
$VAR4 = 'dog5cat002';
$VAR5 = 'dog5';
$VAR6 = 'dog45';
$VAR7 = 'dog4';
$VAR8 = 'dog18cat26';
$VAR9 = 'dog18';
$VAR10 = 'dog10';
$VAR11 = 'dog1';
$VAR12 = 'dog05cat3';
$VAR13 = 'dog';
$VAR14 = 'cat';
Third sort:
$VAR1 = 'cat';
$VAR2 = 'dog';
$VAR3 = 'dog1';
$VAR4 = 'dog4';
$VAR5 = 'dog5';
$VAR6 = 'dog5cat002';
$VAR7 = 'dog5cat03';
$VAR8 = 'dog05cat3';
$VAR9 = 'dog6';
$VAR10 = 'dog10';
$VAR11 = 'dog18';
$VAR12 = 'dog18cat26';
$VAR13 = 'dog45';
$VAR14 = 'kate';
--
/------------------------------------------------------------------\
| Matt Stoker | email: matt.stoker@motorola.com |
| Unit Process Modeling | Mail Drop: M360 |
| DigitalDNA(TM) Laboratories| Phone: (480)655-3301 |
| Motorola, SPS | Fax: (480)655-5013 |
| 2200 W Broadway Road | Pager: (888)699-8803 |
| Mesa, AZ 85202 | |
\------------------------------------------------------------------/
------------------------------
Date: Mon, 08 Jan 2001 20:52:13 -0700
From: Matthew Stoker <matt.stoker@motorola.com>
Subject: Re: Sorting/matching trouble
Message-Id: <3A5A8AED.A938856E@motorola.com>
Sorry to reply to my own post, but if anyone can find an example that
"breaks" the third "numeric/string" sort or has a better coding of this,
please post it. If you can't tell, it is supposed to do a string sort
on the string components and a numeric sort on the numeric components.
(eg. dog05 == dog5, dog6 < dog10...)
Thanks!
Matthew Stoker wrote:
>
> xarbosa wrote:
> >
> > Please assist....
> >
> > I have 2 arrays containing about 15.000 filenames each.
> > I first sort the arrays using: @array = sort(@array);
> > I then compare both arrays based on the value of the string by doing
> > something like this:
> >
> > if ($left lt $right) {
> > do something;
> > compare next $right;
> > } else {
> > do something else;
> > compare next $left;
> > }
> >
> > However, when I test it the arrays are not sorted by the value (higher
> > values appear under lower values ?!?)
> > Anybody know how to get them sorted by value (using lt and gt, not < and >).
> >
> > Any help is highly appreciated,
> >
> > Xarbosa.
>
> I'm not really sure what you're asking or what the problem is that
> you're having. You can add a code block to the sort command to have it
> do the sort in any way you like. See the sample code below for a few
> examples (note some text wrapping has likely occured):
>
> #!/usr/local/bin/perl
> use Data::Dumper;
>
> @sortme =
> (dog,cat,kate,dog5,dog6,dog1,dog4,dog10,dog18,dog45,dog18cat26,dog05cat3,dog5cat03,dog5cat002);
>
> @sortme = sort @sortme; # Normal sort
> print "First sort:\n";
> print Dumper (@sortme);
>
> print "\nSecond sort:\n";
>
> @sortme = sort {$b cmp $a} @sortme; # Reverse sort
> print Dumper (@sortme);
>
> @sortme = sort # Alternate string/numeric sort
>
> {
> @a = split /(\d+)/, $a; # Split sort string into component strings
> and numbers
> @b = split /(\d+)/, $b; # Split sort string into component strings
> and numbers
> foreach $acmp (@a)
> {
> $bcmp = shift @b;
> if ($acmp ne $bcmp) # Process components that are not equal
> (otherwise get next components)
> {
> if ($acmp =~ /\d/ && $bcmp =~ /\d/) # If components are numeric,
> do numeric compare
> {
> $test = $acmp <=> $bcmp;
> return $test if ($test); # Return numeric compare, unless
> components are equal
> } else { # If components are strings,
> do string compare
> $test = $acmp cmp $bcmp;
> return $test;
> }
> }
> }
>
> # If you made it this far then either $a equals $b or $a is a
> substring of $b
> if (shift @b) {$test = -1;} else {$test = 0;}
> return $test;
> }
>
> @sortme;
>
> print "\nThird sort:\n";
> print Dumper (@sortme);
>
> Results:
>
> First sort:
> $VAR1 = 'cat';
> $VAR2 = 'dog';
> $VAR3 = 'dog05cat3';
> $VAR4 = 'dog1';
> $VAR5 = 'dog10';
> $VAR6 = 'dog18';
> $VAR7 = 'dog18cat26';
> $VAR8 = 'dog4';
> $VAR9 = 'dog45';
> $VAR10 = 'dog5';
> $VAR11 = 'dog5cat002';
> $VAR12 = 'dog5cat03';
> $VAR13 = 'dog6';
> $VAR14 = 'kate';
>
> Second sort:
> $VAR1 = 'kate';
> $VAR2 = 'dog6';
> $VAR3 = 'dog5cat03';
> $VAR4 = 'dog5cat002';
> $VAR5 = 'dog5';
> $VAR6 = 'dog45';
> $VAR7 = 'dog4';
> $VAR8 = 'dog18cat26';
> $VAR9 = 'dog18';
> $VAR10 = 'dog10';
> $VAR11 = 'dog1';
> $VAR12 = 'dog05cat3';
> $VAR13 = 'dog';
> $VAR14 = 'cat';
>
> Third sort:
> $VAR1 = 'cat';
> $VAR2 = 'dog';
> $VAR3 = 'dog1';
> $VAR4 = 'dog4';
> $VAR5 = 'dog5';
> $VAR6 = 'dog5cat002';
> $VAR7 = 'dog5cat03';
> $VAR8 = 'dog05cat3';
> $VAR9 = 'dog6';
> $VAR10 = 'dog10';
> $VAR11 = 'dog18';
> $VAR12 = 'dog18cat26';
> $VAR13 = 'dog45';
> $VAR14 = 'kate';
>
--
/------------------------------------------------------------------\
| Matt Stoker | email: matt.stoker@motorola.com |
| Unit Process Modeling | Mail Drop: M360 |
| DigitalDNA(TM) Laboratories| Phone: (480)655-3301 |
| Motorola, SPS | Fax: (480)655-5013 |
| 2200 W Broadway Road | Pager: (888)699-8803 |
| Mesa, AZ 85202 | |
\------------------------------------------------------------------/
------------------------------
Date: Tue, 09 Jan 2001 04:48:49 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Sorting/matching trouble
Message-Id: <x7zoh15o0e.fsf@home.sysarch.com>
>>>>> "MS" == Matthew Stoker <matt.stoker@motorola.com> writes:
MS> Sorry to reply to my own post, but if anyone can find an example that
MS> "breaks" the third "numeric/string" sort or has a better coding of this,
MS> please post it. If you can't tell, it is supposed to do a string sort
MS> on the string components and a numeric sort on the numeric components.
MS> (eg. dog05 == dog5, dog6 < dog10...)
use either the ST or the GRT to both speed up the code and simplify
it. anytime i see a long sort sub, i get the willies. learn to factor
out that code which gets run N log N times and only run it N times.
see http://www.sysarch.com/perl/sort_paper.html
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 08 Jan 2001 18:19:53 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: Stopping users from exploiting Perl 'interpreter' on NT
Message-Id: <3A5A4B19.47594DF8@patriot.net>
Clyde,
Your engineers evidently have very little understanding of NT.
IF your users do not have admin access to the local workstations, then you can
easily
deny all access to the Perl directory (to include the Perl.exe file itself) to
the users themselves.
After all, NTFS provides you with this capability.
One question, though...if you don't want the users to create their own working
Perl scripts,
then why have you got the Perl interpreter installed on the NT workstations?
Clyde Ingram wrote:
> On my project we use lots of Perl on Solaris servers.
> We have recently replaced Solaris client workstations with NT PCs for our
> customer's system users.
>
> Now some engineers are getting nervous at the threat of 'smart' NT users
> developing their own rogue Perl programs to tamper with the network, because
> they can easily access RPC, socket, and other facilities in the Perl on
> their PCs. (All so easy to run Notepad, and set executable permissions on a
> home-grown script.)
>
> Can anyone suggest how to prevent NT users from producing their own working
> Perl programs?
>
> Should we remove Socket.pm and other networking modules, or ultimately the
> whole of Perl's interpretative capability?
> And replace Perl sources on the NT platforms with compiled code (from a
> Perl-to-C generator)?
>
> Is this indeed the only safe solution?
> A lot of folks round here get twitchy at supplying any interpreter on the
> platform users have. (Imagine their nervousness when users had Solaris on
> the desktop, equipped with sh, ksh, csh, awk, sed, perl, . . . )
>
> Some Philistines would like to see Perl boxed-up, chucked out, and replaced
> with Java.
>
> Regards,
> Clyde
--
Q: Why is Batman better than Bill Gates?
A: Batman was able to beat the Penguin.
------------------------------
Date: Mon, 8 Jan 2001 19:35:26 -0500
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: Stopping users from exploiting Perl 'interpreter' on NT
Message-Id: <t5kn5atkbd3i67@corp.supernews.com>
Clyde Ingram <clyde@NOSPAMgetofftheline.freeserve.co.uk> wrote in
message news:93cda3$ccu$1@newsg1.svr.pol.co.uk...
> On my project we use lots of Perl on Solaris servers.
> We have recently replaced Solaris client workstations with NT PCs for
our
> customer's system users.
>
> Now some engineers are getting nervous at the threat of 'smart' NT
users
> developing their own rogue Perl programs to tamper with the network,
because
> they can easily access RPC, socket, and other facilities in the Perl
on
> their PCs. (All so easy to run Notepad, and set executable
permissions on a
> home-grown script.)
>
> Can anyone suggest how to prevent NT users from producing their own
working
> Perl programs?
As Abigail has pointed out, this is neither and NT nor a Perl issue.
The only way that you could stop users from writing and executing a Perl
script, whether on Unix or NT, is by denying them access to the system.
If they can log in and have access to the network for download, a CAROM
or a floppy, they can put Perl in their own directory. They don't need
to use your copy of it. Perl does not need to be installed in order to
be used, either on NT or Unix. You are addressing security from the
wrong end.
Randy Harris
------------------------------
Date: Tue, 09 Jan 2001 01:05:12 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Stopping users from exploiting Perl 'interpreter' on NT
Message-Id: <ctt66.1043$NN3.369700@news.uswest.net>
"Clyde Ingram" <clyde@NOSPAMgetofftheline.freeserve.co.uk> elucidates:
> Can anyone suggest how to prevent NT users from producing their own working
> Perl programs?
Yes. You write policy that says "Thou shalt not ... " and if they do,
you fire them.
I'm unsure as to why you would hire someone you don't trust in the
first place, but I guess thats your issue.
--
If men could learn from history, what lessons it might teach us! But
passion and party blind our eyes, and the light which experience gives
is a lantern on the stern, which shines only on the waves behind us.
--Samuel Taylor Coleridge, "Recollections"
------------------------------
Date: Tue, 09 Jan 2001 00:51:19 GMT
From: speedpk@my-deja.com
Subject: sub process of perl cgi can't get filehandle
Message-Id: <93dna5$ki1$1@nnrp1.deja.com>
Hello I'm having a little poblem with a Cgi which i'm in need of.
There is one Script which is called by a Web-Server. This Script is
doing some work but is also calling another Script with some
parameters. The other Script (which is a Delphi executable) is sending
back some Information. And is also supposed to write a file.
It will always fail to write this file (the permission set to the
directory should not be the problem). Where is the problem? The exe
works if it is called by hand or directly from the webserver.
I'm using ActiveState Perl 5.44 based on perl Version 5.005.
Does anybody have an idea or has been run into the same problem ?
Thanks in Advance
Greetings from Germany
Arne
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 09 Jan 2001 00:59:51 GMT
From: speedpk@my-deja.com
Subject: Re: sub process of perl cgi can't get filehandle
Message-Id: <93dnq4$ko8$1@nnrp1.deja.com>
In article <93dna5$ki1$1@nnrp1.deja.com>,
speedpk@my-deja.com wrote:
> Hello I'm having a little poblem with a Cgi which i'm in need of.
> There is one Script which is called by a Web-Server. This Script is
.....
sorry, i forgot to say that I'm using perl under Winnt 4.0 and Apache
Web Server.
Arne
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 09 Jan 2001 01:10:19 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: sub process of perl cgi can't get filehandle
Message-Id: <%xt66.1108$NN3.373399@news.uswest.net>
speedpk@my-deja.com elucidates:
> Hello I'm having a little poblem with a Cgi which i'm in need of.
> There is one Script which is called by a Web-Server. This Script is
> doing some work but is also calling another Script with some
> parameters. The other Script (which is a Delphi executable) is sending
> back some Information. And is also supposed to write a file.
> It will always fail to write this file (the permission set to the
> directory should not be the problem). Where is the problem?
It is on line 17.
HTH!
--
If men could learn from history, what lessons it might teach us! But
passion and party blind our eyes, and the light which experience gives
is a lantern on the stern, which shines only on the waves behind us.
--Samuel Taylor Coleridge, "Recollections"
------------------------------
Date: Tue, 9 Jan 2001 11:10:13 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: sub process of perl cgi can't get filehandle
Message-Id: <NRt66.14$ar3.4299@vic.nntp.telstra.net>
<speedpk@my-deja.com> wrote in message
news:93dnq4$ko8$1@nnrp1.deja.com...
> In article <93dna5$ki1$1@nnrp1.deja.com>,
> speedpk@my-deja.com wrote:
> > Hello I'm having a little poblem with a Cgi which i'm in need of.
> > There is one Script which is called by a Web-Server. This Script is
> .....
>
> sorry, i forgot to say that I'm using perl under Winnt 4.0 and Apache
> Web Server.
>
Wild Guess....
The user the cgi process is operating as is not the same as the user
when 'calling by hand' and therefore the permissions aren't what you
think they are.
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_!=1)? 's':'';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: Tue, 09 Jan 2001 00:53:58 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: What do you call the => operator?
Message-Id: <Git66.893$NN3.361505@news.uswest.net>
ben-fuzzybear@geocities.com (Ben Okopnik) elucidates:
> She proceeds to refer to it as 'the digraph symbol' further on in the
> book. ACK! A perfect example of just reading the documentation (perlop)
> without understanding it...
>
> Does anyone know the actual name for this thing, though? _Is_ there one?
I call it a "fat comma," although I think it's real name is Earl.
--
If men could learn from history, what lessons it might teach us! But
passion and party blind our eyes, and the light which experience gives
is a lantern on the stern, which shines only on the waves behind us.
--Samuel Taylor Coleridge, "Recollections"
------------------------------
Date: Mon, 08 Jan 2001 20:39:44 -0800
From: Dave E <dave_at_hm@hotmail.com>
Subject: Win32 Alarm equivalent - timeout system calls
Message-Id: <3A5A9610.5FAFE398@hotmail.com>
Hi,
Is there a Win32 strategy for timing out system calls? The perldocs
etc. all use alarm() and this makes perfect sense -- except it won't
work on NT.
I've spent the last 5 hours in documentation hell -- I've learned a lot
but not what I need. My last attempt was with Win32::Process but I
can't get the output of the external command into my code.
There must be a way to timeout code segments, including external calls,
on Win32 boxes -- isn't there?
Any clues appreciated; A code snip would be muchly appreciated :)
David...
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 21
*************************************