[16590] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4002 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 13 18:06:11 2000

Date: Sun, 13 Aug 2000 15:05:12 -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: <966204311-v9-i4002@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 13 Aug 2000     Volume: 9 Number: 4002

Today's topics:
    Re: "more" with perl (Abigail)
    Re: Auto running a script via email or by a specific ti (Abigail)
    Re: CGI : CheckBox and Form Question <etienno@my-deja.com>
        DBM Files Going Haywire!!! HELP!!! mlmguy@my-deja.com
    Re: Help: libs with Latin-1 or Unicode? <occitan@esperanto.org>
    Re: Help: libs with Latin-1 or Unicode? <flavell@mail.cern.ch>
    Re: how can I optimize a tied hash for speed (Kevin Reid)
    Re: Intershop <etienno@my-deja.com>
    Re: Javascript to Perl <juex@my-deja.com>
    Re: lamer problem of commiting a perl script (Abigail)
    Re: London £30-35K Perl Programmers Required (Colin Keith)
    Re: London £30-35K Perl Programmers Required (Maggert)
    Re: Online Script...?. (Colin Keith)
    Re: Organizing and verifying a set of tree structures (Abigail)
        Perl security check <thk@hongkong.com>
    Re: Perl security check (Colin Keith)
    Re: Procmail vs Perl. (Tony L. Svanstrom)
    Re: Procmail vs Perl. <flavell@mail.cern.ch>
    Re: Programming Ethics <ken.j.parmalee.spamthis@bridge.bellsouth.com>
    Re: Regexp help, escaping characters <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 13 Aug 2000 15:42:29 GMT
From: abigail@foad.org (Abigail)
Subject: Re: "more" with perl
Message-Id: <slrn8pdge5.tj3.abigail@alexandra.foad.org>

Nick Condon (nickco3@yahoo.co.uk) wrote on MMDXXXVI September MCMXCIII in
<URL:news:3992AD6A.B60460BF@yahoo.co.uk>:
$$ Javier Hijas wrote:
$$ 
$$ > how can I display paged information with Perl?
$$ 
$$ Pipe it to more?:
$$  perl script | more
$$ 
$$ or in your script:
$$ open (STDOUT, "| more") or warn "Can't run more: $!\n";


Or even:

    my $pager = $ENV {PAGER} || "more"; # Will fail if your pager is called '0'.
    open STDOUT, "| $pager"  or  die "Meeeeep!";


Abigail
-- 
$_ = "\112\165\163\1648\141\156\157\164\150\145\1628\120\145"
   . "\162\1548\110\141\143\153\145\162\0128\177"  and &japh;
sub japh {print "@_" and return if pop; split /\d/ and &japh}


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

Date: 13 Aug 2000 16:16:36 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Auto running a script via email or by a specific time??
Message-Id: <slrn8pdie2.tj3.abigail@alexandra.foad.org>

Ryan (ryanmh_99@yahoo.com) wrote on MMDXXXVIII September MCMXCIII in
<URL:news:sp9h5g9mn4t27@corp.supernews.com>:
)) Is it possible to run a PERL script in response to an email to a specific 
)) email address??  Is it possible to have a script run on a specific time 
)) every day??  Thanks for the help

I don't know what PERL is, but if you ask for a Perl program, yes, there
is. But that has nothing to do with Perl. How to set that up depends on
your local MTA. Idem for running things on a specific time. How to do that
depends on your OS, and not at all on the language your application is
written in.

Talk to your system administrator. And be nice to him/her.



Abigail
-- 
perl -we'$;=$";$;{Just=>another=>Perl=>Hacker=>}=$/;print%;'


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

Date: Sun, 13 Aug 2000 16:43:53 GMT
From: Etienne Laverdiere <etienno@my-deja.com>
Subject: Re: CGI : CheckBox and Form Question
Message-Id: <8n6j8a$alo$1@nnrp1.deja.com>

Thanks for the answer. Just after my sending, I have found a more
generic way to send a 'off' value in the checkbox value. It can sound
strange,but here's the answer (no, it is not a PERL solution, but it is
related):


It is a simple javascript scan made on the "onSubmit" of the form
containing the checkbox button:


function scanCheckBox(form){
	  for (var k=0;k<form.length;k++){
		if ((form.elements[k].type == 'checkbox')&&
(form.elements[k].checked == 0)){
			form.elements[k].checked = 1;
			form.elements[k].value = '*off';
			}
		}
	}


By this way the empty checkbox is send with a 'off' value.



-- Regards,.

Etienne Laverdiere
Montreal

In article <39904A68.F542DA41@shentel.net>,
  Albert Dewey <timewarp@shentel.net> wrote:
> Let's say you have the following in your html form:
>
> <input type=checkbox name=choice1 value=on>
>
> Use the following perl do write to your database if the checkbox is
not checked.
>
> $Choice1 = param('choice1');
>
> if($Choice1 ne "on")
>     {
>     put your database action here........
>     }
>
> What happens is that an unchecked checkbox will upload absolutely
nothing to the
> server, in other words it is ignored by the browser. If you use the
above code
> in Perl you will be writing a value to the database even though the
form sent
> nothing regarding the checkbox to the server because you have
declared the
> variable for the checkbox and it will contain nothing unless the web
page has it
> checked whereupon it will upload the value if "on" as in this example.
>
> Etienne Laverdiere wrote:
>
> > Hi, does anyone have resolves this problem :
> >
> > I have a form with a lots of <INPUT> (elements) and some of theses
Inputs
> > are CheckBox. I have made a database that read this form (with DBI)
and put
> > the value of each Input in it. When my Form have to read a checkBox
that is
> > checked, the database can put an 'on' into the related record
(checkbox1 =
> > 'on').
> >
> > But the problem is that when the checkbox is not checked, the form
doesn't
> > send the information, because it doesn't pass the name of the
checkbox. So,
> > my record is not update. (Because of the complexity of my database,
and the
> > hight number of checkbox in it, I would rather not duplicate all my
checkbox
> > into some hidden field with the same name, and then submit the hole
form..)
> >
> >  I would like something like (if checkbox not check = > checkbox1
= 'off').
> > I tried a simple Javascript that scan all my form and replace a
empty value
> > by a 'oof' but I am sure that the form does't sent the information.
Here's
> > the javascript that is run when submitting my form :
> >
> > function scanCheckBox(form){
> >
> >      for (var k=0;k<form.length;k++){
> >         if ((form.elements[k].type == 'checkbox')&&(form.elements
[k].checked
> > == 0)){
> >             form.elements[k].value = 'OF';
> >            }
> >       }
> >      // return true; doesn't matter
> >  }
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 13 Aug 2000 19:42:36 GMT
From: mlmguy@my-deja.com
Subject: DBM Files Going Haywire!!! HELP!!!
Message-Id: <8n6tnc$hr5$1@nnrp1.deja.com>

Hello,

I am new at Perl. I have created an FFA Links Page with 50 Links
totally. I have tried storing the data in a text file but I dont like
the results. I then tried to use DBM files using the following code. If
you notice I have used a 'different' way of locking the process. The
reason being I dont know any other way of locking. Anyway, now the
logic of the new link being added on the top and the bottom one being
deleted is working perfectly. However, strangely, my DBM data file
keeps growing. It grew to a massive 4.5 MB in one day. But if I try to
display the total number of records in it, it still shows 50. So what
is the extra space holding??? Please HELP someone out there. Thanks in
advance. Here is the code which I am using.

#Start of Code

$linkfilelock = "+< linkfilelock.cgi";

open LINKLOCK, $linkfilelock;
unless (flock (LINKLOCK, 2)) {
print "Can't Lock! the linkfilelock.cgi\n";
	die "I am Dead!";
}

$link_database = "linkfile.dbm";
%link;

dbmopen (%link, $link_database, 0700) || die "cant open DBM";

#tie %link, "Tie::IxHash";

@values;

for ($i=0;$i<50;$i++) {
$values[$i] = $link{$i+1};
}

$newlink = "$title;$url;$email;$remote_addr";

unshift @values, $newlink;
$oldlink = pop @values;

for ($i=0;$i<50;$i++) {
$link{$i+1} = $values[$i];
}

dbmclose %link;

close LINKLOCK;

#End of Code

Thanks again,
mlmguy


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 13 Aug 2000 20:14:09 GMT
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: Re: Help: libs with Latin-1 or Unicode?
Message-Id: <8n6vif$j0d$1@nnrp1.deja.com>

Alan J. Flavell <flavell@mail.cern.ch> wrote:
> On Sat, 12 Aug 2000, Daniel Pfeiffer wrote:

>> I've read the perlunicode and related doc, but I did not understand
>> it.

> Disclaimer: I interpreted what I read about 5.6, to mean that unicode
> support wasn't really ready yet, so I didn't pay much attention to
it.

That's my feeling too.  Won't I ever hate it when XFree86 4.0 finally
works with some decent Unicode support and no programmes are there to
take advantage of it.

> However, I do have some familiarity with unicode from HTML/WWW work,
> so I'm doing my best to comment.  Pinches of salt to be taken ;-)

>> that sets off bits of Perl from the rest of the text and executes
>> them while printing the rest.  The data to be scanned can get passed
>> in via include statements from three sources: a filename, a
>> filehandle or a string.  Now one bit of data might be in Latin-1 and
>> another in the same programme in Unicode.

> Once upon a time, I worked with a computer whose internal coding was
> as good as totally incompatible with all other computers on the planet
> (I wonder whether I could finally get a nod from MJTG on this point
> ;-) and which therefore took it for granted that all input and output
> streams had to be associated with a character-code translation
> procedure.  It was quite a discipline.

And a waste of CPU-time, but it looks like all the combination
mechanisms in Unicode will mean a lot more interpreting and mapping in
the future, even if we stick to only Unicode.

> First of all, let's get one thing clear (but I think from your posting
> that you already know this, hmmm?).  Unicode defines an abstract
> representation of characters.  A mapping, if you will, between
> characters on the one hand, and integers withing a certain range.

Indeed, as does Ascii or Ebcdic...

> If you're dealing with coded character data, then a given file is
> meant to be in one and only one character coding.  If it's utf-8 then
> it can't also be iso-8859-1 and vice versa.  The idea of having a data
> stream that suddenly switches from say utf-8 to say iso-8859-7 just
> isn't considered.

I didn't mean it that way.  Each call to include in Text::iPerl handles
an indpendent document.  These may even be totally dissociated under
mod_perl where the same process will handle separate requests for
different web-pages.

>> Where and how does this get handled?  As far as I understand this,
>> the makers of Unicode did not invent a (Latin-1 NOP) magic number to
>> differeniate this, so the document gives no clues

> AFAIK all unicode codings are self-identifying, or at least can be
> made so by starting the datastream in a specific way (the coded
> representation of a zero-width non joiner, IIRC?).

> But this won't help you to disambiguate iso-8859-1 from iso-8859-15
> ("Latin-zeuro" - joke), or windows-1252 from windows-1251 for
example.
> Whether you can disambiguate between ascii-based codings and
> ebcdic-based codings is yet another question (remember, Perl _is_
> implemented on some ebcdic-based plaforms).

A colleague of mine is the driving force behind the BS2000 port.  And
poor me has to get into that lousy system currently -- and like
everybody around, I just hate the Siemens model of automatic
ebcdic/ascii conversions taking place at erratic moments :-(

>> unless someone invents a heuristic to determine byte sequences
>> impossible in UTF-8 -- maybe not very promising.

> utf-8 has a built-in consistency check, in as much as each multibyte
> sequence defines its own length.  The probability of an arbitrary
> iso-8859-* file of any size passing this test is miniscule.

That sounds good, I'll just experiment with using tr///UC as a test.
But that's not very efficient...

Grüße zurück -- Daniel

--
Bring text-docs to life!              Erwecke Textdokumente zum Leben!
                   http://beam.to/iPerl/
Vivigu tekstodokumentojn!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 13 Aug 2000 22:53:59 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Help: libs with Latin-1 or Unicode?
Message-Id: <Pine.GHP.4.21.0008132240180.24627-100000@hpplus03.cern.ch>

On Sun, 13 Aug 2000, Daniel Pfeiffer wrote:

(much that calls for no further comment from me...)

> > First of all, let's get one thing clear (but I think from your posting
> > that you already know this, hmmm?).  Unicode defines an abstract
> > representation of characters.  A mapping, if you will, between
> > characters on the one hand, and integers withing a certain range.
> 
> Indeed, as does Ascii or Ebcdic...

Well, yes, but those integers lie in the range 0-255, and are encoded
by using bytes(octets) of the appropriate values, so it's very
straightforward.  Everybody makes the same choice (the only exception
I ever found was the IBM mainframe, which in some contexts stored
ASCII with the bits the opposite way round).

Whereas unicode codings are a more complex representation of the
abstract integer values.

You're probably already aware of it, but there's a mass of
concentrated information at http://czyborra.com/utf/

> A colleague of mine is the driving force behind the BS2000 port.  And
> poor me has to get into that lousy system currently -- and like
> everybody around, I just hate the Siemens model of automatic
> ebcdic/ascii conversions taking place at erratic moments :-(

You should've seen IBM mainframe Postscript!  A mishmash of 
EBCDIC and ASCII.  Shudder.

all the best



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

Date: Sun, 13 Aug 2000 17:34:34 -0400
From: kpreid@attglobal.net (Kevin Reid)
Subject: Re: how can I optimize a tied hash for speed
Message-Id: <1efbcgl.1g90i0if6hxtsN%kpreid@attglobal.net>

<webqueen> wrote:

> I just benchmarked my ap thru CGI- 10,000 element hash going through it
> one item at a time, 4 minutes on a P450! Something like:
> 
> tie %h ...
> 
> foreach (keys %h) {do some simple sorting and printing}
> 
> untie %h;

That builds a list of every key in the hash, then iterates over it. It
is much more efficient to use while and each():

tie %h ...
while (my ($key, $value) = each %h) {
  # do something with $key and $value
}
untie %h;

-- 
 Kevin Reid: |    Macintosh:      
  "I'm me."  | Think different.


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

Date: Sun, 13 Aug 2000 16:55:33 GMT
From: Etienne Laverdiere <etienno@my-deja.com>
Subject: Re: Intershop
Message-Id: <8n6ju4$b3n$1@nnrp1.deja.com>

Hi, I work whit Intershop for almost a year and it's a good engin.
Forget about a complete PERL API, everything is encrypted. With
some "reverse engenering" maybe you will find 5 or 6 functions to
access you product database. It works well, but you will need some
development of your own if you need to make a good e-commerce solution.

Regards,

Etienne Laverdiere
Montreal

subscribe to news.intershop.com to find the newgroups you need.


In article <39946742.893378E1@mail.com>,
  Zachary Kent <zkent@mail.com> wrote:
> Has anyone here used Intershop (Merchant, to be specific)?  I hear it
is
> written in Perl and extendable by adding new code.  Does anyone have
any
> experience with it?  What were your thoughts on it vs. other e-
commerce
> solutions?  What did it cost?
>
> I ask this question in this group cus I am a perl programmer and I
want
> to know what other perl programmers have to say about this product.  I
> tried the alt.comp.intershop group but it is a just a bunch of chain
> letters and scams.
>
> Thanks
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 13 Aug 2000 08:24:34 -0700
From: "Jurgen Exner" <juex@my-deja.com>
Subject: Re: Javascript to Perl
Message-Id: <3996bdbb@news.microsoft.com>

"Andy" <andychu@hotmail.com> wrote in message
news:39963D9F.DF58BBD9@hotmail.com...
> Does anyone know how to pass the value from Javascript to Perl?

You can use any inter-process communication method you like, e.g. signals,
pipes, shared files, etc. (except shared memory).

> Example:
> code segment in the javascript:
>
> <script language="Javascript">
> function add(value){
>    var myvalue = Math.abs(value) + 100;
> }
> </script>
> ------------------------------------------------------------------
> code segment in the perl:
> <a href="anyscript.cgi?thevalue=myvalue" onclick="add(10)">test</a>

But this is an HTML snippet, not Perl.

> after clicked the link - test, the value "10" was added to myvalue and
> get the result "110", and i want to get this result and put it into the
> perl code like above, but it doesn't work, does anyone know how to solve
> it?

From your description I have no idea where Perl comes into the game.
Maybe this is a stealth CGI question?

jue




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

Date: 13 Aug 2000 15:14:06 GMT
From: abigail@foad.org (Abigail)
Subject: Re: lamer problem of commiting a perl script
Message-Id: <slrn8pdeot.tj3.abigail@alexandra.foad.org>

Christopher M. Jones (christopher_j@uswest.net) wrote on MMDXXXIX
September MCMXCIII in <URL:news:f1tl5.1241$3C5.393296@news.uswest.net>:
 .. 
 .. "Abigail" <abigail@foad.org> wrote:
 .. 
 .. > HD (elbereth*nospam*@gmx.de) wrote on MMDXXXV September MCMXCIII in
 .. > <URL:news:8mrjg7$6pp$1@news01.khis.de>:
 .. > ## I am starting in perl a few days ago
 .. > ##
 .. > ## #!/usr/bin/perl
 .. >
 .. > Bug  1:  There's no -w.
 .. > Bug  2:  There's no -T.
 .. > Bug  3:  There's no "use strict;"
 .. > Bug  4:  There's no "use CGI;"
 .. 
 .. Sheesh, take the stick out of your ass for at least a
 .. few minutes a day.  Not everyone needs to program like
 .. you do.

Then don't come here presenting your problems. If you want to dig your own
hole, be merry, and don't complain if you fall in.

 .. > ##   $value =~ s/<!--(.|\n)*-->//g;
 .. >
 .. > Bug  5: That doesn't match HTML comments.
 .. 
 .. Oh, not like you'd actually want to help the poor guy?
 .. 
 .. BTW, it should be something like
 .. 
 ..   $value =~ s/<!--.*?-->//gs;

That doesn't match HTML comments either.

 .. > ## print "<body bgcolor=#FFFFFF text=#000000 link=#009900 vlink=006600
 .. > ## alink=#0000FF>\n";
 .. >
 .. > Bug  7: Invalid HTML syntax.
 .. 
 .. Invalid?  When did you become the W3C?

You don't have to be the W3C to be able to understand what has been written.

 .. It'll work perfectly fine and that's all that really
 .. matters.

Just the fact you're using a pitiful browser written by people who couldn't
parse their way out of a paper bag doesn't mean it's correct. Every version
of a browser produced by a company whose name starts with an N, and ends
with etscape, fixed a parsing bug, making gazillions of pages that used to
"work" no longer "work".

Bug compatability isn't "working perfectly fine".

 .. Again, not everyone has to program like the great
 .. bitch-goddess from the sky.

Agreed. But then, if it would work, he wouldn't come here and present his
problems, now would he?


Abigail
-- 
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT


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

Date: Sun, 13 Aug 2000 15:43:40 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: London £30-35K Perl Programmers Required
Message-Id: <Mmzl5.114$DT4.3514162@nnrp2.clara.net>

In article <3996a59c.217367908@news.ionet.net>, mag@ionet.net (Maggert) wrote:
>        You'll never get the quality Perl Programmers for less than
>55K. British Pounds. You might be able to snag some up and comers for
>between  40 - 50 though. 

If I could get paid that for programming Perl I wouldn't complain :)
Wish I was good enough :(

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Sun, 13 Aug 2000 19:23:26 GMT
From: mag@ionet.net (Maggert)
Subject: Re: London £30-35K Perl Programmers Required
Message-Id: <3996f54d.237768873@news.ionet.net>

On 13 Aug 2000 15:12:52 +0100, nobull@mail.com wrote:

>> 	In the mean time you can post your offer to
>> http://jobs.perl.org .
>
>Really?  As far as I can see that's a very US-centric site.

	I guess thats true, but they'd probably take your money
anyway. They probably ought to take that into account and do an
international thing.



MP


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

Date: Sun, 13 Aug 2000 16:12:42 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Online Script...?.
Message-Id: <_Nzl5.115$DT4.3517337@nnrp2.clara.net>

In article <3996a7d5.803915@news.erols.com>, T. & D. Gregor, Sr. <tdg@erols.com> wrote:
>What I’m searching for is the equivalent of the "Online.cgi" script

*sigh* There are very few script names that mean anything to anyone.. 

>(hack) for the Ultimate Bulletin Board or UBB. This hack through

Well its catchy, but a better reputation would be if I'd heard of it.

>cookie manipulation via PERL... shows who’s online at any given point
>in time, by popping-up a window showing USER NAME - DATE/TIME -

Blah okay some advice. HTTP is a protocol that closes the connection after 
every transaction. Therefore there is no 'online' the only time people are 
connected are when they're actually transfering files, I doubt that is what 
you really want.

>Any and all feedback is most welcome...

*all* feedback could include some extremely strong language. This isn't your 
fault, per se, its a mistake that many people make. But that said, this 
group is for help with Perl. What you asked for is a program. The two are 
unrelated, no matter how frequenly people write CGI programs  in Perl. 

Don't get angry/upset/disheartened. Instead think about what you asked for. 
Are their no mailing lists/web sites where you can talk with other users of 
this program? If not, how about writing it yourself and distributing it? If 
you don't know where to start, go to http://www.perl.com/ get a copy of 
perl, with the documentation, visit the tutorials and go for it. 

Don't think "I can't do that", just play with it. I suspect if you start 
you'll find this 'ultimate' program will be full of holes, and lacking 
features that you can add. Your 'online' script is probably something as 
simple as checking the files in a directory, or opening a file that contains 
some kind of database and displaying the contents back to you.

For instance in the case of multiple text files in a directory it could be 
something as 'simple' as:

#warn "untested code"

opendir(DH, "/usr/home/me/uubdb") || die "couldn't open dir - $!";
chdir( "/usr/home/me/uubdb");

printf("%24s %15s %15s %s\n", qw(Username StartTime LastTime IP));
# Check each file in the dir
while(defined($file = readdor(DH))){
  next if($file =~ /^\./);
  if(!open(FH, $file)){
    print "Error opening $file - $!";
    next;
  }

  # Read the data from the file
  while(<FH>){
    $username  = $1 if(/^Username: (.*)\s*$/);
    $starttime = $1 if(/^StartTime: (.*)\s*$/);
    $ip        = $1 if(/^IP: (.*)\s*$/);
    $lasttime  = $1 if(/^lasttime: (.*)\s*$/);
  }

  # print it on screen
  printf("%24s %15s %15s %s\n", $username, $starttime, $lasttime, $ip);
}

# To give
Username  StartTime  LastTime  IP
bobsmith   12:13:03  12:15:03  127.0.0.1
johnsmith  12:15:23  12:20:38  192.168.0.1

Complex? So is reading this message if you're new to computers... 


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: 13 Aug 2000 15:31:52 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Organizing and verifying a set of tree structures
Message-Id: <slrn8pdfq7.tj3.abigail@alexandra.foad.org>

Bart Lateur (bart.lateur@skynet.be) wrote on MMDXXXVII September MCMXCIII
in <URL:news:hdu7psgn362q3e1kd9a992q02tvecb7f13@4ax.com>:
~~ I have the subtask of modifiying data that should be ordered in a
~~ treelike structure. The user can modify the relationship between two
~~ items, so that if one is subordinate to the other, the reverse can't be
~~ true. No cycles. It's not just *verifying* that there are no cycles, but
~~ *removing* the inverse link, if this link did exist before.

That's a vague specification. If you have the links 'A => B', 'B => C',
'C => A', what is "the inverse link"? 

~~                                                             Also, not
~~ all items are indeed linked to each other. So it's a very loose tree. (a
~~ bush?)

A forest.


~~ I'm looking for suggestions on what data structures and data
~~ organization I could use, to ease writing the program that maintains it
~~ in a state of integrity.

I seriously suggest looking into 'Cormen, Rivest, Leiserson: Introduction
to Algorithms'.

Do a depth first search of your forest. Any "back-edge" created by the
depth first search is a link you have to remove. The running time of the
algorithm is O (|V| + |E|).



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: Sun, 13 Aug 2000 23:09:29 +0800
From: thk <thk@hongkong.com>
Subject: Perl security check
Message-Id: <FC3CA5B4D21DF0E2.C138D19F76A7B521.A9A07F0F58C4FFCE@lp.airnews.net>

Dear all,

Recently, I am writing a CGI script for users to edit their
 .forward file in their home directory on web so that they can
use the forward function more convenience.

Here is a question, when I want to use

    open(USER, ">/home/me/.forward");

there is no problem.

But when I use a variable such as

    $userfile=/home/me/.forward ;
    open(USER, ">$userfile");

a error message generated :
--Insecure dependency in open while running setuid at
/web/cgi-bin/chforward.cgi line 79.

so I have change my idea, I want to generate a temp file to store the
new .forward data, unlink the old one and then copy the temp file to
 .forward under user's directory.

Finally I have got the following error:
--Insecure dependency in unlink while running setuid at
/web/cgi-bin/chforward.cgi line 93.

Do anyone can give some idea?
How can I edit user's .forward file by a variable path?
Or you have some better idea?





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

Date: Sun, 13 Aug 2000 16:49:06 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Perl security check
Message-Id: <6kAl5.116$DT4.3521842@nnrp2.clara.net>

In article <FC3CA5B4D21DF0E2.C138D19F76A7B521.A9A07F0F58C4FFCE@lp.airnews.net>, thk <thk@hongkong.com> wrote:
>But when I use a variable such as
>    $userfile=/home/me/.forward ;
>    open(USER, ">$userfile");

I don't think this is your code. If it is then the interpreter should be 
taken outside and XOR'ed for allowing unquoted variables without screaming. 
With or without -w.

>a error message generated :
>--Insecure dependency in open while running setuid at
>/web/cgi-bin/chforward.cgi line 79.

Then that isn't the code that you have above:

  #!/usr/bin/perl -Tw
  use strict;
  use Symbol;

  my($fh) = Symbol::gensym;
  my($userfile)='/usr/home/colin/.forward';
  open($fh, ">$userfile");

Generates no warnings at all. You will get warnings about insecure 
dependencies if you use tainted variables. That is any variable that could 
have been set by a  *dum-de-dum* ... user (ick! :)

So... given that the code above werks, you must be using something like 
  $userfile = $ENV{HOME} . '.forward';
or
  $userfile = $ARGV[0];

Maybe something like this to take it straight from the passwd file:
  my($userfile)=(getpwuid($<))[7]. '.forward';

But then, thats only possible for a local user because then $< has their 
UID. You can't use getpwnam($ARGV[0]) because then its come from outside and 
is tainted.

>so I have change my idea, I want to generate a temp file to store the
>new .forward data, unlink the old one and then copy the temp file to
>..forward under user's directory.

Good and bad. Good because if the program dies before it has chance to 
rewrite the new one, but has opened it, thus blatted the contents its 
recoverable. Bad because you'll probably end up with race conditions because 
the writing and copying aren't atomic. I.e. you open it for 
writing and write. Something else slips its entry in there, you copy it ... 
ta da, you've just copied someone else's data .. 

>How can I edit user's .forward file by a variable path?
>Or you have some better idea?

Yes, it involves beaches, tropical sunshine and skimpily clad w.. err. oh, 
sorry, yes don't trust the users, they're a crafty bunch. Match your 
homedirectory against a regexp to untaint it. I.e. 

die "naughty!" if($homedir !~ /^\/usr\/home\/([a-z]+)$/);
die "non existent" if(!(@_ = getpwnam($1)));
die "nope" if($_[1] ne crypt($passwd, substr($_[1], 0, 2)));
my($userfile) = "/usr/home/$1/.forward";

Not only have you checked that its a username with just letters, but you 
then checked it in the password file and that the password is correct. The 
latter is for your sanity, Perl couldn't give a toss.

Of course, since you're talking about .forward files, I assumed it was some 
sort of UNIX, thus you have passwd files ... :)


Hey, on the idea of  this being an "unhelpful, RTFM group", anyone thought 
of writing a bot to automatically send "no, goto comp.infosystems.www.*" 
messages? In purl of course :)))

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Sun, 13 Aug 2000 21:18:35 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Procmail vs Perl.
Message-Id: <1efbmse.1s7p8t2171w2glN%tony@svanstrom.com>

Sam <sam@email-scan.com> wrote:

> In article <1efbf1y.171gvyotw70ytN%tony@svanstrom.com>,
>       tony@svanstrom.com (Tony L. Svanstrom) writes:
> 
> > A simple question: Why would I want to learn how to use procmail when I
> > already know Perl, wouldn't it be easier, as well as potentially a lot
> > more powerful, to simply use Perl for the mailfiltering?
> 
> And how do you propose to actually use Perl to filter your incoming mail?

The cheating way... "piping into" it from Procmail. ;)
The "real" way... using good ol' .forward. :)

> > I've printed about 50-60 pages of documents related to procmail, and at
> > a first look there seems to me as if there are no real advantages to
> > using Procmail vs a Perl-based solution. Clearly there must be something
> > that I miss, but what?
> 
> Yes: your mail server runs procmail to deliver your mail.  It doesn't run
> Perl to do that.  procmail applies the filtering instructions, and, if
> instructed to do so, delivers the mail to your system mailbox.
> 
> Running Perl instead of procmail will accomplish absolutely nothing,
> except losing your mail, unless you write the actual code to deliver your
> mail to your system mailbox, after any filtering takes place.

Of course, I would have to deal with that myself; haven't tried working
with those files before, but I don't see a problem.

> To do that, you need to know where your system mailbox is, and the correct
> procedure to deliver mail there.  Simply appending the message may not
> always work, in most cases there are some low-level locking procedures
> that need to take place.

Ah, now we're getting to the interesting stuff... Exactly what is it
that Procmail is doing that I can't do with Perl, when it comes to
writing to the mailbox?


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
 DSS: 0x9363F1DB, Fp: 6EA2 618F 6D21 91D3 2D82  78A6 647F F247 9363 F1DB
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©1999  <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Sun, 13 Aug 2000 22:20:52 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Procmail vs Perl.
Message-Id: <Pine.GHP.4.21.0008132215380.24627-100000@hpplus03.cern.ch>

On Sun, 13 Aug 2000, Tony L. Svanstrom wrote:

> Ah, now we're getting to the interesting stuff... Exactly what is it
> that Procmail is doing that I can't do with Perl, when it comes to
> writing to the mailbox?

It knows a whole lot about different kinds of mailbox and different
locking strategies.  If you toss out procmail, you'd have to re-invent
those.  Well, at least you'd have to re-invent the ones you need - and
if/when you move to a different environment you'd likely have to do it
over again.

(So why not use procmail to pipe the stuff into your Perl script, and
get the best of both?)

cheers



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

Date: Sun, 13 Aug 2000 17:07:43 -0400
From: Ken Parmalee <ken.j.parmalee.spamthis@bridge.bellsouth.com>
Subject: Re: Programming Ethics
Message-Id: <39970E1F.6F714829@bridge.bellsouth.com>



Soren Andersen wrote:

> jmaggard@va.mediaone.net (Jason Maggard) wrote in
> <398D1351.D8A14436@va.mediaone.net>:
>
> >If you hadn't programmed this someone else would have.
> >If someone else wouldn't have they could buy one.
>
> This is the utterly amoral argument. It is a worthless argument, it is the
> argument of those who have no ultimate values at all, nor much imagination.
>
> Philosophy is not the strong point of many individuals in modern society. It is
> a very good thing that this thread is taking place here. Ordinary people, "even
> programmers," need to *not* leave this sort of question up to the "experts." It
> is too important to leave up egomaniac talking heads and pundits.
>
> There is such a thing as being asleep as one moves through life. When one is
> awake, one realizes, senses, sees that every single day brings ethical,
> spiritual challenges.
>
> "Ethics" is not an "inferior" area to "programming." Just far less comfortable.
> Comfort != rightness | logic | clear thinking. Comfort is just that:
> stagnation, stasis, dullness, decay. Hostility and cynicism when ethical
> questions are raised or replied to in public discussions is a self-defense
> mechanism engaged in by those who have the inner maturity and self-confidence
> of young children and furthermore doubt their own capacity or potential for
> growth in that area.
>
> Life is change. Growth comes whether we want it or not. Sooner or later.
> Embracing it as much as we can and choosing (at least sometimes) a harder road
> over the easiest road is a sign of imagination, courage and true intellect, and
> is a more graceful or 'cool' way of living -- because that way, one gets to be
> the protagonist rather than merely the eventual 'victim.' It's not "stupidity"
> to be concerned about ethical issues.
>
> Too many "clever" programmers apparently have an extremely narrow and distorted
> understanding of the overall model of how life works -- the Big Picture. It
> works based on profound cause-and-effect (not simple-minded childish naive
> notions of same) and it shows at times fearsome stringency, strictness. The
> minds of human beings today seem like leaky sieves -- we forget memorable
> instances of life's strictness 5 minutes after we perceive them -- we go 'back
> to sleep' -- and in that condition even deny that cause-and-effect is the
> principle that life operates on when another (with compassionate intention)
> points it out.
>
>    soren andersen
>
> --
> Using PNG-format images as Web BACKGROUNDs without
> "breaking your Site" for silly older browsers:
> http://www.wonderstorm.com/techstuff/
>    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have no problems with your speech, however my experience has been that what gets
passed off as "ethics" nowadays is really some "time-honored" rules that mask the
agendas of other people.

And you're either following your own path or the path given to you by another.
Which one will give you the ability to look in the mirror and say to yourself "What
I am I built with my own hands"?

I'd walk away from any job that asks me to check my values at the door, or to
trust/obey my superiors without question. Other than that, I'm pretty open.

Ken Parmalee

-- Remove ".spamthis" from my e-mail address to reply




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

Date: Sun, 13 Aug 2000 20:33:57 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Regexp help, escaping characters
Message-Id: <0m0eps0lelq8sc6ako5ngqe6n7h2ki2q9o@4ax.com>

Sebastian wrote:

>I've got a string like so:
>
>$s = '"this is a text field";1234;"A text; field";4321;"Another text
>field"';
>
>Essentially, I want to split it into fields:
>
>@array = split(/;/,$s);
>
>But I don't want to split on a delimiter within quotes, such as in the
>third field of my string above.

The problem you describe is very common. So common, that there is a name
for this kind of text file (CSV), and there is a module that is built to
process it: Text::CSV, or Text::CSV_XS which is written in C. See CPAN,
or Activestate's module repositiry if it's for a windows Perl (try the
"/packages/zips" subdirectory at their site; be sure to get the module
for your Perl.

-- 
	Bart.


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

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 V9 Issue 4002
**************************************


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