[18733] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 901 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 14 21:11:37 2001

Date: Mon, 14 May 2001 18:10:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <989889011-v10-i901@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 14 May 2001     Volume: 10 Number: 901

Today's topics:
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (John Stanley)
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (John Stanley)
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <flavell@mail.cern.ch>
    Re: Probably a simple question... <Ask@For-It.Com>
    Re: Probably a simple question... <flavell@mail.cern.ch>
    Re: Probably a simple question... <jfreeman@tassie.net.au>
        Problem writing to a socket after forking <rdoerr@planetkc.com>
    Re: Question <andras@mortgagestats.com>
    Re: Question (Steve)
    Re: Sorting a variable <ren@tivoli.com>
    Re: Sorting a variable <pswordkirk@msn.com>
    Re: Taint <dodger@necrosoft.net>
    Re: Taint (Damian James)
    Re: Taint (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 14 May 2001 23:28:12 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <9dppmc$j5l$1@news.orst.edu>

In article <iVFK6.2110$%L5.38854@insync>,  <tadmc@augustmail.com> wrote:
>[ Editor's note:
>  We are _still_ not ready to have the autoposting done from dfw.pm.org,

Autoposting? Is this supposed to be a regular thing?

Amost all of this is very good advice. I've only got a problem with the
imperatives that are being used.

>Outline
>   Before posting to comp.lang.perl.misc
>      Must

"Must" is an inappropriate word for a guideline and a document like this.
"Musts" are rules, and this is an unmoderated USENET group.

>Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
>    The comp.lang.perl.misc (clpmisc) Usenet newsgroup is for the discussion
>    of using the Perl programming language.

Ok. 

>    Do *NOT* send email to the maintainer of these guidelines. It will be
>    discarded unread. The guidelines belong to the newsgroup so all
>    discussion should appear in the newsgroup. 

Umm, if the group is for discussing perl, then discussing this document
is off topic, even according to this document. 

>        Checking the FAQ before posting is required in Big 8 newsgroups in
>        general, 

There is not a group I know of that makes this a requirement. It is
highly recommended, but not required. It's hard to have requirements
when there is nobody in charge of the group to enforce them.

>        You are expected to do this in nearly all newsgroups.

Yes. Different than required. 

>  Really Really Should
>
>    This section describes things that you *really should* do before posting
>    to clpmisc.

Move all the Must stuff here and you will be fine.

>        There are tens of thousands of Perl programmers. It is very likely
>        that your question has already been asked (and answered). See if you
>        can find where it has already been answered.
>
>        One such searchable archive is
>        <URL:http://www.deja.com/home_ps.shtml>.

I believe that deja has gone away. Google is now the archive-de-jour.

>    Carefully choose the contents of your Subject header
>        You have 40 precious characters of Subject to win out and be one of

You might say "Most newsreaders show only 40 characters of your
Subject, so you should take care ..." By RFC standards, you have 998
characters, give or take a handful, and I'm not even sure that you cannot
fold to get longer lines.

>    Use an effective followup style
>        When composing a followup, quote only enough text to establish the
>        context for the comments that you will add. Always indicate who
>        wrote the quoted material. Never quote an entire article. Never
>        quote a .signature (unless that is what you are commenting on).

"Be careful when commenting on a signature, since it is a signature and
not the topic of the article you are replying to."



------------------------------

Date: 14 May 2001 23:49:51 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <9dpquv$k3j$1@news.orst.edu>

In article <slrn9fqnjt.26h.tadmc@tadmc26.august.net>,
Tad McClellan <tadmc@augustmail.com> wrote:
>This is *not* what _I_ am doing. I am just the guy who is writing it down.

ALL FAQs are the doing of the person who writes them. 

>>> Outline
>>>    Before posting to comp.lang.perl.misc
>>>       Must
>>
>>Should.
>
>I cannot make the change you suggest.

Why not? You are wrong to say "must", so why can you not correct it?

I'll make the point by asking a question: which perl .pod did you read
prior to saying you cannot make the change? If you must read .pod prior
to posting, but did not, then the "must" is questionable.

>"Should" implies that it is OK to post without checking the docs.

It is. It is not OK to post questions without checking the docs, but
you did not limit your statement to "posting questions", and there is
nobody here to make this a must in any case. There is a difference
between "not ok" and "must not". The best you can say is "should".

I think there is an example of walking on the grass being tossed about.
In some places, it is not ok to walk on the grass. Those places happen to
belong to someone who has control over them and can stop you. But even
so, it is not prohibited to walk on the grass under every circumstance.
If you see someone having a heart attack in the middle of the grassy
area, are you not permitted to go render first aid to them? Likewise,
if you already know the answer to a question, are you not permitted to
post the answer without reading the FAQ or documentation?

>>If you start off on a bossy tone 
>
>I'm open to suggestions of less offensive wording. Let's have them...

"Should". "Are expected to...". You already word it this way in some of
the document.

>I do not want to alienate the audience, of course.
>
>I also do not want to misinform them.

Then do not tell the "must" when there is nobody to enforce the "must".
Tell them "it's a really good idea" and "it is expected", which it the
truth. Tell them that they may get yelled at for not doing it. Other than
that, there's no enforcement, thus no "must". 

>But these aren't my guidelines, 

Yes. They clearly represent your opinion, to the point that you imply
that if the opinion expressed is not the same as yours, you will leave
the group.  "it will have to be maintained by a participant in the
group", as I recall, is how you said it.

I have no problem maintaining the FAQ, if you feel you cannot. I've the
code in place to post it regularly, including supercession, and to make
it available on the web.

>Let me take this opportunity to repeat what has become a bit of
>a mantra with me of late:
>
>  deja/google sucks!

Yes, it does. Unfortunately, my "archive" is guaranteed for just a week,
even though I don't clean it out more than once a month usually, so I
will not offer it for general use.




------------------------------

Date: Tue, 15 May 2001 01:54:22 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <Pine.LNX.4.30.0105150146150.25587-100000@lxplus003.cern.ch>

On 14 May 2001, John Stanley wrote:

> >        Checking the FAQ before posting is required in Big 8 newsgroups in
> >        general,
>
> There is not a group I know of that makes this a requirement. It is
> highly recommended, but not required.

It is considered to be non-optional.  As such, it is a "requirement",
as much as anything can be a requirement when there are no formal
sanctions.  I don't see anything wrong with terming it as "required"
for anyone who understands the context.

> It's hard to have requirements
> when there is nobody in charge of the group to enforce them.

Quite.  So your argument is based on terminology.

> >        You are expected to do this in nearly all newsgroups.
>
> Yes. Different than required.

As you yourself just in effect pointed out, what meaning could
"required" have other than "considered by informed opinion to be
non-optional", in a community where there are no formal sanctions?




------------------------------

Date: Mon, 14 May 2001 23:28:37 +0100
From: "Robb Meade" <Ask@For-It.Com>
Subject: Re: Probably a simple question...
Message-Id: <9dpm3g$c64$1@newsg1.svr.pol.co.uk>

"Randal L. Schwartz" pointed out my poor Netiquette when he wrote...

> Well, you could start by reading the appropriate parts of "perldoc URI"
> and "perldoc HTML::Entities" and then asking questions based on what
> you still have left that you are pondering.

Where does one find this perldoc?  I dont use Perl locally (although I think
its on a CD that came with my Perl book somewhere)...

As I said, I dont really 'use' it - just have a small email script running
in it, primarily because my hosts server is running linux, and you dont get
CDONTS with that :(  so I had to find another way to send email - hence
sendmail..

> And you should also learn to put your post at the bottom of what's
> quoted, and trim your quotes.  It's annoying as hell to keep reading
> all these upside down posts.

Relevent point - I appologise..was a very 'quick' reply...sorry...
--

Robb Meade

Kingswood Web Services
www.kingswoodweb.net





------------------------------

Date: Tue, 15 May 2001 00:40:06 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Probably a simple question...
Message-Id: <Pine.LNX.4.30.0105150033460.29989-100000@lxplus003.cern.ch>


I suppose I'd have to make the routine protest about the Subject line.

On Mon, 14 May 2001, Robb Meade wrote:

> Where does one find this perldoc?

It's part of every complete Perl installation.

> I dont use Perl locally

Then that's the solution to your problem.  As long as you labour with
one hand tied behind your back, I think you'll find relatively little
sympathy from the denizens of this group[1].  If you have a computer,
use it.  If you haven't, they'll want to know how you hope to make
progress...

Seriously: it's the right way to move forward.  Don't take it
personally - it really is.

[1]in fact if you _do_ find sympathy in such circumstances - BEWARE!



------------------------------

Date: Tue, 15 May 2001 09:23:12 +1000
From: James freeman <jfreeman@tassie.net.au>
Subject: Re: Probably a simple question...
Message-Id: <3B0068E0.DEFFF7B@tassie.net.au>



Robb Meade wrote:

> Hi all,
>
> I have little to no knowledge of Perl, but I have managed, with a little
> help from this NG a few weeks back to get together just a little bit of code
> for a mailing list system...
>
> My only problem I have now is trying to build up a link within the code...
>
> This is the line I have... :
>
> my $link="www.kingswoodweb.net/boomshankers/mailing-sub.asp" & "?" & "name="
> & $name & "&" & "surname=" & $surname & "&" & "email=" & $to;
>
> so, when I put that in the main body of the email when it arrives in my
> inbox it should read something like :
>
> www.kingswoodweb.net/boomshankers/mailing-sub.asp?name=Robb&surname=Meade&em
> ail=webmaster@kingswoodweb.net
>
> Unfortunately - it isnt working...
>
> Everything else is - but the $link is just blank in my emails?
>
> Does the something & something & something not work in Perl as it does in
> ASP??
>

First the '&' operator is the Perl 'bitwise and' operator. The '.' operator is
the string joining operator. So if you change your & operators to . operators
you will get what you expected. Unfortunately getting what you expected still
will not work! (see below)

Although changing & to . will work you clearly do not understand that you can
include a variable inside double quotes and it will interpolate. Interpolate
means that Perl will see the variable in the string and go "ah hah the
programmer wants me to substitute the name of the variable with its value".
Double quotes " interpolate wherease single quotes ' do not. For full details
see:

perlop Quote & Quote-like Operators

Here is an example to run.

#!/usr/bin/perl

$name= 'James';
$surname= 'Freeman';
$to='jfreeman@tassie.net.au';

$link = "www.kingswoodweb.net/boomshankers/mailing-sub.asp" . "?" . "name=" .
$name . "&" . "surname=" . $surname . "&" . "email=" . $to;
print "$link\n";

$link=
'www.kingswoodweb.net/boomshankers/mailing-sub.asp?name=$name&surname=$surname&email=$to';

print "$link\n";

$link =
"www.kingswoodweb.net/boomshankers/mailing-sub.asp?name=$name&surname=$surname&email=$to";

print "$link\n";

**Note we use interpolation of the \n to print a newline after $link
(interpolated too).



Second. The part after the ? is the query string and needs to be hex encoded to
work. Well bits of it do actually, although you could hex encode the lot. In
browser-land and the HTTP protocol certain characters have special significance.
You need to hex encode these characters to avoid unexpected and unwanted
results. There are quite a few chars that need encoding like @ ? & % and
whitespace. In your example the @ must be encoded. NB: You don't need worry what
these characters are unless you really want to, just use the following example
as a guide to how to encode your query strings.

This is an edited real life example that generates the text of an HTML link to
automatically pass a cgi script a name, email and unsubscribe request. This is
how I generate a click on this link to be unsubscribed link for the bottom of
ezines (opt in only and the link really does unsubscribe you!!!). To be
especially nice I have substituted your details into it.

I have also added the http:// bit which forgot in your string but should not if
you want it to work for everyone, be standards compliant, remind you that this
is the Hyper Text Transport Protocol....

my $scriptname = "mailing-sub.asp";
my $http_script_path = "http://www.kingswoodweb.net/boomshankers";

# make the query string up
my $link = "name=$name&surname=$surname&email=$to";

# encode the query string
$link =~ s/([^a-zA-Z0-9_.!~*'() -=&])/sprintf "%%%02X", ord($1)/eg;
$link =~ tr/ /+/;

# complete the link, note we have avioded accidentally encoding the
# ? by adding it now. if you include the ? in the query string created # above
it will get encoded => broken
$link = "$http_script_path/$scriptname?$link";

Hope this helps.

James

--
################################################################
#                                                              #
#        A Thought on Perl Poetry and the Immortal JAPH        #
#                                                              #
#  I, require strict* and do not require warnings*. My answer  #
#  equals reference you unless answer equals 42. Question: If  #
#  defined, by this paradigm, do you do, the hacker foo?  Now  #
#  join the data (why Fs & Os?), so the space or newline goes  #
#  Character evaluate: Reverse split null, then for each foo:  #
#  You ate foo, but I ate two. Answer -> Join with null, sort  #
#  the spots, and print it join the dots. Go now and exit, do  #
#  not die, else go to question and answer why? JAPH! (c)JADF  #
#                                                              #
################################################################

I, require strict and do(not require warnings); my $answer = \$u
unless $answer == '42'; Question: if(defined by this_paradigm do
you_do_the_hacker_foo(??)){sub AUTOLOAD{$_=$now=join'the',<DATA>
;y?FO?01?; s.o|the| |\n..goe;s/(.{7})/(chr(eval'($u,$ate)=(0,1);
foreach $foo(reverse split "",$1){$u+=$ate*$foo;$but_I=$ate*=2;}
$$answer'))/eg;$_= join'',sort/(..)/g and print join'',/.(.)/go;
$now and exit, do(not die)}}else{goto Question and $answer;y???}
 __DATA__

OOFFOOOOOFOO      OFOO       OOFFFOOOFFO    FOOO    FFOO    OFFO
FFFOOFOOOFOF    OFFFFOOF     OFFFOOFOOOOO   OFOO    FOFO    FFFF
    FOOO      FOOF    OOFO   FOOO    OFOF   OOOO    FFOF    OOOF
    OFOF      OOFO    FFFO   OFFF    OOOO   OFFO    OOOF    FFFO
    OFFO      FOFOOOFFOFFO   FFFFFOOOFOFF   OOFFFFOOOFFO    FFOO
    OFOF      FOOFFOFOFOFF   FFFOOFFOOFO    FFFFFOOOOFOF    OOOF
    FFOO      OOOF    FFOO   OFOO           FFOO    OFFF    FOOO
FF  OFOO      FOOO    OOOF   FOFO           OOFO    OFFO
OOFFOFOO      FFFO    FOOO   FOFO           OOFO    FFOO    OOFO
 FFOOOF       OOOO    OFFO   FOOO           OOFF    OFOF    FFFO




------------------------------

Date: Mon, 14 May 2001 17:40:45 -0500
From: "Ray Doerr" <rdoerr@planetkc.com>
Subject: Problem writing to a socket after forking
Message-Id: <tg0nq04kh32keb@corp.supernews.com>

I am having a problem writing to a socket after I have forked on a Windows
2000 machine.  I have the forking part working perfectly.  The problem is
once I send on the socket, it is never sent out the ethernet port until the
send function is called two or three times.  After the second or third call
to send, I finally see the first packet that was send and sometimes the
second as well.  It appears to be a problem with the autoflush buffer with
module IO:Socket, but since version 1.18 the autoflush buffer is enabled by
default.  Below is my test script that can be used to recreate this problem.
If you send it any data on UDP Port 1813, it will echo the packet back to
the sender.  The interesting thing here is if the number of Worker Threads
is reduced to 1 with the for loop, it works fine.  Another problem I have is
with the creation of the Worker Threads, if the sleep in the Work Thread
function is commented out, only the first Thread is created, but with a 1
second sleep, everything works fine.  Any help would be greatly appreicated
as I have been pulling my hair out for 1 week now.  Here is the code:

Thanks Ray Doerr


require 5.005;
use strict;
use IO::Socket;
use IO::Handle;

# Default some variables
my ($datagram, $socket) = "";

#-- Open a socket
$socket = IO::Socket::INET->new(LocalPort => '1813',
                                Proto     => "udp")
       or die "Can't open UDP Port: $@\n";

my ($tid) = "";
my ($thread_count) = 0;

print "Parent Thread ID = $$\n";

# Create 5 Worker Threads
for (my $i=1; $i<=5; $i++) {
 if (defined($tid = CreateThread(\&WorkerThread))) {
  print "Count = $i, Thread ID = $tid\n";
  $thread_count++;
 } else {
  print "Count = $i, *** Failed to Create Thread ***\n";
 }
 #sleep 1;     # Small delay between  Thread Creation, but not required.
}

print "A total of $thread_count Worker Threads are now running\n";

# Catch any error from the Threads
while ($thread_count) {
 # Wait if any Thread die.
 $tid = wait();    # Wait for Exit Status Code ($?) from child.
        # A Code of 0 indicates that the child exited normally
 $thread_count--;
 print "Thread ID = $tid Ended, Exit Status Code = $?, $thread_count
remaining\n";
}
print "Program has Terminated!\n";
exit;

sub WorkerThread {
 my ($datagram) = "";

 $| = 1;  # This force Perl to flush the output buffers after every Print or
Write operation, STDOUT

 sleep 1;  # If this sleep is not present only the first Worker Thread is
created.
 print "Worker Thread $$ is now ready to accept Packets\n";

 eval {
  while ($socket->recv($datagram, 1024)) {
   print "Thread=$$, Received datagram from IP=" . $socket->peerhost() . ",
Port=" . $socket->peerport() .
    ", Length=".length($datagram)."\n";

   # Send a Response back to the Client.
   if (my $sent = $socket->send($datagram)) {
    print "$sent bytes Sent OK\n";
   } else {
    print "Failed sending Response";
   }
  }
 };
 print "Unknown error occured in Thread $$: $@, $!\n";
 sleep 5;
}

sub CreateThread {
 my ($subroutine) = @_;
 my ($pid) = fork();
 if (defined($pid)) {
  if( $pid == 0 ) {
   # If $pid = 0, then this is the Child Thread.  $$ is the pseudo-process
ID
   $| = 1;  # This enables the autoflush buffer, if it's not
     # there, you won't see the output from the Thread!
   &$subroutine;
   exit();
  }
 }
 # This function will now return with the Thread ID or return UNDEFINED
 # if Creation of the Thread Failed.
 return $pid;
}














------------------------------

Date: Mon, 14 May 2001 18:05:36 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Question
Message-Id: <3B0056B0.A3A62D4F@mortgagestats.com>



"Methods, Verification [SKY:1G20:EXCH]" wrote:
> 
> Hello Perl Wizzards!
> 
> I have a quick question. I wrote a small script which scans through a
> file (*.txt), searching for a specific line; upon finding it, the script
> parses the line and pastes it into another file, and it keeps on doing
> this until all desired lines are found. Beginner stuff - I'm a newbie.
> 
> Now, my question to you is, how can I get the same script to search for
> two, or three, or four...etc different lines simultanously, and paste to
> the same file. Also, how can I get the script to perform the above
> operations, on more than one source file. ie. How can it access all
> files in a directory, perform the search/parse operations, and terminate
> upon searching through the last file.
> 
> Well, that was two questions, but any help would be greatly appreciated.
> Thanks a lot in advance.

Why don't you start by posting your code; that way we can tell you what
to change to get your desired result.


------------------------------

Date: 14 May 2001 23:16:16 GMT
From: steve@zeropps.uklinux.net (Steve)
Subject: Re: Question
Message-Id: <slrn9g0pnp.ct0.steve@zero-pps.localdomain>

On Mon, 14 May 2001 16:47:02 -0400, Methods, Verification [SKY:1G20:EXCH] wrote:
>Hello Perl Wizzards!
>

Not a very helpful subject line, and I'm not a wizard. 

>Now, my question to you is, how can I get the same script to search for
>two, or three, or four...etc different lines simultanously, 

Two approaches spring to mind, first inside your while loop that reads
the lines of the files have a foreach loop like so:

my @patterns = ('Liverpool','Manchester','Leyland','Bolton');

while(<OPENFILE>) 
  {
   my $Line = $_;
   foreach $Pattern (@patterns)
     {
      if($Line =~ /$Pattern/)
        {
         Write some stuff to file etc....
        }
     } ## End of foreach.
  } ## End of while loop.

Or you could have the foreach loop on the outside and the 
while loop on the inside depending how you want to group your output.

>the same file. Also, how can I get the script to perform the above
>operations, on more than one source file. ie. How can it access all
>files in a directory, perform the search/parse operations, and terminate
>upon searching through the last file.

It's called file globbing (sp?). 

my $filename; 

while(defined($filename = glob("*.txt"))) 
  {
   open(TEXTFILE, "$filename") || die "Can't open $filename: $!";
   
     Some more code......

   close(TEXTFILE) || die "Can't close $filename: $!";  
  }

>Well, that was two questions, but any help would be greatly appreciated.
>Thanks a lot in advance.

It'd be worth investing in a book like "Learning Perl", and reading the 
FAQs and other docs that come with perl, perldoc perl is a good place
to start. 

-- 
Cheers
Steve              email mailto:steve@zeropps.uklinux.net

%HAV-A-NICEDAY Error not enough coffee  0 pps. 

web http://www.zeropps.uklinux.net/

or  http://start.at/zero-pps

 11:16pm  up 102 days, 4 min,  2 users,  load average: 1.22, 1.13, 1.04


------------------------------

Date: 14 May 2001 17:18:45 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Sorting a variable
Message-Id: <m3n18fk20q.fsf@dhcp9-172.support.tivoli.com>

On Mon, 14 May 2001, pswordkirk@msn.com wrote:

> I'm accessing a DBM database, searching it for a specific value,
> then printing the keys that contain that value. However I want the
> output to be sorted alphabetically.... but not sorted by the keys,
> but by the value (actually, a part of the value, which is split with
> a delimiter).

Two ways to go.  Either sort the whole list and then search and print,
or, search the list and save the values, then sort the results and
print.

> Here is the code I have now.

Based on what you currently have, it's a bit easier to just save the
matches and print in a separate loop after sorting:

[Indenting of original code fixed]

#______
my @results;
Movies->DBMConnect();
while (($Movies::key, $Movies::value) = each %Movies::dbmdata) {
  ($Movies::Title, $Movies::PreviewURL, $Movies::ReviewURL,
   $Movies::Rating, $Movies::Release, $Movies::Genre)
     = split(/$Movies::DELIM/, $Movies::value);
  if ($Movies::Genre =~ /$Movies::ID/) {
    my $result = "$Movies::Title";
    if ($Movies::PreviewURL ne "") {
      $result .=
        qq( <a href="/movies/previews.cgi?id=$Movies::key">[Preview]</a>);
    }
    if ($Movies::ReviewURL ne "") {
      $result .=
        qq( <a href="/movies/reviews.cgi?id=$Movies::key">[Review]</a>);
    }
    $result .= "<br>\n";
    push @results, $result;
  }
}
Movies->DBMDisconnect();
print sort @results;
#______

Note that this cheats by taking advantage of the fact that the movie
title is the first part of the result string.

> Now, I need the output to be sorted by '$Movies::Title' .... and of
> course have the key be able to match up with it in the output. I've
> tried sorting the hash, putting the title in an array and sorting
> that, and a bunch of other stuff but nothing works.
> 
> Truth be told, it would do the same thing I need it to do if it were
> sorted by $Movies::key, but I would much rather it sort by the
> title. Any help is appreciated, I've been at this for about 3 days
> now. And if you notice any problems with the code, feel free to
> shout at me for being an idiot.

The above solution is *very* specific to your example code, and is
*not* how I would have done it from scratch.  I would probably have
done something similar to Logan Shaw's suggestion.

Be sure and peruse the FAQ entry, "How do I sort an array by
(anything)?" for more information on this type of thing.

BTW, the example Logan gave should have worked.  What exactly was the
problem?

-- 
Ren Maddox
ren@tivoli.com


------------------------------

Date: Mon, 14 May 2001 23:50:42 GMT
From: "KapTin KiRk" <pswordkirk@msn.com>
Subject: Re: Sorting a variable
Message-Id: <mb_L6.654$v5.83810@news1.rdc1.ct.home.com>

The exact code that he gave me did work. However when I attempted to put in
the keys in there (which I need for the link) it went a bit beserk. I'll try
your suggestion, if not I'll just go ahead and sort it by the keys, which
would be the simplest thing to do. Thanks

"Ren Maddox" <ren@tivoli.com> wrote in message
news:m3n18fk20q.fsf@dhcp9-172.support.tivoli.com...
> BTW, the example Logan gave should have worked.  What exactly was the
> problem?




------------------------------

Date: Mon, 14 May 2001 22:32:26 GMT
From: "Dodger" <dodger@necrosoft.net>
Subject: Re: Taint
Message-Id: <_1ZL6.2746$F46.833009@news1.rdc2.pa.home.com>

"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m3elts2fkh.fsf@mumonkan.sunstarsys.com...

> No it does not.  You cannot alter a string's taintedness via s///.
> Period.

Hmm.. Even with:

$string =~ s/^(.*)$/($string = $1, $string)[1]/e;

?

> ITYM "blindly untainting data is *not* a good idea"; nevertheless your
> "example" does nothing of the kind.

Sorry, typo. That's what I meant.

> I think it is time to post your test code and output.  If your perl
> behaves as you say it does, it is surely broken.

I do apologise on one front -- in that in examining my existing code I have
found that I have only used this method of untainting inside of a
subroutine, as follows:

sub untaint ($) { /^(.*)$/ and return $1; }

However, the principle does remain, and for the number who have attacked
that a subprocess should be started in which to run the 'safe' stuff, I have
experienced that this does not work: the subprocess does/has not inherited
the UID setting of the spawning process after any $< and $> settings.

I appreciate that Joe has directly pointed at the error, instead of marking
the entire concept as nonsense, and again I apologise for my slight error.

So, in answer to the original question, let me rephrase that as:

$dirty =~ /^(.*)$/ and $clean = 1;

--
Dodger
www.dodger.org
www.necrosoft.net
www.gothic-classifieds.com





------------------------------

Date: 14 May 2001 22:35:13 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Taint
Message-Id: <slrn9g0n8e.58p.damian@puma.qimr.edu.au>

Dodger chose Mon, 14 May 2001 12:01:55 GMT to say this:
>"Uri Guttman" <uri@sysarch.com> wrote in message
>news:x7pudd9i61.fsf@home.sysarch.com...
>
>> <the sound of dodger hitting killfiles all over the world>
>
>Perfect. And for everyone who responded likewise, I'll do the same for you
>all.
>
>It's best we don't communicate, or even know one another exist,
>

Cool -- can't pass up an invitation like that. My scorefile is still
letting way too many posts through.

*plonk*

HAND :-)


------------------------------

Date: 14 May 2001 23:31:20 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Taint
Message-Id: <9dpps8$fu4$5@mamenchi.zrz.TU-Berlin.DE>

According to Dodger <dodger@necrosoft.net>:

[lots snipped]
 
> $dirty =~ /^(.*)$/ and $clean = 1;

Oh man.  You *do* rely on readers filling in bits for you, don't you?

Anno


------------------------------

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 901
**************************************


home help back first fref pref prev next nref lref last post