[22566] in Perl-Users-Digest
Perl-Users Digest, Issue: 4787 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 30 14:05:45 2003
Date: Sun, 30 Mar 2003 11:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 30 Mar 2003 Volume: 10 Number: 4787
Today's topics:
--->>> Ну очень интересная программулька.... wedweb@nm.ru
CGI syntax error? What syntax error? (Caie)
Re: CGI syntax error? What syntax error? <tassilo.parseval@rwth-aachen.de>
Re: CGI syntax error? What syntax error? <me@verizon.invalid>
Re: CGI syntax error? What syntax error? <idont@thinkso.net>
Re: CGI syntax error? What syntax error? <idont@thinkso.net>
Re: CGI syntax error? What syntax error? <nobody@dev.null>
Re: CGI.pm or roll-your-own? (Peter Scott)
Re: CGI.pm or roll-your-own? <wsegrave@mindspring.com>
Re: CGI.pm or roll-your-own? <dha@panix.com>
Re: CGI.pm or roll-your-own? <wsegrave@mindspring.com>
Re: CGI.pm or roll-your-own? <wsegrave@mindspring.com>
Re: CGI.pm or roll-your-own? <wsegrave@mindspring.com>
Re: help understand dereferencing <goldbb2@earthlink.net>
how to put in percent sign thingies <ericosman@rcn.com>
Re: how to put in percent sign thingies <tassilo.parseval@rwth-aachen.de>
Re: Multiple POSTS and GETS from one perl script <meanblue@rascalsdesign.biz>
Re: simple substitution also changes line endings <goldbb2@earthlink.net>
Re: suid not working (David Efflandt)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 30 Mar 2003 17:11:04 +0000 (UTC)
From: wedweb@nm.ru
Subject: --->>> Ну очень интересная программулька....
Message-Id: <b678f7$b9p$1@relay.cca.usart.ru>
Ну очень интересная программулька....
Это программа поможет заработать Вам деньги.
Загляните не пожалеете... http://66.220.27.21/fox/index.htm
Можете скачать демо версию по этой ссылке http://66.220.27.21/fox/klik_demo.zip (300 кБ).
Подробности найдете в архиве.
Удачи ВАМ....
------------------------------
Date: 30 Mar 2003 08:23:22 -0800
From: the_caie@hotmail.com (Caie)
Subject: CGI syntax error? What syntax error?
Message-Id: <87d7d0df.0303300823.1bc437ea@posting.google.com>
Hey wizards!
I'm doing my nut in over this one. Can you help? Sorry this is quite
a large chunk.
<SNIP>
# Determine if an E-mail address was entered on the previous screen
# If an E-mail address WAS entered, check it with the chkemail module
to see if valid
my $blank_string = '';
require 'chkemail.pl';
chomp($email_address);
if ($email_address ne $blank_string){
# If invalid, then print this, yet continue to run the program
if (&email_check($email_address) == 0){
print <<END_HTML;
<p>The E-mail address: $email_address is invalid. Results will not be
sent to this address. This screen will automatically refresh and take
you to the results of the run once completed.</p>
<p>Starting Internet matching via the GoogleAPI...</p>
</body>
</html>
END_HTML
# Return data and control to sub main
return(@$sentences, 1);
}
# Otherwise the E-mail address IS VALID, convey this, finish the
HTML
else{
print <<END_HTML;
<p>Results will be sent to: $email_address. This screen will also
automatically refresh and take you to the results of the run once
completed.</p>
<p>Starting Internet matching via the GoogleAPI...</p>
</body>
</html>
END_HTML
# Return data and control to sub main
return(@$sentences, $email_address);
} # end else email address invalid
# Otherwise NO E-mail address was entered, convey this and finish off
HTML
elsif ($email_address eq $blank_string){
print <<END_HTML;
<p>No E-mail address was entered into the previous form. This screen
will automatically refresh and take you to the results of the run once
completed.</p>
<p>Starting Internet matching via the GoogleAPI...</p>
</body>
</html>
END_HTML
# Return data and control to sub main
return(@$sentences, 1);
} # end else no email address
} # end if
</SNIP>
The errors being spat out are the last 12 lines of this code. The
script returns the following two error messages
syntax error at apd.cgi line 145, near "elsif"
syntax error at apd.cgi line 155, near "}"
Execution of apd.cgi aborted due to compilation errors.
There are no leading or trailing spaces around END_HTML and I cannae
see any typos. Put me out of my misery, if you can.
Caie
------------------------------
Date: 30 Mar 2003 16:57:24 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: CGI syntax error? What syntax error?
Message-Id: <b677lk$d1q$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Caie:
> I'm doing my nut in over this one. Can you help? Sorry this is quite
> a large chunk.
[...]
> The errors being spat out are the last 12 lines of this code. The
> script returns the following two error messages
>
> syntax error at apd.cgi line 145, near "elsif"
> syntax error at apd.cgi line 155, near "}"
> Execution of apd.cgi aborted due to compilation errors.
>
> There are no leading or trailing spaces around END_HTML and I cannae
> see any typos. Put me out of my misery, if you can.
Perl does not know about 'elsif'. It should be 'else if' instead.
Perhaps a small recapulation of 'perldoc perlsyn' wouldn't hurt.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Sun, 30 Mar 2003 17:35:39 GMT
From: "dw" <me@verizon.invalid>
Subject: Re: CGI syntax error? What syntax error?
Message-Id: <LVFha.12043$_14.6502@nwrdny02.gnilink.net>
"Caie" <the_caie@hotmail.com> wrote in message
news:87d7d0df.0303300823.1bc437ea@posting.google.com...
Deleting all lines except if, else, elsif, and braces helps show the error:
>
> if ($email_address ne $blank_string){
> if (&email_check($email_address) == 0){
> }
> else{
> } # end else email address invalid
> elsif ($email_address eq $blank_string){
> } # end else no email address
> } # end if
Your structure is wrong. You currently have an if...else...elsif structure
in an if structure when it looks like you want an if...else structure inside
an if...elsif structure.
You probably want to move the last brace
} # end if
up before your elsif
elseif ($email_address eq $blank_string) {
However, that elseif should just be an else anyway since it is always true
when the first if is false.
dw
------------------------------
Date: Sun, 30 Mar 2003 12:58:11 -0500
From: "Chris W" <idont@thinkso.net>
Subject: Re: CGI syntax error? What syntax error?
Message-Id: <vK-cndtXarW2rRqjXTWcow@comcast.com>
"Tassilo v. Parseval" wrote in message
> Also sprach Caie:
>
> > syntax error at apd.cgi line 145, near "elsif"
> > syntax error at apd.cgi line 155, near "}"
> > Execution of apd.cgi aborted due to compilation errors.
> >
> > There are no leading or trailing spaces around END_HTML and I cannae
> > see any typos. Put me out of my misery, if you can.
>
> Perl does not know about 'elsif'. It should be 'else if' instead.
> Perhaps a small recapulation of 'perldoc perlsyn' wouldn't hurt.
That's just not true. Perl knows elsif, and it works fine, if you code it
right. The problem is he has an 'else' before the 'elsif', and that's not
legal.
------------------------------
Date: Sun, 30 Mar 2003 13:06:01 -0500
From: "Chris W" <idont@thinkso.net>
Subject: Re: CGI syntax error? What syntax error?
Message-Id: <S9acnQmjTZKfrxqjXTWcqQ@comcast.com>
Sorry, I spoketh too soon! Can't find the error.
------------------------------
Date: Sun, 30 Mar 2003 18:13:17 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: CGI syntax error? What syntax error?
Message-Id: <3E87333D.3050803@dev.null>
Tassilo v. Parseval wrote:
>
> Perl does not know about 'elsif'. It should be 'else if' instead.
> Perhaps a small recapulation of 'perldoc perlsyn' wouldn't hurt.
>
> Tassilo
>
Ahem...
Here's a direct quote from perlsyn:
The following compound statements may be used to control flow:
if (EXPR) BLOCK
if (EXPR) BLOCK else BLOCK
if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK
------------------------------
Date: Sun, 30 Mar 2003 14:30:14 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <WbDha.340089$na.25914142@news2.calgary.shaw.ca>
In article <b64khs$1j9ee$1@ID-184292.news.dfncis.de>,
Gunnar Hjalmarsson <noreply@gunnar.cc> writes:
>> There's REALLY NO WIN for a hand-rolled CGI parsing code.
>
>To me it is, since
>1) I know what I need to know to do what I do, and
No, several people have pointed out that there are a number of things
you needed to do that you didn't know had to be done, like guarding
against DoS attacks.
>2) I haven't (yet) studied CGI.pm enough to feel comfortable with it.
Let me help:
use CGI qw(param);
my $form_input = param('form_input');
That's at least 90% of everything you need to do. It even handles
file uploads transparently in a quite brilliant way ($form_input
doubles as both the filename and a filehandle for reading the data
depending on how you use it).
The CGI.pm documentation is a bit long because it covers so many
things, but there are so many other guides and books around I don't
think it's hard to learn about param(). Most of the CGI.pm POD seems
to be about the HTML generating functions, which I abandoned for
HTML::Template some time ago.
The only other major things to know about param() are that in a list
context it will return a list of values for an input if it has
multiple values, and with no arguments it returns a list of the names
of parameters in the form.
For anyone to consider this amount of learning daunting is just
baffling to me. Yet people keep doing it. Maybe the CGI.pm
POD should be just one page showing how to use param(), and
everything else goes in a CGIguts page :-)
--
Peter Scott
http://www.perldebugged.com
------------------------------
Date: Sun, 30 Mar 2003 09:52:44 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b673tn$6p1$1@slb9.atl.mindspring.net>
"Peter Scott" <peter@PSDT.com> wrote in message
news:WbDha.340089$na.25914142@news2.calgary.shaw.ca...
The course of this thread reminds me that Tad McClellan often writes "Please
put the subject of your article in the Subject of your article."
Does anyone remember the OP's original question? From a Google Groups
search, the original question was
Greg Raven (greg at racquettech dot com)
U.S. Racquet Stringers Association
wrote:
"I've been working unsuccessfully at write a short subroutine that will
detect whether the CGI input is GET or POST, process the data
accordingly, and then allow the calling script to use the values. This
subroutine could then be called by the various CGI scripts we use on our
site."
"My inability to make such a simple subroutine work has lead me to wonder
if I should invest the time in attempting to learn how to use CGI.pm."
"If the group would be so kind, are the benefits of CGI.pm worth the
overhead?"
If Greg Bacon would kindly follow Tad's advice, he might get a response that
is helpful to him. OTOH, I see he checked out about 65 messages ago, perhaps
having given up on getting help here.
There have been some very interesting and informative side-threads that have
resulted from Greg's choice of subject.
Best to all.
Bill Segraves
------------------------------
Date: Sun, 30 Mar 2003 16:35:54 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <slrnb8e77a.er4.dha@panix2.panix.com>
In article <b673tn$6p1$1@slb9.atl.mindspring.net>, William Alexander
Segraves wrote:
>
> Does anyone remember the OP's original question? From a Google Groups
> search, the original question was
>
> Greg Raven (greg at racquettech dot com)
^^^^^
[snip question]
> If Greg Bacon would kindly follow Tad's advice, he might get a response that
> is helpful to him. OTOH, I see he checked out about 65 messages ago, perhaps
> having given up on getting help here.
I'm faily sure Greg *Bacon* doesn't actually need help with this issue.
:-)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Alaska is a large cold place with approximately six residents who
would inbreed if they found each other more attractive.
- Scott Adams
------------------------------
Date: Sun, 30 Mar 2003 10:38:09 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b676ia$uj1$1@slb2.atl.mindspring.net>
"William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
news:b673tn$6p1$1@slb9.atl.mindspring.net...
<snip>
> Greg Raven (greg at racquettech dot com)
> U.S. Racquet Stringers Association
>
> wrote:
>
> "I've been working unsuccessfully at write a short subroutine that will
> detect whether the CGI input is GET or POST, process the data
> accordingly, and then allow the calling script to use the values. This
> subroutine could then be called by the various CGI scripts we use on our
> site."
>
See _Perl and CGI for the World Wide Web_, by Elizabeth Castro, Appendix A,
Parsing Form Input, for the subroutine Parse_Form, an example of
"roll-your-own" form-parsing script. See
http://beta.peachpit.com/vqs/K5815/samples/index.html for the code.
That said (written), my advice to you, Greg, is to embrace the use of CGI.pm
instead of "roll-your-own". Think *modules*.
> "My inability to make such a simple subroutine work has lead me to wonder
> if I should invest the time in attempting to learn how to use CGI.pm."
>
Yes. Your investment of time in learning to use CGI.pm will be richly
rewarded.
> "If the group would be so kind, are the benefits of CGI.pm worth the
> overhead?"
>
In a word, yes.
Greg, if you'll do a Google Groups search for "cgi.pm or roll-your-own",
you'll find most of the on-topic responses in the first ten messages.
When you have a follow-up question related to your original query, I'd
suggest you pick a better subject line to ensure you get responses that are,
well, responsive to *your* concerns.
BTW, I like your web site. Looks good!
Cheers.
Bill Segraves
------------------------------
Date: Sun, 30 Mar 2003 11:00:24 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b6782a$iq9$1@slb6.atl.mindspring.net>
"David H. Adler" <dha@panix.com> wrote in message
news:slrnb8e77a.er4.dha@panix2.panix.com...
<snip>
> > If Greg Bacon would kindly follow Tad's advice, he might get a response
that
> > is helpful to him. OTOH, I see he checked out about 65 messages ago,
perhaps
> > having given up on getting help here.
>
> I'm faily sure Greg *Bacon* doesn't actually need help with this issue.
> :-)
Thanks, David.
I agree.
My sleep-deprived brain substituted *Bacon* in place of *Raven*. I should
have checked what I wrote before I sent it.
Cheers.
Bill Segraves
------------------------------
Date: Sun, 30 Mar 2003 11:03:49 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b6782b$iq9$2@slb6.atl.mindspring.net>
"William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
news:b676ia$uj1$1@slb2.atl.mindspring.net...
<snip>
> Greg, if you'll do a Google Groups search for "cgi.pm or roll-your-own",
> you'll find most of the on-topic responses in the first ten messages.
Also, Greg, a GG search for "Perl vs. Perl & CGI.pm " will show you a
year-old thread, in which the contributions from some of the luminaries of
this ng illuminate the issues in which you are interested.
Cheers.
Bill Segraves
------------------------------
Date: Sun, 30 Mar 2003 12:47:24 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: help understand dereferencing
Message-Id: <3E872DAC.65C07D3@earthlink.net>
chance@austin.rr.com wrote:
>
> Thanks everybody. I think I got it.
>
> The cool thing about perl is that a lot of the time you can get away
> with not always knowing exactly whats going on, and still get the job
> done. This seemed like on of those exceptions where I really did need
> to understand what was happening, so I appreciate help. Sorry the
> final solution was as lame as me not understanding/noticing that '='
> does in fact do a copy by value ... yes even for hashes.
>
> One last question and I'll stop pestering :)
>
> If I were to do the below, as Benjamin suggested, would that be thread
> safe? i.e. if test_sub gets called at the same time from two different
> threads, does each thread get its own copy of %test_hash, or are they
> going to step all over each other?
It should be thread safe if you use ithreads (which come with perl
version 5.8), but not thread-safe if you use 5.005threads.
> > Well, mostly not, but if you were to do:
>
> > sub test_sub($) {
> > our %test_hash;
> > local *test_hash = shift();
> > ...
> > }
>
> I have never used an $our variable. Mostly just becuase I have had
> to maintain too much crap in the universe with global variables, so
> I've got a very string globals-are-bad-gag-reflex. Even for throw
> away scripts.
>
> Not knowing understanding if/how/why $our variables are thread safe
> has been a pretty strong second reason not to use them.
If you're using ithreads, then any variable *not* marked as shared can
(even if it's global) be accessed in multiple threads without harm.
This is because each interpreter gets it's own copy of it.
> In case you can't tell .... I've done a decent amount of perl, but its
> always pretty much been throw aways scripts, even if they got pretty
> complicated. Now I might get opportunity to write a real application,
> you know, a program that has to run correctly more than once, and
> actually have other people look at .... so I'm kind of seeing the
> other side of perl for the first time.
Might I ask, what kind of application are you building, that needs
threads to work right?
> I used to think government was a necessary evil.
> I'm not so sure about the necessary part anymore.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Sun, 30 Mar 2003 11:50:10 -0500
From: Eric Osman <ericosman@rcn.com>
Subject: how to put in percent sign thingies
Message-Id: <3E872042.3040005@rcn.com>
Hi, I have a real question and a meta question.
The real question:
I have a subject line that I want to package up in the form
mailto:someone?subject=subject-line
but I have to put the appropriate percent-thingies in the
subject, for example if it has spaces and quotes in it,
example:
mailto:yahoo@yahoo.com?subject=hi%20there
Should I be writing the percentifier myself ? Or is there
a standard module to use ?
The meta question:
When I went to cpan.org and clicked on "browse" and attempted
to browse by category to find such a thing, I quickly ran into
something like
http://cpan.org/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/HTML/
but this list only seems to list by author's names which is
useless towards the goal of finding things by category.
So the meta question is how to really find things by category.
Thanks.
/Eric
------------------------------
Date: 30 Mar 2003 17:09:20 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: how to put in percent sign thingies
Message-Id: <b678c0$dmm$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Eric Osman:
> Hi, I have a real question and a meta question.
>
> The real question:
>
> I have a subject line that I want to package up in the form
>
> mailto:someone?subject=subject-line
>
> but I have to put the appropriate percent-thingies in the
> subject, for example if it has spaces and quotes in it,
> example:
>
> mailto:yahoo@yahoo.com?subject=hi%20there
>
> Should I be writing the percentifier myself ? Or is there
> a standard module to use ?
It's not extremely hard to do it yourself. A very conservative regex
(replacing more than actually would be needed) could look like this:
s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/ge;
This replaces any non-alphanums with their respective
hex-representation.
Or you simply use the uri_escape() function from the URI::Escape module.
> The meta question:
>
> When I went to cpan.org and clicked on "browse" and attempted
> to browse by category to find such a thing, I quickly ran into
> something like
> http://cpan.org/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/HTML/
> but this list only seems to list by author's names which is
> useless towards the goal of finding things by category.
>
> So the meta question is how to really find things by category.
Better go to http://search.cpan.org/. The main-categories are directly
accessible through this site. But searching for a few keywords is
probably more promising.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Sun, 30 Mar 2003 18:01:51 +0100
From: Andrew Newlands <meanblue@rascalsdesign.biz>
Subject: Re: Multiple POSTS and GETS from one perl script
Message-Id: <fh8e8vgimc97og06vl3jm9ldtb9dd6rjjq@4ax.com>
On Sun, 30 Mar 2003 14:45:33 +0200, "Tore Aursand" <tore@aursand.no>
wrote:
>On Sun, 30 Mar 2003 10:36:03 +0100, Andrew Newlands wrote:
>>> You mean fork()'ing?
>
>> possibly...this is what I am trying to determine. Does fork()ing allow
>> you to post data to another script while continuing to run the one you
>> are on?
>
>Pretty irrelevant; POST'ing has something to do with the behaviour of the
>HTTP protocol. As I understand it, you just need to pass a set of
>arguments to your script. Wether you do it CGI wise or not, is up to you.
> As long as you're using CGI.pm, there's no problem what-so-ever, as it's
>all about reading data from STDIN anyways.
>
>See 'perldoc -f fork' and 'perldoc CGI' for more information.
I know how to pass data to scripts using CGI.pm, however Iwant to
pass data to a script and then continue processing the script that
passed the data...
I have been told about the system function, now the first argument is
the filename of the script that you wish to run, what can I do with
the other arguments? Is this function what I am looking for? can it be
used to run another script while my first is being run? Can I pass
data for varialbles in the second script?
Thanks for your time :)
------------------------------
Date: Sun, 30 Mar 2003 12:58:55 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: simple substitution also changes line endings
Message-Id: <3E87305F.57F67C7F@earthlink.net>
Tuang wrote:
>
> Benjamin Goldberg <goldbb2@earthlink.net> wrote :
> >
> > > > However, you would be better off if it were opened in the right
> > > > mode to begin with; thus, write your script as:
> > > >
> > > > #!/cygdrive/c/Perl/bin/perl -w -i.bak -p
> > > > use open IN => ":raw", OUT => ":raw";
> > > > # insert processing code here:
> > > > y/A/X/;
> > > > __END__
> > >
> > > I tried this (inserting the "use ..." line, and without any
> > > "binmode ..." line) and it didn't work. I didn't get any errors or
> > > warnings, but it still converted 0A line endings to 0D 0A.
> >
> > Strange. I don't know why it didn't work.
>
> And I spoke too soon when I said that "binmode ARGVOUT;" was working.
> It turns out that my problem of having it convert my unix (LF) text
> files to dos (CR-LF)has been fixed. Unix files now stay Unix, but my
> DOS files now convert to Unix!
That's because 'binmode ARGVOUT' only prevents "\n" from being converted
to CRLF on output.
If you want CRLF to *not* be converted to "\n" on input, then you'll
need to do 'binmode ARGV'.
However, this will only take place *after* the first line has been read
from it. So, the first line of a DOS file will end up with a unix
newline (though the rest of the lines will be correct).
If 'use open ...' had worked, you wouldn't have that problem.
[snip]
> So I'm still looking for generic filter wrapper code that I can reuse
> on all platforms that support Perl to process any arbitrary sequence
> of bytes and have it make only the changes I specify to those bytes
> and no other.
If the open pragma worked, then that would be the solution.
Since it doesn't, then you can't use the -i switch for in-place edit,
and have to do it yourself.
#!/cygdrive/c/Perl/bin/perl -w
use strict;
for my $orig (@ARGV) {
open( my($ifh), "<", $orig )
or die "Couldn't open $orig for reading: $!";
open( my($ofh), ">", "$orig.new" )
or die "Couldn't open $orig.new for writing: $!";
binmode $_ for $ifh, $ofh;
while( sysread $ifh, $_, 8192 ) {
tr/A/X/;
print $ofh;
}
close($ifh) or die "Error closing $orig: $!";
close($ofh) or die "Error closing $orig.new: $!";
rename($orig, "$orig.new")
or die "Error renaming $orig.new as $orig: $!";
}
__END__
> Is this extraordinarily difficult in Perl or is it just difficult for
> me. ;-)
The problem is that when you configured and compiled perl, you told it
to convert between CRLF and "\n". If you hadn't done that, you wouldn't
be having this problem.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Sun, 30 Mar 2003 14:55:14 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: suid not working
Message-Id: <slrnb8e1ah.rbh.efflandt@typhoon.xnet.com>
On Sat, 29 Mar 2003, Phil Langerholc <root@localhost.spam.me.not> wrote:
> I am having a problem with Perl trying to suid on AIX 4.3.3, ML is 11. I
> am using the perl that comes with AIX , 5.005_03 because I have several
> different customer sets I support and they want the "vendor supplied"
> version on their systems.
>
> I've Googled and not found too much on this for AIX aside from some overflow
> vulnerabilities in pervious versions of AIX.
You did not mention set user, group and permissions of script (typically
4755 for suid). If you expect a Perl script to run suid, then suidperl
has to be suid root (is NOT by default due to security concerns). If
suidperl is suid root and suid root script is run by normal user:
#!/usr/bin/perl -wU
$ENV{PATH} = '';
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
system("/usr/bin/whoami");
print "EUID $>\tUID $<\nEGID $)\tGID $(\n";
$< = $>; $( = $) = 0;
system("/usr/bin/whoami");
print "EUID $>\tUID $<\nEGID $)\tGID $(\n";
Results for me in Linux:
root
EUID 0 UID 501
EGID 503 500 100 80 503 GID 503 500 100 80 503
root
EUID 0 UID 0
EGID 0 500 100 80 503 GID 0 500 100 80 503
--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
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 4787
***************************************