[18734] in Perl-Users-Digest
Perl-Users Digest, Issue: 902 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 15 00:06:03 2001
Date: Mon, 14 May 2001 21:05:07 -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: <989899507-v10-i902@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 14 May 2001 Volume: 10 Number: 902
Today's topics:
Can you build GUI's with perl? <bfb@att.net>
Re: Concenate Columns <joe+usenet@sunstarsys.com>
Re: Concenate Columns <c_clarkson@hotmail.com>
Emptying all variables in script <neo@accesscable.net>
Re: Emptying all variables in script <krahnj@acm.org>
Re: Existing Script To Add Time <grasshopper99[no-spam]@hotmail.com>
Re: garbage collection in perl <ilya@math.ohio-state.edu>
How to call a 3rd-party DLL from perl script? (Christopher Mooney)
Re: nested pattern <jfreeman@tassie.net.au>
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <godzilla@stomp.stomp.tokyo>
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <godzilla@stomp.stomp.tokyo>
sorting hash's <bobnet604@hotmail.com>
Re: sorting hash's <uri@sysarch.com>
Re: Taint (Garry Williams)
URGENT: CGI program wanted! <graphi@lineone.net>
Urgent: CGI program wanted <muksca@hotmail.com>
Re: Urgent: CGI program wanted <AgitatorsBand@yahoo.com>
Re: Urgent: CGI program wanted <muksca@hotmail.com>
Re: Urgent: CGI program wanted <spam@un.u.nu>
Re: What is wrong with my Regular Expression? <godzilla@stomp.stomp.tokyo>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 15 May 2001 03:21:40 GMT
From: Bernie <bfb@att.net>
Subject: Can you build GUI's with perl?
Message-Id: <3B00A0C1.FBA6EA73@att.net>
Is it possible to build GUI's with perl, under Linux and
or Windows? I checked CPAN, but didn't find any modules
along these lines.
-Thanks
------------------------------
Date: 14 May 2001 23:05:45 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Concenate Columns
Message-Id: <m3r8xr1fcm.fsf@mumonkan.sunstarsys.com>
jtjohnston <jtjohnston@courrier.usherb.ca> writes:
> "firsthalf.txt"
> 1¶field1¶field2¶field3¶field4¶field5¶field6¶field7¶field8¶field9¶field10
> ¶field11¶field12
>
> 2¶field1¶field2¶field3¶field4¶field5¶field6¶field7¶field8¶field9¶field10
> ¶field11¶field12
>
> ...
> 100¶field1¶field2¶field3¶field4¶field5¶field6¶field7¶field8¶field9¶field10
> ¶field11¶field12
>
> "secondhalf.txt"
> 1¶field13¶field14¶field15¶field16¶field17¶field18¶field19¶field20¶field21
> ¶field22¶field23¶field24
>
> 2¶field13¶field14¶field15¶field16¶field17¶field18¶field19¶field20¶field21
> ¶field22¶field23¶field24
>
> ...
> 100¶field13¶field14¶field15¶field16¶field17¶field18¶field19¶field20¶field21
> ¶field22¶field23¶field24
>
> I need to concenate, not the files, but the columns and output to a new
> text file. Thus where "field12" ends, I want to add "field13" up to
> field "24".
> The output will look like this:
>
> 1¶field1¶field2¶field3¶field4¶field5¶field6¶field7¶field8¶field9¶field10
> ¶field11¶field12¶field13¶field14¶field15¶field16¶field17¶field18¶field19
> ¶field20¶field21¶field22¶field23¶field24
>
> 2¶field1¶field2¶field3¶field4¶field5¶field6¶field7¶field8¶field9¶field10
> ¶field11¶field12¶field13¶field14¶field15¶field16¶field17¶field18¶field19
> ¶field20¶field21¶field22¶field23¶field24
>
> ...
> 100¶field1¶field2¶field3¶field4¶field5¶field6¶field7¶field8¶field9¶field10
> ¶field11¶field12¶field13¶field14¶field15¶field16¶field17¶field18¶field19
> ¶field20¶field21¶field22¶field23¶field24
>
> Newbie question ... but :) Can someone help me come up with something?
>
Sorry for not offering a perl solution, but what's wrong with Unix's
join(1)?
% man 1 join
% join -t '¶' firsthalf.txt secondhalf.txt
If you are not using *nix, you should be :)
btw- some years ago I was asked a similar question on a job interview.
I gave an awk answer, and they gave someone else the job :(
hth
Joe Schaefer
--
Quintessential Williams: e-enable user-centric e-markets
------------------------------
Date: Mon, 14 May 2001 17:16:59 -0500
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: Concenate Columns
Message-Id: <3D533F69F2F68522.F7123B45DDD85120.CD52AAFEACDDFB3F@lp.airnews.net>
jtjohnston <jtjohnston@courrier.usherb.ca> wrote:
:
: Hi,
:
: I already have two database files "firsthalf.txt" and "secondhalf.txt".
: Without getting into a looong explanation, a very expensive software
: (www.notabene.com) can only extract 12 fields at a time.
:
: Their contents, respectively, look a bit like this:
:
: "firsthalf.txt"
: 1¶field1¶field2¶field3¶field4¶field5¶ . . . field11¶field12
: 2¶field1¶field2¶field3¶field4¶field5¶ . . . field11¶field12
: ...
: 100¶field1¶field2¶field3¶field4 . . . field11¶field12
:
: "secondhalf.txt"
: 1¶field13¶field14¶field15¶field16¶ . . . field22¶field23¶field24
: 2¶field13¶field14¶field15¶field16¶ . . . field22¶field23¶field24
: ...
: 100¶field13¶field14¶field15¶field16¶ . . . field22¶field23¶field24
:
: I need to concenate, not the files, but the columns and output to a new
: text file. Thus where "field12" ends, I want to add "field13" up to
: field "24".
: The output will look like this:
: 1¶field1¶field2¶field3¶field4¶field5¶ . . . field22¶field23¶field24
: 2¶field1¶field2¶field3¶field4¶field5¶ . . . field22¶field23¶field24
: ...
: 100¶field1¶field2¶field3¶field4¶field5¶ . . . field22¶field23¶field24
:
[snip]
An array might be faster, but I think a hash is more flexible.
# requires perl 5.6.0
sub read_file ($;%);
# create a hash with record number as key and the rest of the line as value
my %combined = read_file 'secondhalf.txt', read_file 'firsthalf.txt';
my $combined_file = 'combined.txt';
open my $fh, ">$combined_file" or die "Yikes! $combined_file $!";
print $fh "$_$combined{$_}\n" foreach sort keys %combined;
sub read_file ($;%) {
# read file and put in hash, concatenate if hash given
my $file_name = shift;
my %hash;
%hash = @_ if @_;
open my $fh, $file_name or die "Yikes! $file_name $!";
while (<$fh>) {
$hash{$1} .= $2 if /^(\d+)(\xb6.*)/;
}
return %hash;
}
HTH,
Charles K. Clarkson
The Lottery is a tax on those who can't do math.
------------------------------
Date: Mon, 14 May 2001 23:24:32 -0300
From: "News" <neo@accesscable.net>
Subject: Emptying all variables in script
Message-Id: <Xn0M6.238165$Z2.2589256@nnrp1.uunet.ca>
I need to know if there is a way to empty all your variables in a perl
script at once instead of:
$variable1 = "";
$variable2 = "";
$variable3 = "";
This is because I require another script later in the program except the
script that I require conflicts with some of the variables. Instead of
emptying them one by one as above I'd like to clear all variables in my
script at once if that is possible.
Thanks
------------------------------
Date: Tue, 15 May 2001 02:52:24 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Emptying all variables in script
Message-Id: <3B0099E5.1E6DB5DD@acm.org>
News wrote:
>
> I need to know if there is a way to empty all your variables in a perl
> script at once instead of:
>
> $variable1 = "";
> $variable2 = "";
> $variable3 = "";
>
> This is because I require another script later in the program except the
> script that I require conflicts with some of the variables. Instead of
> emptying them one by one as above I'd like to clear all variables in my
> script at once if that is possible.
perldoc -f reset
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 15 May 2001 01:19:56 GMT
From: "grasshopper" <grasshopper99[no-spam]@hotmail.com>
Subject: Re: Existing Script To Add Time
Message-Id: <0v%L6.38243$Hk4.583151@news1.rdc1.ab.home.com>
Excuse my ignorance, but how does one use a function, be it mktime or any
other one?
Thanks!
Pete
"TAJTHY Tamás" <tajthy@mail.euroweb.hu> wrote in message
news:3afbcd15.11513725@news.euroweb.hu...
> Dear Grasshopper,
>
> On Fri, 11 May 2001 04:21:27 GMT, "grasshopper"
> <grasshopper99[no-spam]@hotmail.com> wrote:
>
> >Wondering if anyone has a script (bourne or perl) available which can
> >calculate the elapsed time between two given times such as: 08:00 16:30
> >which would be an elapsed time of 08:30.
>
> I think You don't need a script. It seems very easy. In the POSIX
> module there is mktime function. With it You can get the seconds
> ellapsed since 1970-01-01 00:00. Do it on both times You have to
> substract them and the result is the ellapsed time in seconds.
>
> I hope this help a bit.
>
> Good byte!
>
------------------------------
Date: 15 May 2001 02:15:01 GMT
From: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: garbage collection in perl
Message-Id: <9dq3f5$2p1$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Anno Siegel
<anno4000@lublin.zrz.tu-berlin.de>], who wrote in article <9dpi4p$fu4$4@mamenchi.zrz.TU-Berlin.DE>:
> > The value of that variable *will* persist until the next access (most
> > often by my(), which undef()s the previous value) unless this value is
> > an object reference.
>
> I'm not sure I understand. In which way is an object reference treated
> differently from other scalars? Is it not reset by my()? Or is it not
> retained until the next access? I can't seem to find a code example
> that supports either reading.
This is a correct search result. I write it differently below.
a1) *Nothing* is done to a lexical variable "when it goes from scope".
(HEURISTIC: Going out from scope is a "time-related issue").
a2) Exception: if the variable contains an object reference, the
variable is undef()ed on exit.
b) Runtime-effect of my() is the same as of undef().
Ilya
------------------------------
Date: Tue, 15 May 2001 03:24:57 GMT
From: cjmoone@yahoo.com (Christopher Mooney)
Subject: How to call a 3rd-party DLL from perl script?
Message-Id: <3b00a00c.105616205@news.tcainternet.com>
I am currently toward the end of the first phase of a project I am
coding in VB6 with an Access Database and using a background Excel
instance to fill a spreadsheet record with 100+ inputs, which then
makes a call to a third-party DLL designed to be called from Excel. I
then sniff out the output and store it in the database along with
other values. I have tried several unsucessful options to call this
DLL from VB, but to no avail (including suggestions from other native
USENET VB programmers). ARGGGGGHHH!
The obvious disadvantage to this is that I must start a background
instance of Excel, thus degrading system performance and requiring
Excel be installed on the machine. I have been coding production Perl
scripts at work for a while now, and would love to replace this Excel
call with one from a Perl script (if it's doable of course).
Anyone else had luck with this kind of problem?
Thanks in advance :)
------------------------------
Date: Tue, 15 May 2001 11:13:48 +1000
From: James freeman <jfreeman@tassie.net.au>
Subject: Re: nested pattern
Message-Id: <3B0082CC.109F4803@tassie.net.au>
Robert Vazan wrote:
> What do you do with nested patterns? I mean something like:
>
> { "foo\"bar" { ....; } (m@b}a\@z@ && do {...} ) ... }
>
> Or {}'s with few //'s and ""'s inside. I don't need to see
> into that string, just identify it. I don't want to write
> specialized parser, when 99% cases are so simple.
>
> /Robert
You may need to rephrase your question as I really have no idea what you mean.
If you have a pattern matching problem, the best approach is to do this:
1 Specify what you are trying to do and in what context.
2 Supply some REAL sample data demonstrating the problem data set. Real data is
vital as pattern matching is tailored around it.
3 Show us what you have tried, or if you do not know where to start, indicate
exactly what you want to achieve from your pattern.
If by some chance I have correctly interpretted that you want to find the
closing bracket in a nested bracket case such as:
'foo( () \( () ((\))))bar'
where the nesting is complicated by backslashed brackets then this sub will
return a regex that matches any complex bracket pattern.
# demo useage code
$search_string = 'foo( () \( () ((\))))bar';
($open) = $search_string =~ m/([\(\{\[\<])/; # get opening bracket
$opening_bracket = "\\$open"; # this interpolates to \( which is what we want
$matching_regex = &bracket_finder($opening_bracket, $search_string);
print "Bracket match failed :-(" unless $matching_regex;
$search_string =~ s/($matching_regex)//;
$bracket_set = $1;
print "$matching_regex\t$bracket_set\t$search_string\n";
sub bracket_finder {
# first we get the arguments
# note that the bracket pair in $open needs to be in the regex
# friendly form '\(' so that when interpolated into a regex it does not
# take on a non literal meaning
(my $open, my $string) = @_;
# initialise variables
my %bracket_pairs = qw| \( \) \[ \] \{ \} \< \> |;
my $regexp = "(?<!\\\\)";
my $open_count = 0;
my $found_backslash = 0;
my $close = (defined($bracket_pairs{$open})) ? $bracket_pairs{$open}
: die "Non bracket supplied as
arg to bracket_finder\n";
# now we will iterate through the string char by char
# we count the valid open and closing brackets in $open_count
# when this gets to zero we have finished
for my $i (0..length($string)) {
my $char = substr ($string, $i, 1);
# initially open_count is zero until we find the first opening bracket
next if ($open_count == 0 and "\\$char" ne $open);
# we use the found backslash flag to add the char immediately following
# it to our regexp in case it is a bracket, so we avoid short matching
if ($found_backslash) {
$regexp .= "\\$char.*?" if $char =~m/[\(\{\[\<\)\}\]\>]/;
$found_backslash = 0;
next;
}
# check $char for a backslash, set flag so we skip the next char
if ($char eq "\\") {
$found_backslash = 1;
next;
}
# for each opening bracket add the appropriate regex to find it
if ("\\$char" eq $open) {
$open_count++;
$regexp .= "$open.*?";
}
# for each closing bracket add the appropriate regex to find it, the
last one is different
if ("\\$char" eq $close) {
$open_count--;
$regexp .= ($open_count) ? "$close.*?" : "$close";
}
# exit the loop if we have a matched number of open and closed brackets
last unless $open_count;
}
return ($open_count == 0 ) ? $regexp : 0;
# note if open count is not equal to zero we have unmatched brackets
}
Cheers
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 18:28:55 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <3B008657.5E4FA84B@stomp.stomp.tokyo>
tadmc@augustmail.com wrote:
A brief random compilation:
Patronizing Lip Service:
________________________
>> This is *not* what _I_ am doing.
>> I am just the guy who is writing it down.
>> ...I am just the secretary that writes down the consensus of the group.
>> This is supposed to be (as close as is practicable) the concensus
>> of the group's participants, so your are _supposed_ to be
>> making suggestions :-)
Reality:
________
>> I cannot make the change you suggest.
>> I do not want to put Whys in here.
>> I do not want to do that.
>> But these aren't my guidelines....
>> There will be no vote....
>> I will not read nor feed the troll.
>> (her posts are dropped at my newsfeed level,
>> so I can't get them at all from my newsreader).
>> I will try to followup with some reasoning for things not adopted.
>> I do not believe that that is the concensus here....
>> I feel it would be gratuitous to bother with a URL...
>> No, not _here_ ....
>> If you mean 1) then I disagree.
>> If you mean 2) then I agree that it could be left out,
>> but I still don't want to leave it out.
>> I, personally, would like this moved up to the bossy "Must" section....
* sniffs *
Ewwww... do I smell rancid hypocrisy or is that
the smell of black jack boot polish?
Godzilla!
------------------------------
Date: Mon, 14 May 2001 20:38:33 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <3B00A4B9.E711326C@stomp.stomp.tokyo>
clpmisc@dfw.pm.org wrote:
(snipped)
> Outline
> Before posting to comp.lang.perl.misc
> Posting to comp.lang.perl.misc
> Social faux pas to avoid
There are appropriate ways to do develop a newsgroup
charter and, there are no other ways to do this. This
development of a charter should be done right, or not
at all.
If it is not to be done right, this FAQ could reside
on a person's server and links provided within an article
as is appropriate, with a statement or explanation it
is provided by an individual as a courtesy, much like
Mr. Boutell does in our sister group.
Correct development of a charter, not just a newsgroup
charter, has certain procedures and protocal. I have
participated in development of charters, many times,
related to education, such as group sponsers, clubs,
teams and the such. It must be done right or will be
forever tainted with controversy.
McCellan, your behavior is completely inappropriate.
You should bow out and ask for volunteers to handle
this, appropriately. You are biased, unfair and most
dictatorial in your approach. You have forfeited
any right to act as secretary. This is evidenced
by your own words posted to this newsgroup.
I have split up topics for a reason.
* Friendly Welcome Message *
> Before posting to comp.lang.perl.misc
> Posting to comp.lang.perl.misc
> Social faux pas to avoid
My reason for this is each topic should be discussed
individually, a request for comments provided, a rough
draft written upon what is deemed to be a concensus,
then a call for popular vote to approve. Volunteers
would be needed to discuss and formulate a rough
draft on behalf of everyone here.
Dividing charter topics into unique sections, provides
a high degree of organization and quickness in development.
One unique topic is discussed at a time, and no other.
A charter should be developed in planned stages.
After each section is developed and approved, a complete
charter is written, discussed, then a final version is
ratified by popular vote.
Voting is also an important issue, especially when email
addresses are involved. No vote cast via an anonymous
mail server, such as yahoo, mailcom, cutsey and others,
should be accepted. Only "real" email addresses should
be accepted and verified by inquiry and return verification.
Two people should handle this. One purpose for a team is
to be sure email actually makes it to someone. Another reason
is team effort increases odds of spotting false votes.
Inherently, the validity of voting cannot be questioned
when two, or more, are responsible for counting votes.
This task of developing a charter the right way, the
appropriate way, would be an easy task. This charter
is basically written already. However, there is a high
degree of controversy, which I contribute to McCellan
by abusing his position as "secretary" and by a select
few regulars whom have deemed it their right to write
this charter according to their personal preferences,
rather than a concensus of all regulars who elect to
participate. It is clear, some regulars are being
deliberately excluded by a variety of methods.
My personal opinion is Mr. Berry should write the
final charter, completely, then submit it for opinion.
He is well qualified for this task and, none will
disagree, a very straightforth honest person. This
would not be too difficult for him, mostly correcting
grammar errors, awkward sentences and, a task he is
most suited for, introducing diplomatic and polite
wording into this charter.
Mr. Schwartz and Abigail would be prime choices for
handling voting issues. Abigail is the best choice
to keep Randal on task and to make him behave himself.
All which is left, is some discussion, a bit of voting
and finding a place to store this charter. As odd as
this sounds, I believe McCellan would be pleased to
stored this charter on his server and allow links
to this charter. He has at least earned this right.
In closing, development of a group charter, although
not difficult, will take time. I am estimating about
four to six months, to do this the right way.
My services are volunteered. However, I will preemptively
bow out to respect popular opinion about me, which is
not exceptional. Nonetheless, I will help if asked.
Well? You people gonna do this right or be forever
submerged in controversy and ill will?
Godzilla!
------------------------------
Date: Tue, 15 May 2001 02:40:49 +0100
From: "bobnet" <bobnet604@hotmail.com>
Subject: sorting hash's
Message-Id: <3b0088ee$1@shiva.ukisp.net>
hiya,
Could someone point me at web resources detailing
sorting hashes of hashes, elaborate and complex records.
I've read all I could find in Programming, Advanced
Programming, the Cookbook and Algorithms with Perl
and pretty much got my head around it.
However 'strange' things keep happening and I wonder
what I might of missed.
thnx
bobnet
------------------------------
Date: Tue, 15 May 2001 03:41:03 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: sorting hash's
Message-Id: <x7ae4f9t3f.fsf@home.sysarch.com>
>>>>> "b" == bobnet <bobnet604@hotmail.com> writes:
b> hiya,
b> Could someone point me at web resources detailing
b> sorting hashes of hashes, elaborate and complex records.
b> I've read all I could find in Programming, Advanced
b> Programming, the Cookbook and Algorithms with Perl
b> and pretty much got my head around it.
b> However 'strange' things keep happening and I wonder
b> what I might of missed.
http://www.sysarch.com/perl/sort_paper.html
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Tue, 15 May 2001 01:29:11 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Taint
Message-Id: <slrn9g11j7.1a9.garry@zfw.zvolve.net>
On Mon, 14 May 2001 22:32:26 GMT, Dodger <dodger@necrosoft.net> wrote:
> "Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
> news:m3elts2fkh.fsf@mumonkan.sunstarsys.com...
>
> 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; }
That's what perlsec says to do, if you must. (Although the
short-circuit is superfluous, since the match can never fail.)
> 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.
Please exhibit the code that you claim fails in this way. This would
seem to indicate that you have a very broken perl.
$ cat try
#!/usr/local/bin/perl5.6.1
use warnings;
use strict;
$ENV{PATH} = "/bin";
print "$0: \$< = $<, \$> = $>\n";
# become root
$< = $>;
print "$0: \$< = $<, \$> = $>\n";
# relinquish privileges
$< = $> = getpwnam("nobody");
print "$0: \$< = $<, \$> = $>\n";
exec "./try_child", "try";
__END__
$ cat try_child
#!/usr/local/bin/perl5.6.1
use warnings;
use strict;
print "$0: \$< = $<, \$> = $>\n";
$< = $>;
my $file = shift; # tainted
# If taint checking, the next line will raise an exception...
open(my $fh, ">>$file") || warn "can't open '$file': $!\n";
# Let's attempt to gain back privileges
$> = 0;
$< = 0;
print "$0: \$< = $<, \$> = $>\n";
__END__
$ ls -l try try_child
-rwsr-xr-x 1 root staff 180 May 14 20:52 try*
-rwxr-xr-x 1 garry staff 237 May 14 20:54 try_child*
$ ./try
/dev/fd/4: $< = 100, $> = 0
/dev/fd/4: $< = 0, $> = 0
/dev/fd/4: $< = 60001, $> = 60001
./try_child: $< = 60001, $> = 60001
can't open 'try': Permission denied
./try_child: $< = 60001, $> = 60001
$
--
Garry Williams
------------------------------
Date: Tue, 15 May 2001 03:05:47 +0100
From: "muksca" <graphi@lineone.net>
Subject: URGENT: CGI program wanted!
Message-Id: <tg13coccc09731@corp.supernews.co.uk>
Sorry to ask here only for weeks now I have tried other groups and resources
to no avail.
Anyone here have or know of a perl script which does (or modification) the
following...
1. User uploads a file to server
2. Calls the CGI and prints out environment variables to a txt file (flat
file dB)
3. Creates a unique directory ON-THE-FLY and puts the upload into that
directory
4. Display a standard thank you page
Ideally each separate upload should be assigned its own directory and
preserve the original file name.
I have been looking around for ages now
Anyone?
--
NO NONSENSE professional Websites:
www.your-new-site.com
------------------------------
Date: Tue, 15 May 2001 03:08:44 +0100
From: "muksca" <muksca@hotmail.com>
Subject: Urgent: CGI program wanted
Message-Id: <tg13i8t5quo134@corp.supernews.co.uk>
Sorry to ask here only for weeks now I have tried other groups and resources
to no avail.
Anyone here have or know of a perl script which does (or modification) the
following...
1. User uploads a file to server
2. Calls the CGI and prints out environment variables to a txt file (flat
file dB)
3. Creates a unique directory ON-THE-FLY and puts the upload into that
directory
4. Display a standard thank you page
Ideally each separate upload should be assigned its own directory and
preserve the original file name.
I have been looking around for ages now
Anyone?
--
NO NONSENSE professional Websites:
www.your-new-site.com
------------------------------
Date: Tue, 15 May 2001 02:39:35 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: Urgent: CGI program wanted
Message-Id: <HF0M6.644$du2.61268@news.shore.net>
muksca <muksca@hotmail.com> wrote:
: Anyone here have or know of a perl script which does (or modification) the
: following...
[snip]
: I have been looking around for ages now
: Anyone?
: --
: NO NONSENSE professional Websites:
: www.your-new-site.com
Anyone else laugh when they saw this sig?
--Art
------------------------------
Date: Tue, 15 May 2001 04:37:21 +0100
From: "muksca" <muksca@hotmail.com>
Subject: Re: Urgent: CGI program wanted
Message-Id: <tg18odqmqb3046@corp.supernews.co.uk>
Do you actually have anything useful to contribute?
------------------------------
Date: Tue, 15 May 2001 03:33:45 GMT
From: Miguel Cruz <spam@un.u.nu>
Subject: Re: Urgent: CGI program wanted
Message-Id: <ts1M6.803$3n.41184@news.itd.umich.edu>
muksca <muksca@hotmail.com> wrote:
> Sorry to ask here only for weeks now I have tried other groups and resources
> to no avail.
> Anyone here have or know of a perl script which does (or modification) the
> following...
>
> 1. User uploads a file to server
> 2. Calls the CGI and prints out environment variables to a txt file (flat
> file dB)
> 3. Creates a unique directory ON-THE-FLY and puts the upload into that
> directory
> 4. Display a standard thank you page
If you tried to write it, I bet you could get some good help here.
miguel
------------------------------
Date: Mon, 14 May 2001 20:51:29 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: What is wrong with my Regular Expression?
Message-Id: <3B00A7C1.60950DAF@stomp.stomp.tokyo>
Ilmari Karonen wrote:
(body content snipped)
> Ilmari Karonen - http://www.sci.fi/~iltzu/
> Please ignore Godzilla / Kira -- do not feed the troll.
Mr. Karonen, I am asking something of you on
behalf of the entire newsgroup.
You have been displaying this highly inappropriate
signature file for over a year now. I am asking you
to discontinue doing this.
Your signature has no effect on me. However, your
signature file serves to set an exceptionally bad
example for all here and, for those who elect to
join this group. Your signature file serves only
one purpose; to incite hatred.
Is it your intent to have people think of you
as a promoter of hatred?
Your signature file is not a slam on me. It is
a slam on you. Your true message is,
"I am a total jerk."
Give this some thought. You are not performing
any beneficial service for this group with this
signature file of yours.
Godzilla!
------------------------------
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 902
**************************************