[16638] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4050 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 17 18:15:50 2000

Date: Thu, 17 Aug 2000 15:15:33 -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: <966550532-v9-i4050@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 17 Aug 2000     Volume: 9 Number: 4050

Today's topics:
    Re: Processing text from gzipped file (Otto Wyss)
    Re: readdir in order by date (David Combs)
    Re: readdir in order by date (Greg Bacon)
    Re: readdir in order by date (David Combs)
    Re: readdir in order by date <lr@hpl.hp.com>
    Re: References to hashes <kjetilskotheim@iname.com>
        Search and replace character sections msacks@my-deja.com
    Re: Search and replace character sections (Greg Bacon)
    Re: Search and replace character sections <care227@attglobal.net>
    Re: Search and replace character sections <care227@attglobal.net>
    Re: Search and replace character sections michaeljgardner@my-deja.com
    Re: Search and replace character sections <godzilla@stomp.stomp.tokyo>
        Search and replace help please msacks@my-deja.com
    Re: Search and replace help please <kjetilskotheim@iname.com>
    Re: Sorting is very slow (Anno Siegel)
    Re: Sorting is very slow <russ_jones@rac.ray.com>
    Re: Sorting is very slow <juex@deja.com>
    Re: Sorting is very slow (Abigail)
    Re: SUID in perl <care227@attglobal.net>
    Re: SUID in perl <juex@deja.com>
        THERE IS A WHOLE NEWSGROUP DEDICATED TO Perl/TK!!! <care227@attglobal.net>
    Re: uninitialized value??? (Keith Calvert Ivey)
        Upload file: Apache/perl - PLEASE HELP!!! <milnergroup@usa.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 17 Aug 2000 23:07:31 +0200
From: otto.wyss@bluewin.ch (Otto Wyss)
Subject: Re: Processing text from gzipped file
Message-Id: <1efj5wy.1tm4szg14hyuwcN%otto.wyss@bluewin.ch>

> > I'd like to open a gzipped file an process its
> > contents. Is there any easy way, i.e. is there a
> > function (or module) to unzip it on the fly?
> 
>     perldoc Compress::Zlib
> 
Thanks.

But I'm not able to figure out myself how to get the uncompressed text
into a buffer. What's wrong with this lines:

        open (FILE, "$file") ll die ...;
        $gzcontent = <FILE>;
        $content = uncompress($gzcontent);
        $verbose && print "Content is = $content\n";
        &process ($content, (stat ("$file"))[9]);
        close FILE if $file;

I also tried gzopen but wasn't successful either.

O. Wyss


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

Date: 17 Aug 2000 18:16:28 GMT
From: dkcombs@netcom.com (David Combs)
Subject: Re: readdir in order by date
Message-Id: <8nha5s$5se$1@slb2.atl.mindspring.net>

In article <slrn8ocqh6.rvr.rgarciasuarez@rafael.kazibao.net>,
Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
>Mark-Jason Dominus wrote in comp.lang.perl.misc:
>>In article <39865CB7.F8CDE4A9@earthlink.net>,
>>David Tsai  <templar318@earthlink.net> wrote:
>>>Does anyone know how to read files from a directory in order by the date
>>>they were created?
>>
>>No can do.  You get them in the order that the operating system gives
>>them to you.
>>
>>>But I want it to automatically read in the files in order by the date
>>>beacuse I don't want to use an array....
>>
>>You can sort them without the array:
>>
>>        sort {-C $a <=> $C $b} (readdir DIR)
>>
>>but I don't know what you think that will win you.
>
>A little warning here : -C will not get the correct result if you
>don't prepend the directory to the file name:
>
>  opendir DIR,$dir or die "Can't read dir $dir: $!\n";
>  for my $file (sort { -C "$dir/$a" <=> -C "$dir/$b" } readdir DIR) {
>      # ...
>  }

(1) OK -- then why does this -C thing exist?

(2) if it is a BIG dir, would `ls -t` be faster?

(3) (remind us) why must one prepend the directory/ to the filename,
    in order to use -C?  

David



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

Date: Thu, 17 Aug 2000 18:51:43 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: readdir in order by date
Message-Id: <spod1vejr5j85@corp.supernews.com>

In article <8nha5s$5se$1@slb2.atl.mindspring.net>,
    David Combs <dkcombs@netcom.com> wrote:

: In article <slrn8ocqh6.rvr.rgarciasuarez@rafael.kazibao.net>,
: Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
:
: >A little warning here : -C will not get the correct result if you
: >don't prepend the directory to the file name:
: >
: >  opendir DIR,$dir or die "Can't read dir $dir: $!\n";
: >  for my $file (sort { -C "$dir/$a" <=> -C "$dir/$b" } readdir DIR) {
: >      # ...
: >  }
: 
: (1) OK -- then why does this -C thing exist?

The -C file test operator is documented in the perlfunc manpage.

: (2) if it is a BIG dir, would `ls -t` be faster?

Probably.

: (3) (remind us) why must one prepend the directory/ to the filename,
:     in order to use -C?  

This is what the perlfunc documentation on readdir() says:

    If you're planning to filetest the return values out of a readdir(),
    you'd better prepend the directory in question.  Otherwise, because
    we didn't chdir() there, it would have been testing the wrong file.

        opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
        @dots = grep { /^\./ && -f "$some_dir/$_" } readdir(DIR);
        closedir DIR;

The readdir() operator returns a list of filenames contained in that
directory.  The filenames aren't qualified, so if you opendir() /etc
and readdir() the handle in list context, the result will contain
"passwd", "group", "sendmail.cf", "inetd.conf", "services", and so
on.  Remember that unqualified filenames are considered relative to
the current directory, so, depending on the working directory, "passwd"
and "/etc/passwd" may refer to different files.

Greg
-- 
Quantum Mechanics is God's version of "Trust me."


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

Date: 17 Aug 2000 20:10:02 GMT
From: dkcombs@netcom.com (David Combs)
Subject: Re: readdir in order by date
Message-Id: <8nhgqq$h0c$1@slb6.atl.mindspring.net>

Thanks!

David



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

Date: Thu, 17 Aug 2000 14:48:28 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: readdir in order by date
Message-Id: <MPG.1405fd84bb515d5598ac8b@nntp.hpl.hp.com>

In article <spod1vejr5j85@corp.supernews.com> on Thu, 17 Aug 2000 
18:51:43 GMT, Greg Bacon <gbacon@HiWAAY.net> says...
> In article <8nha5s$5se$1@slb2.atl.mindspring.net>,
>     David Combs <dkcombs@netcom.com> wrote:
> 
> : In article <slrn8ocqh6.rvr.rgarciasuarez@rafael.kazibao.net>,
> : Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:

 ...

> : >  for my $file (sort { -C "$dir/$a" <=> -C "$dir/$b" } readdir DIR) {
> : >      # ...
> : >  }

 ...

> : (2) if it is a BIG dir, would `ls -t` be faster?
> 
> Probably.

Not if the sort is done properly -- by computing the sortkey once per 
file instead of once per comparison.

http://www.hpl.hp.com/personal/Larry_Rosler/sort/

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 17 Aug 2000 21:21:48 +0200
From: Kjetil Skotheim <kjetilskotheim@iname.com>
To: Dave Wishart <dwishar1@ford.com>
Subject: Re: References to hashes
Message-Id: <399C495C.C83A8B6F@iname.com>


Dave Wishart wrote:
> 
> Longish bit of code - sorry. Included for completeness.
> 
> I'm a bit stumped over a small section of code I now have to maintain.
> 
>>>>>>>>..........
> 
> The bit I'm stumped with is:-
> 
>  $$my_propid{$my_key}=\%my_temp_transaction;
> 
>     if (not ($transaction{$my_propid}))
>   {
>   $transaction{$my_propid}=\%{$my_propid};
>   } # end of if
> 
> I think the line
> 
>  $$my_propid{$my_key}=\%my_temp_transaction;
> 
> assigns
> 
> $$my_propid{$my_key} ro a reference to a hash but I'm not sure of the
> $$my_propid{$my_key} part. I think its a symbolic reference.



Yes, I very well could be. The line $my_propid="STANDARD" indicates
that this is a symbolic reference. $$my_propid{...} is the same as
$STANDARD{...}  when $my_propid = "STANDARD".

> As for the if statement I don't really understand it. I did look at Camel
> for advice but things aren't any clearer.

Well, it simply sets $transaction{$my_propid} to a reference to the
hash named by $my_propid if it hasnt been set to a true value before.
Could use the ||= operator (sets if not set before) instead of the if:

$transaction{$my_propid} ||= \%{$my_propid};

If $my_prodid is STANDARD then:

$transaction{'STANDARD'} ||= \%STANDARD;


 
> The hash 'transaction' hasn't been declared or used until this section of
> code.


Doent have to be if its a global hash. Although it is considered "good
programming behaviour" to declare vars.



-- 
Kjetil Skotheim
kjetilskotheim@iname.com


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

Date: Thu, 17 Aug 2000 19:57:34 GMT
From: msacks@my-deja.com
Subject: Search and replace character sections
Message-Id: <8nhg33$kij$1@nnrp1.deja.com>

Hi.
I have scoured this board and have not found anything close enough to
my problem to help me.

I am trying to hide the domain of an email address. To do this I want
to replace the section in between the '@' and '.com/.edu/.net/.org' of
an email address with '*' to protect the identity of the email sender.

I have only been using perl for a short while, and this is the search
and replace test string that I am trying: s/\b\@*com/\*/g;

Just to be sure I'm clear, the intent of the string is to
convert "jack1test@hotmail.com" to "jack1test@*******.com"

Thanks in advance.

-Matt


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


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

Date: Thu, 17 Aug 2000 20:28:48 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Search and replace character sections
Message-Id: <spoio0ndr5j70@corp.supernews.com>

In article <8nhg33$kij$1@nnrp1.deja.com>,
     <msacks@my-deja.com> wrote:

: Just to be sure I'm clear, the intent of the string is to
: convert "jack1test@hotmail.com" to "jack1test@*******.com"

    $addr =~ s/^(.+)@(.+)\.(.+)$/$1 . '@' . ('*' x length $2) . ".$3"/e;

Look, Ma, no /e:

    $addr =~ s/^(.+)@(.+)\.(.+)$/$1\@${\('*' x length $2)}.$3/

Greg
-- 
The surest sign that intelligent life exists elsewhere in the universe is that
it has never tried to contact us. 
    -- Calvin


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

Date: Thu, 17 Aug 2000 16:28:47 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Search and replace character sections
Message-Id: <399C4AFF.ECEF3DEA@attglobal.net>

msacks@my-deja.com wrote:
> 
> Hi.
> I have scoured this board and have not found anything close enough to
> my problem to help me.
> 
> I am trying to hide the domain of an email address. To do this I want
> to replace the section in between the '@' and '.com/.edu/.net/.org' of
> an email address with '*' to protect the identity of the email sender.

How American-centric.  (is that a word?).  There are quite a bit more
top level domains than .(com|org|net|mil|edu)  

Each country (including the good ol' USA) has a top level domain
corresponding to its 2 letter ISO country code.  .us, .jp, .uk, etc.
 
> I have only been using perl for a short while, and this is the search
> and replace test string that I am trying: s/\b\@*com/\*/g;
> 
> Just to be sure I'm clear, the intent of the string is to
> convert "jack1test@hotmail.com" to "jack1test@*******.com"
> 

But your regex won't do that.  Lets see why, bit by bit.

s	search for
/	(delimiter, begin search)
\b	a word boundry
\@	followed by an ampersand (does that need to be escaped?)
*	any number of the previous, including 0
com	literal text, the word 'com'
/	(delimiter, begin replace)
\*	a literal * (but only 1)
/	(delimiter, end replace)
g;	do it globally.  Is this necessary?

So you want a boundry followed by hopefully 1 but possible 0 or a 
million @'s followed by com:  @@@@@@@@@@@@com.  Problematic.  Try 
instead:

s/(.+\@).+\.(com|org|net|mil|edu)/$1*****\.$2/ #overlooking the rest 
                                               #of the world =(


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

Date: Thu, 17 Aug 2000 16:34:56 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Search and replace character sections
Message-Id: <399C4C70.5FF53773@attglobal.net>

Drew Simonis wrote:
> 
> s/(.+\@).+\.(com|org|net|mil|edu)/$1*****\.$2/ 

Greg Bacon's regex is (as expected) much better.  Ignore mine.


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

Date: Thu, 17 Aug 2000 20:44:47 GMT
From: michaeljgardner@my-deja.com
Subject: Re: Search and replace character sections
Message-Id: <8nhirp$o45$1@nnrp1.deja.com>

In article <8nhg33$kij$1@nnrp1.deja.com>,
  msacks@my-deja.com wrote:
> Hi.
> I have scoured this board and have not found anything close enough to
> my problem to help me.
>
> I am trying to hide the domain of an email address. To do this I want
> to replace the section in between the '@' and '.com/.edu/.net/.org' of
> an email address with '*' to protect the identity of the email sender.
>
> I have only been using perl for a short while, and this is the search
> and replace test string that I am trying: s/\b\@*com/\*/g;
>
> Just to be sure I'm clear, the intent of the string is to
> convert "jack1test@hotmail.com" to "jack1test@*******.com"
>
> Thanks in advance.
>
> -Matt
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Matt,
I don't think your regex is correct.  You want characters starting with
the "at" sign and ending with a period to be replaced.  I think it
should be something like;

$emailaddress=~s/@\w+\./@xxxxxxx\./;

I used a slash to escape the '.' so it wouldn't represent 'any'
character.  You want to replace the domain name with asterisks, I
used x's to avoid any metacharacter confusion.  It this turns out to be
the address of an existing porn site you can change it to something
else.  Anyway, try it and see if it works.

Cheers,
Michael


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


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

Date: Thu, 17 Aug 2000 14:31:46 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Search and replace character sections
Message-Id: <399C59C2.2DE8937C@stomp.stomp.tokyo>

msacks@my-deja.com wrote:

> I have scoured this board and have not found
> anything close enough to my problem to help me.

Possibly you are approaching this problem with
less than logical thinking?
 
> I am trying to hide the domain of an email address....

(snipped)

This is a rather odd way, replacing characters
with asterisks. I don't understand why you are
even making portions of an email address public
viewable. Have a look:

"jackandjill@*******.org"

"                       "

What difference is there?

A major difference, yes? For the first example email
address, you have to do some fancy programming. For,
the second case, which should actually be nothing,
requires you do just that; nothing.

Don't post, don't record or delete email addresses.
Very simple solution, don't you agree? 

Should I want to find "jackandjill@*******.org"
it is just a matter of a wildcard search for
jackandjill at a .org site.

If this isn't enough reason, an email address can be
found without much effort based simply on the logon
name, especially if a unique logon name. For most
logon names sans server, you can find a full email
address within thirty minutes. Don't display email
addresses, even a portion, if you truly wish to 
conceal email addresses. I can find a full email
address from partial information, so can others.
Just a matter of time, effort and creativity.

If you are still not convinced, why are you bothering
to replace characters with asterisks. Why don't
you just pull the logon name and delete all else
following? 

"jackandjill@upthehill.com"

becomes

"jackandjill"

Sure seems logical to me, more logical than providing
just enough details to quickly find a full email addy
when your intent is to conceal an email address.

Godzilla!


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

Date: Thu, 17 Aug 2000 19:55:45 GMT
From: msacks@my-deja.com
Subject: Search and replace help please
Message-Id: <8nhfvm$khg$1@nnrp1.deja.com>

Hi.
I have scoured this board and have not found
anything close enough to my problem to help me.

I am trying to hide the domain of an email
address. To do this I want to replace the section
in between the '@' and '.com/.edu/.net/.org' of
an email address with '*' to protect the identity
of the email sender.

I have only been using perl for a short while,
and this is the search and replace test string
that I am trying: s/\b\@*com/\*/g;

Just to be sure I'm clear, the intent of the
string is to convert "jack1test@hotmail.com"
to "jack1test@*******.com"

Thanks in advance.

-Matt


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


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

Date: Thu, 17 Aug 2000 21:28:20 +0200
From: Kjetil Skotheim <kjetilskotheim@iname.com>
To: msacks@my-deja.com
Subject: Re: Search and replace help please
Message-Id: <399C4AE4.AAA426B4@iname.com>



msacks@my-deja.com wrote:
> I am trying to hide the domain of an email
> address. To do this I want to replace the section
> in between the '@' and '.com/.edu/.net/.org' of
> an email address with '*' to protect the identity
> of the email sender.
> 
> I have only been using perl for a short while,
> and this is the search and replace test string
> that I am trying: s/\b\@*com/\*/g;
> 
> Just to be sure I'm clear, the intent of the
> string is to convert "jack1test@hotmail.com"
> to "jack1test@*******.com"


$address = 'jack1test@hotmail.com';
$address =~ s/\@(.+)(\.\w+)$/"@".("*" x length($1)).$2/e;

print "$address\n"; #will now see jack1test@*******.com




-- 
Kjetil Skotheim
kjetilskotheim@iname.com


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

Date: 17 Aug 2000 18:16:49 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Sorting is very slow
Message-Id: <8nha6h$m0c$1@lublin.zrz.tu-berlin.de>

Abigail <abigail@foad.org> wrote in comp.lang.perl.misc:
>Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDXLIII

[...]
 
>() You don't understand what the O(f(n)) notation means.  Roughly speaking,
>() it means that there is a constant A such that for large n the runtime
>() of an algorithm is proportional to A*f(n).
>
>That is incorrect. You will know that for large enough n, the runtime is
>*less* than A*f(n). Heapsort and mergesort are both O (n log n), but they
>are also O (n^2). You cannot say that one sorting algorithm is O (n^2)
>and the other is O (n log n), the other is faster. As O (n^2) does not
>imply it is not O (n log n).

You are, of course, absolutely correct, and I can only point out that
I cautioned the readers.  I would be lying if I said I had this 
particular inaccuracy in mind when I added "roughly speaking", but
I knew it would come in handy.

Then again, it is often practical to think of big-Oh as if it meant
"will run in time proportional to...".  It basically means that we
trust whomever has worked out the bound that they have found a good 
one.  That in defense of my over-simplification.

>                             Bubble sort is Omega (n^2), and that's why
>it's relatively slow. Note however that worst case, quicksort is Omega
>(n^2) as well. If you know that your input is uniformly distributed,
>quicksort has an O (n log n) expected running time. However, many
>quicksort implementation act poorly on sorted, or nearly sorted data.
>Perls implementation of quicksort uses a "middle-of-three" approach
>to pick a pivot. This makes sorting sorted data fast (faster than 
>randomly shuffled input, as it gets a perfect pivot each time), but
>it's still easy to have input that makes the sorting algorithm behave
>quadratic. See below.

Yes, it seems to be hard to get that worst case behavior out of
quicksort derivates.  It seems you can only shift it to less
obvious situations.

That's what I like about merge sort.  It has n log(n) average run 
time with a small standard deviation.  Why isn't it more often
implemented?

[snip beautifully presented benchmarks (I saved the file)]

Anno


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

Date: Thu, 17 Aug 2000 13:16:22 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: Sorting is very slow
Message-Id: <399C2BF6.66DB8E3@rac.ray.com>

Abigail wrote:
> 

(Lots of stuff about sorting algorithms and then examples and
benchmarks)

That was an excellent and very informative post. Thanks, I learned a
lot from it. (Not sarcasm, this time I mean it.)

-- 
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747

Quae narravi, nullo modo negabo. - Catullus


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

Date: Thu, 17 Aug 2000 14:27:50 -0700
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: Sorting is very slow
Message-Id: <399c58d7$1@news.microsoft.com>

"Jim Chim" <mecks@ust.hk> wrote in message news:399B5F82.42E16A26@ust.hk...
>     I have write a code to sort some meteorological data which contain
> 281560 data point.
> And write a sortin scheme to sort it. I know bubble sort only. I found
> that it take more
> than 10 hours to sort the data in PIII 800MHz machine. Can anyone give
> me some idea
> of how to improve the scheme so that it work faster. Thanks.

Why do you prefer a manual implementation of one of the slowest known
sorting algorithms over the fast build-in "sort" in the first place?
If you insist on re-implementing the wheel have a look at one of the many
books about algorithms, starting with the venerable Donald E. Knuth "The Art
of Programming" (sorry, don't remember the volume), or Sedgwick
"Algorithms", or Cormen et.al. "Introduction to Algorithms".

jue




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

Date: 17 Aug 2000 21:28:29 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Sorting is very slow
Message-Id: <slrn8pom6o.tj3.abigail@alexandra.foad.org>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDXLIII
September MCMXCIII in <URL:news:8nha6h$m0c$1@lublin.zrz.tu-berlin.de>:
^^ 
^^ Then again, it is often practical to think of big-Oh as if it meant
^^ "will run in time proportional to...".  It basically means that we
^^ trust whomever has worked out the bound that they have found a good 
^^ one.  That in defense of my over-simplification.

Finding thight bounds is usually a hard problem. Finding non-trivial
upper bounds is much easier than finding non-trivial lower bounds.

^^ Yes, it seems to be hard to get that worst case behavior out of
^^ quicksort derivates.  It seems you can only shift it to less
^^ obvious situations.
^^ 
^^ That's what I like about merge sort.  It has n log(n) average run 
^^ time with a small standard deviation.

Well, mergesort not only has O (n log n) average [1] running time, it's
also the worst case running.

^^                                        Why isn't it more often
^^ implemented?

Memory. Mergesort doesn't work in-situ, and you an additional Theta (n)
memory.

Now, why isn't heapsort implemented more often... ? ;-)

(And for reasonable value of "small", sorting small arrays can be done
quite quickly with Shellsort, which has a very trivial algorithm (see K&R
and TAoCP).



Abigail
-- 
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_=sub{print/::(.*)/};
$\=$/;q<Just another Perl Hacker>->();


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

Date: Thu, 17 Aug 2000 14:52:09 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: SUID in perl
Message-Id: <399C3458.2A82AD74@attglobal.net>



Lithium wrote:
> 
> Anyone know where I can go for information on writing what every reference
> refers to as a "setuid script"?  Or have a code example, or even just know
> of a script that uses it that I can look at?

Most would prefer to write a C wrapper for the script.  I don't 
know any examples off hand, but a websearch at google or altavista 
should turn up quite alot.  Search on CGI wrapper and similar
things...

You'll also find alot more information in the archives of this
group as well as comp.infosystems.www.authoring.cgi, the latter
being the prefered group for this sort of question. 

F-up suggested.


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

Date: Thu, 17 Aug 2000 14:31:13 -0700
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: SUID in perl
Message-Id: <399c59a1$1@news.microsoft.com>

"Lithium" <lithium@ev1.net> wrote in message
news:spo8e2bfr5j53@corp.supernews.com...
> After asking a dumb question, doing research using the info I was
> (thankfully) given, and going down a number of other avenues, I now know
how
> to write a program that uses suid in C (which is all the manpages seem to
> cover on this area).  Regrettably, I needed to do this in perl.  I can't
> find a command remotely like setuid or setguid or anything similar for
perl,
> and so far haven't found a module that seems to do something similar to
the
> c library for it.

You don't want to.
Just the other day there was a CERT advise about a security issue with SUID
Perl, affecting all versions of Perl.

jue




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

Date: Thu, 17 Aug 2000 15:08:34 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: THERE IS A WHOLE NEWSGROUP DEDICATED TO Perl/TK!!!
Message-Id: <399C3832.CC95CF8B@attglobal.net>

comp.lang.perl.tk

Sorry for shouting, but so many questions on Tk are driving me insane.


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

Date: Thu, 17 Aug 2000 19:25:45 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: uninitialized value???
Message-Id: <399d00cd.5761373@news.newsguy.com>

Gordon Gidluck <ggidluck@ozarkisp.net> wrote:

>   if(/^(\d{5})/){
>     if (($i==0) && ($zip{$1}==1)) { print "$_ 1\n"; }
>     if (($i==0) && ($zip{$1}!=1)) { $i+=1; print "$_ 0\n"; }
>     if (($i==1) && ($zip{$1}==1)) { $i+=1; print "$_ 1\n"; }
>     if (($i==2) && ($zip{$1}!=1)) { $i+=1; print "$_ 0\n"; }
>     if (($i==3) && ($zip{$1}==1)) { $i+=1; print "$_ 1\n"; }
>     if (($i==4) && ($zip{$1}!=1)) { $i+=1; print "$_ 0\n"; }
>     if (($i==5) && ($zip{$1}==1)) { $i+=1; print "$_ 1\n"; }
>     if (($i==6) && ($zip{$1}!=1)) { $i+=1; print "$_ 0\n"; }
>     print "$_\n";
>   }

The reason for the warnings is that you're comparing $zip{$1},
which is often undefined, to a number.  One solution would be 
to use just

    $zip{$1}

or
    exists $zip{$1}

in a boolean context, since it appears that all you're really
interested in is whether the key exists in the hash.  You might
also want to use ++$i instead of $i+=1, although that's not
causing warnings, because you have initialized $i to 0
explicitly.

The code in the loop above is very strange and can probably be
greatly simplified.  What are you really trying to do exactly?
If you're trying to use $i to count lines (but just the first
six?), you might want to use $. instead.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Thu, 17 Aug 2000 20:10:18 GMT
From: The Milner Group, Inc. <milnergroup@usa.net>
Subject: Upload file: Apache/perl - PLEASE HELP!!!
Message-Id: <8nhgqp$ljo$1@nnrp1.deja.com>

Hello,

PROBLEM:

I'm trying to upload a simple text file (for now) using the browser/CGI
perl.

As a result I am getting the following error:
"Premature end of script headers".

If I change to GET from POST, I can retrieve the file NAME, but the
actual body of the text file is not there.

I feel that it maybe an Apache setup issue, but do not know what switch
to look for.


NOTE:

1. Permissions are 777 on upload dir and cgi script.
2. perl is executing other CGIs and is in correct location
3. CGI is executing without error on command-line

the following is my environment/programs:

       OS: HP-UX
WEBSERVER: Apache 1.3
     PERL: perl5/CGI.pm
  BROWSER: MSIE4+/Netscape (neither works)

HTML PAGE:
-----------------------------------
<html>
<head>
</head>
<body>
<form ENCTYPE="multipart/form-data"
action="http://server.com/cgi-bin/upload.cgi" method=post>
<H1>File Upload:</h1><BR>
<INPUT TYPE="file" NAME="FILE1" SIZE="25">
<INPUT TYPE="submit" NAME="submit" VALUE="Upload File">
</FORM>
</BODY>
</HTML>


PERL SCRIPT: (downloaded from
http://www.perlservices.com/uploadhelper.htm
-------------------------------------
#!/usr/local/bin/perl
$basedir = "/tmp/upload";
$allowall = "yes";
$theext = ".gif";
$donepage = "http://www.cnet.com";
use CGI;
$onnum = 1;
while ($onnum != 11) {
my $req = new CGI;
my $file = $req->param("FILE$onnum");

if ($file ne "") {
my $fileName = $file;
$fileName =~ s!^.*(\\|\/)!!;
$newmain = $fileName;
if ($allowall ne "yes") {
if (lc(substr($newmain,length($newmain) - 4,4)) ne $theext){
$filenotgood = "yes";
}
}
if ($filenotgood ne "yes") {
open (OUTFILE, ">$basedir/$fileName");
print "$basedir/$fileName<br>";
while (my $bytesread = read($file, my $buffer, 1024)) {
print OUTFILE $buffer;
}
close (OUTFILE);
}
}
$onnum++;
}
print "Content-type: text/html\n";
print "Location:$donepage\n\n";

--
Anatoly Milner
The Milner Group, Inc.


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


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

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


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