[13073] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 483 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 12 14:07:21 1999

Date: Thu, 12 Aug 1999 11:05:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 12 Aug 1999     Volume: 9 Number: 483

Today's topics:
    Re: array and file processing <habfan2@my-deja.com>
    Re: array and file processing <habfan2@my-deja.com>
    Re: Fastest form of an 'if' (Jack Applin)
    Re: Help - Split Function Blowing My Mind Away!! (Mike Kozlowski)
        Ignorant Newbie: Forbidden execution <mrice_deja@my-deja.com>
    Re: Ignorant Newbie: Forbidden execution (Steve Linberg)
    Re: Ignorant Newbie: Forbidden execution <rootbeer@redcat.com>
    Re: Moving a Perlscript from NT to LINUX <kbandes@home.com>
    Re: Nastiness contrary to the spirit of perl? <msouth@shodor.org>
    Re: Nastiness contrary to the spirit of perl? <tchrist@mox.perl.com>
        OFF: Opinions on Magazines <grichard@uci.edu>
    Re: p5p flamage (was Re: reference to object method) (Greg Bacon)
    Re: p5p flamage (was Re: reference to object method) <tchrist@mox.perl.com>
    Re: p5p flamage (was Re: reference to object method) <tchrist@mox.perl.com>
    Re: perl -splice - add an element/delete jatgirl@yahoo.com
    Re: perl on linux (James R. Goodfriend)
    Re: perl on linux <tchrist@mox.perl.com>
    Re: Perl Sockets on Linux <Scott.Wachtler@cdc.com>
    Re: Perl/SSI hacking mujali@my-deja.com
    Re: Perl/SSI hacking (Steve Linberg)
        Quick Question--OS Name <mahesh@zedak.com>
    Re: Quick Question--OS Name (Anno Siegel)
    Re: Reading from <DATA> more than once (John Porter)
        Regexp question <azielke@hotmail.com>
    Re: Regexp question (Andrew Johnson)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Thu, 12 Aug 1999 16:21:01 GMT
From: Teacher Guy <habfan2@my-deja.com>
Subject: Re: array and file processing
Message-Id: <7ous8v$b7o$1@nnrp1.deja.com>

In article <37B0780D.2C1B8C0C@cisco.REMOVETHIS.com>,
  Makarand Kulkarni <makkulka@cisco.REMOVETHIS.com> wrote:


> Do you want to find the top ten students and the average score
> of these top ten students for EACH course offered? If not
> then how are these results going to make sense.
> --


Hello.  Sorry about confusion.  My data is as follows:
structure : $name,$score,$testtotal,$course
Tom|40|50|science
Joe|12|45|math
Cindy|5|10|english
 ...... etc

I want to load data from file.  Calculate test averages for each record
and sort results, including average, to show the top ten test
averages.  It is important to maintain integrity of each record.

Processing the data structure is the problem.  I can't seem to
visualize how Perl processes the data.

Thanks for response.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 12 Aug 1999 16:41:37 GMT
From: Teacher Guy <habfan2@my-deja.com>
Subject: Re: array and file processing
Message-Id: <7outfv$c44$1@nnrp1.deja.com>



> Interesting assignment...if a bit unclear :
>
> What do you mean by "without screwing up order of other fields" ?

If I sort on a field do all the other fields of record sort in sync?

> I see no order in your example, except maybe in the input data itself.
> Do you want to sort by testscore, and then by order of appearance in
> your input data, or is that not required ?
>

sort on average test score, a calculation using input data

> And can the same student appear several times, e.g. for several
courses ?

Yes, a future consideration for sure.

>
> And should the average be the average of the ten top scores, or the
> average of all courses followed by the top 10 students ?

Top 10 average test (percent) results for all incoming data.


>
> Otherwise, you could just use something like this (with a couple of
> intermediate variables to make things a bit more understandable) :
>
> #!/usr/local/bin/perl -w
> while (<DATA>) {
>         chomp;
> # we don't seem to need the other fields for this assignment
> #        ($student,$testscore,$course) = split(/\|/);
>         $testscore = (split(/\|/))[1];
>         push(@scores,$testscore);
> }
> # check whether we have enough data
> if (@scores < 10) {
>         die "Insufficient data...\n";
> }
> # find the top 10 scores, assuming they're numerical
> @topscores = (sort {$b <=> $a} @scores)[0..9];
> print "The top 10 scores are : @topscores\n";
> # calculate the average
> $total = 0;
> foreach $score (@topscores) {
>         $total .= $score;
> }
> $ave = $total / 10;
> print "The average of these 10 scores is : $ave\n";
> print "Is that really what you wanted to know ?\n";
> exit;


MY DATA IS AS FOLLOWS:

stud1|4|10|course1
stud1|20|60|course2
stud1|50|80|course3
stud2|90|120|course1
stud2|8|10|course2
stud2|7|10|course3
stud3|85|180|course1
stud3|70|110|course2
stud3|62|80|course3
stud4|32|35|course1
stud4|6|15|course2
stud4|5|5|course3

Thus, $testave = $score/$tottest

then I need the $testave to serve as index to sort all incoming data.


> __DATA__
> stud1|10|course1
> stud1|9|course2
> stud1|8|course3
> stud2|9|course1
> stud2|8|course2
> stud2|7|course3
> stud3|8|course1
> stud3|7|course2
> stud3|6|course3
> stud4|7|course1
> stud4|6|course2
> stud4|5|course3
>
> But that is probably not what you're looking for, right ? :-)
>
> What you actually need (according to my ESP module) is
> to sort the students by their highest testscore, rather than
> sorting the testscores by themselves.
>

Yes, ESP is correct.  I need to calculate testscore averages and sort
incoming data based on these calcs.



> So, depending on what else you'll need to do with these
> data, you might use an array of arrays, a hash of hashes
> (e.g. $hash{$student}{$course}), a hash of arrays
> (e.g. $hash{$student} = ( [$course1, $score1], ...)), etc.

Everyone keeps talking about array of arrays and hash.  Not having much
luck applying LoL to my situation.  Data structures are my weakness.

>
> Have a look at perllol and perldsc for more information on
> how to build such structures... There are some nice examples.
>

I presume perllol is part of CPAN??



> Michel.
>


Thank you very much for the help and I'd appreciate any enlightenment
that you can offer.

Kiley


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 12 Aug 1999 16:47:18 GMT
From: neutron@fc.hp.com (Jack Applin)
Subject: Re: Fastest form of an 'if'
Message-Id: <7outqm$bpv$1@fcnews.fc.hp.com>

Gary O'Keefe (gary@onegoodidea.com) wrote:
> A keyboard was whacked upside Andrew Fry's head and out came:

> timethese(
>         $count, {
>                 'if ( $a ) { $c = $b }' => 'if ( $a ) { $c = $b; }',
>                 '$c = $b if ( $a )' => '$c = $b if ( $a );',
>                 '$c = $a && $b' => '$c = $a && $b;'
>         }
> );

That last one isn't the same--it will always assign something to $c,
even if $a is false.  Perhaps this would be better:

	$a && ($c = $b);


						-Jack Applin
						 neutron@fc.hp.com


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

Date: 12 Aug 1999 16:19:32 GMT
From: mkozlows@norman.ssc.wisc.edu (Mike Kozlowski)
Subject: Re: Help - Split Function Blowing My Mind Away!!
Message-Id: <7ous6k$h4u$1@news.doit.wisc.edu>

In article <MPG.121b9148ac744f3d989e33@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:

[ "my ($y) = @_;" -- Threat or Menace?]

>  But I would probably write that line thus:
>
>    my $y = shift;
>
>Assigning an array @_ to a one-element array slice ($y) rubs across the 
>grain, somehow.

Interesting.  I use that as my standard idiom for dealing with function
arguments.  It's simple, it's consistent with the general case (i.e.,
"my($x, $y, $z) = @_;"), and it works perfectly fine.

>So, in answer to Mike Kozlowski's question, each of those is 'wrong', 
>for some definition of 'wrong'.  

But we're using a stylistic, rather than a technical definition of wrong,
so my code's not secretly breaking under me.  Which allays my momentary
bit of mild panic.

-- 
Michael Kozlowski                                        
http://www.ssc.wisc.edu/~mkozlows/


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

Date: Thu, 12 Aug 1999 16:01:25 GMT
From: M. Rice <mrice_deja@my-deja.com>
Subject: Ignorant Newbie: Forbidden execution
Message-Id: <7our4d$aai$1@nnrp1.deja.com>

Hope this is the right forum. If not, apologies in advance!

So I am trying to run a perl script on my newly installed red hat linux
box. The directory structure looks like this:

/home/httpd
/home/httpd/html/
/home/httpd/cgi-bin/

I tried putting the .pl script into the cgi-bin directory and
consistently get a Forbidden error from apache (with specific page
requested or just directory) when I submit a request. I've tried this
command on the root:

chmod 755 cgi-bin

but to no avail.

I also looked in the srm.conf file and tried uncommenting some lines
referring to Perl, but that yielded a whole new crop of errors (I can
get if needed).

Is this is a possible solution: 1) mkdir cgi-bin under the html
directory 2) grant execute access to the world on it 3) and put the
file in the directory.

Any help would be greatly appreciated!


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 12 Aug 1999 13:44:08 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Ignorant Newbie: Forbidden execution
Message-Id: <linberg-1208991344080001@ltl1.literacy.upenn.edu>

In article <7our4d$aai$1@nnrp1.deja.com>, M. Rice <mrice_deja@my-deja.com>
wrote:

> Hope this is the right forum. If not, apologies in advance!

It's not.  Your question isn't about Perl, it's about CGI and Apache.  Try
comp.infosystems.www.servers.unix, and/or
comp.infosystems.www.authoring.cgi.  Good luck!

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
Be kind.  Remember, everyone you meet is fighting a hard battle.
print 'Just Another Perl ' . $perl_hierarchy[(USER+EXPERT)/2];


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

Date: Thu, 12 Aug 1999 10:54:31 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Ignorant Newbie: Forbidden execution
Message-Id: <Pine.GSO.4.10.9908121053420.7774-100000@user2.teleport.com>

On Thu, 12 Aug 1999, M. Rice wrote:

> I tried putting the .pl script into the cgi-bin directory and
> consistently get a Forbidden error from apache

Sounds like a webserver (mis)configuration problem.

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.

   http://www.perl.com/CPAN/
   http://www.perl.org/CPAN/
   http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
   http://www.perl.org/CPAN/doc/manual/html/pod/

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 12 Aug 1999 13:37:33 -0400
From: Kenneth Bandes <kbandes@home.com>
Subject: Re: Moving a Perlscript from NT to LINUX
Message-Id: <37B3065D.E9C59340@home.com>

Thomas Schmickl wrote:

> ... but do you know anything how to solve  the problem I mentioned ? Have
> you ever transfered a text from NT to LINUX ?

Well, yeah, I think Martien Verbruggen's solution was correct:

perl -pi -e 's/\015$//' filenames

The problem with NT files is the carriage returns (\015).  Unix wants only
line-feeds.  So just get rid of the carriage returns, which Martien's
one-liner does (it performs the substitution in a loop on every line and
updates the input files in place).

In the future, if you move the text files (not zipped) from NT to Unix using
ftp in ASCII mode (I), you'll be fine - it'll correct for that stuff.

Ken Bandes




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

Date: 12 Aug 1999 17:03:47 GMT
From: Mike South <msouth@shodor.org>
Subject: Re: Nastiness contrary to the spirit of perl?
Message-Id: <7ouupj$t1$1@inxs.ncren.net>

Just a note to all you guys that have paid your dues, paid our dues, and 
continue to pay our dues for us.  Thanks.  I consider perl and the "perl
community" to be one of the few redeeming examples of what heppens when
a lot of people try to do something together.  I appreciate what you
have given us, and the effort you continue to put in to helping people
get work done.  Yes, I have found the FAQ's confusing, examples terse
and inadequate, tones in the newsgroup nasty at times.  But I would
_never_ think to complain about what has been offered so freelly,
_particularly_ when I haven't taken the time to write a better
FAQ, compile clearer examples, or answer newbie questions more
gracefully myself.  I can't imagine the state of mind that would
allow such behavior.

And now, a story:  Once, I really needed the answer to a perl question.
I knew it should be in the FAQs somewhere.  I didn't want to dig 
through all of that.  I was tempted to simply post to clpm.  But not
only did I want to avoid the flames I would deserve, I just felt that
it was my infinitesimal contribution to the community to not take
people's time with an answer I could get myself.  So I looked, long
and hard, and several hours later I came up with the answer myself.
I was extremely pleased, not just to have the answer, but also to
have not committed the moral offense of wasting the time of people
who have given so much of it.  I was so pleased that I wanted to
post a message sharing my success, but couldn't resolve the 
recursive irony of that, so I just kept it inside.  And it has 
been there until today, when I thought that maybe tired eyes 
might like to see that at least some of the effort you've made
to _both_ give people the tools to get it themselves _and_
teach them that they should use the tools that they have been
freely given paid off at least once.

My advice to others who have problems with the docs, the way
questions are answered, or the language of regular expressions
is that, before you criticize the people that are giving this
to you freely, you _attempt_, just _once_, _attempt_ to 
write something better, answer a few questions yourself (but
make sure you point people to the FAQs, too!), or, better
still, create NPPERLWCOSDSNEAIWM and publish it so we can
point people to that instead.

mike

(that would be, "newbie proof practial extraction and report
language with completely obvious self documenting syntax
not even an idiot would misunderstand", btw)

or maybe that's what cobol is?...




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

Date: 12 Aug 1999 11:55:31 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Nastiness contrary to the spirit of perl?
Message-Id: <37b30a93@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    Mike South <msouth@shodor.org> writes:
:And now, a story:  Once, I really needed the answer to a perl question.
:I knew it should be in the FAQs somewhere.  I didn't want to dig 
:through all of that.  

Perhaps the first Perl program written by all Perl programmers should
be "grep", quickly followed by faqgrep, docgrep, etc.  :-)

--tom
-- 
    In the long run, every program becomes rococo, and then rubble.
                    -- Alan Perlis


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

Date: Thu, 12 Aug 1999 10:53:05 -0700
From: "Gabe" <grichard@uci.edu>
Subject: OFF: Opinions on Magazines
Message-Id: <7ov1f8$9e9@news.service.uci.edu>

I post this here only because there are a lot of knowledgeable computer
users here. Don't flame me.

I'm looking for a computer magazine for non computer morons. I'm tired of ZD
and their 'zines. Every issue it's the same damn things: shitty reviews of
hardware/software I'll never buy, the "latest" Windows tips, the "latest"
Linux hype, the 50 best this, the 10 greatest that, the "latest" internet
bandwidth solutions...you know the story.

I want a mag geared towards the knowledgeable hobbyist/professional which
deals more with issues in computing (programming, networking, web stuff, ai,
database design, etc) than with ratings and reviews for the ignorant.

Suggestions please?

Gabe




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

Date: 12 Aug 1999 17:24:32 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: p5p flamage (was Re: reference to object method)
Message-Id: <7ov00g$8cl$2@info2.uah.edu>

In article <MPG.121c8cb2607dde2f989e49@nntp.hpl.hp.com>,
	lr@hpl.hp.com (Larry Rosler) writes:

: In article <7oulg8$5uk$3@info2.uah.edu> on 12 Aug 1999 14:25:12 GMT, 
: Greg Bacon <gbacon@itsc.uah.edu> says...
:
: > People whine, gripe, and complain about p5p's attitude toward changes
: > to the Holiest of Holies, but I like it that way.  The fact that changes
: > to the core are subject to such scrutiny is a sign that people really and
: > truly care about Perl and its future.  Pumpkings could apply every patch
: > that crosses p5p as a matter of policy, but down that path lies NT. :-)
: 
: How does this purported policy and process relate to the 5.004 'while 
: (defined($line = <FILE>)) {' botch that I just posted a rant about?  How 
: much scrutiny did that change to the core receive?

Thanks for the Message-ID. :-)  For benefit of the discussion, I'll
quote it here:

> For a while, in perl 5.004, there was a warning about that 'problem',
> which could *never* occur in any real-life situation dealing with
> valid 'text files' (and if they aren't text files, why would one be
> reading them a 'line' at a time?).

All files aren't text files.  What about C<$/ = "0">?  That's admittedly
perverse and possibly contrived, but not outside the realm of
possibility.  The problem was really more of a sin of omission.  We
just didn't think to make C<while ($line = <HANDLE>) { ... }>
semantically identical to C<while (<HANDLE>) { ... }>.  The check for
definedness was easy to overlook (look how long it went unnoticed).

I'm just glad someone left the Salzenberg on long enough to find the
problem. :-)

: At least someone was thoughtful enough to fix it in the next release.

This was, at least in part, due to no small amount of bitching by Tom.
Nonetheless, I think we're all happy with the current situation with
regard to the situation in question.

I'm just glad the Christiansen squeaked loudly enough to call our
attention to the problem. :-)

Greg
-- 
Fenster: Treat me like a criminal, I'll end up a criminal.
Hockney: You are a criminal.
Fenster: Why you gotta go and do that? I'm trying to make a point.


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

Date: 12 Aug 1999 11:36:26 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: p5p flamage (was Re: reference to object method)
Message-Id: <37b3061a@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    Greg Bacon <gbacon@cs.uah.edu> writes:
:: At least someone was thoughtful enough to fix it in the next release.
:
:This was, at least in part, due to no small amount of bitching by Tom.
 ...
:I'm just glad the Christiansen squeaked loudly enough to call our
:attention to the problem. :-)

I seem to do a lot of that.  I wish a few other people were as
persnickety or tasteful :-) as me so that I could take some time 
off from unwavering vigilance. :-(

--tom
-- 
    "You can only measure the size of your head from the inside." --Larry Wall


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

Date: 12 Aug 1999 11:37:21 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: p5p flamage (was Re: reference to object method)
Message-Id: <37b30651@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    Greg Bacon <gbacon@cs.uah.edu> writes:
:The check for definedness was easy to overlook (look how long it went
:unnoticed).

It wasn't unnoticed--just unimportant in the collective eye.

--tom
-- 
 "VAX. For those who care enough to steal the very best."
     -- A microscopic message on the silicon chip inside
	one of Digital Equipment's often stolen computer designs.


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

Date: Thu, 12 Aug 1999 17:13:16 GMT
From: jatgirl@yahoo.com
Subject: Re: perl -splice - add an element/delete
Message-Id: <7ouvb2$des$1@nnrp1.deja.com>

My bad that I started another thread with in a thread :) oh well.
anyways, I'm very much thankful to the folks who kindly & intelligently
replied to my post. Your help was greatly appreciated.

Sincerly
JatGirl

In article <slrn7r4dv6.d88.abigail@alexandra.delanet.com>,
  abigail@delanet.com wrote:
> jatgirl@yahoo.com (jatgirl@yahoo.com) wrote on MMCLXXII September
> MCMXCIII in <URL:news:7ot2qe$29j$1@nnrp1.deja.com>:
>
> Why on earth is your posting masquerading as belonging in the thread
> named 'Renaming a hash key?'. You don't followup to any posting, you
> don't contribute to the thread, yet you copy an entire References:
> line.
>
> That's real bad netiquette. If you don't know how to post, don't post
> at all. Learn what the buttons do before you press them.
>
> [question snipped]
>
> I refuse to answer questions if you can't make proper postings.
>
> [References header fixed]
>
> Abigail
> --
>                  ACHTUNG! ALLES LOOKENSPEEPERS!
> Das Internet ist nicht fuer gefingerclicken und giffengrabben.  Ist
easy
> droppenpacket der routers und overloaden der backbone mit der spammen
und
> der mime-attachmenten.  Ist nicht fuer gewerken bei das dumbkopfen.
Das
> mausclicken sichtseeren keepen das bandwit-grabben hans in das pockets
> muss; relaxen und watchen der cursorblinken.
>
>   -----------== Posted via Newsfeeds.Com, Uncensored Usenet News
==----------
>    http://www.newsfeeds.com       The Largest Usenet Servers in the
World!
> ------== Over 73,000 Newsgroups - Including  Dedicated  Binaries
Servers ==-----
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 12 Aug 1999 16:02:44 GMT
From: GoodfriB@jntf.osd.mil (James R. Goodfriend)
Subject: Re: perl on linux
Message-Id: <7our74$g95$1@news1.rmi.net>

In article <Lqms3.610$wU.5297@news1.online.no>, mike@crusaders.no says...
>
>Ala Qumsieh <aqumsieh@matrox.com> wrote in message
>news:x3ywvv29qy5.fsf@tigre.matrox.com...
>> > perl -e 'while(<>){s/\cM//g;print}' < oldscript.pl > fixedscript.pl
>> Haven't heard of the -p and -n flags?
>
>Actually... No.
>
>> or even the -i flag?
>
>I know what it's for, but I haven't used it.
>
>> % perl -pi -e 's/\cM//g' oldscript.pl > fixedscript.pl
>

	perl's actually got a special character (\r) for the carriage reurn,
so you could just do this:

% perl -pie 's/\r//g' script.pl

	Note I'm not redirecting, since -i is going to change the script in 
place anyway.  If you want to save yet another keystroke, you probably don't 
need the 'g' at the end of the regexp.

				-Bob




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

Date: 12 Aug 1999 11:52:35 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: perl on linux
Message-Id: <37b309e3@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    GoodfriB@jntf.osd.mil (James R. Goodfriend) writes:
:	perl's actually got a special character (\r) for the carriage reurn,
:so you could just do this:
:
:% perl -pie 's/\r//g' script.pl

Nope, you just created a backup file named "script.ple" and tried
to run one named "s/\r//g".  Whoops.

--tom
-- 
Vah! Denuone Latine loquebar? Me ineptum. Interdum modo elabitur. 


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

Date: Thu, 12 Aug 1999 09:52:27 -0700
From: "Scott.R.Wachtler" <Scott.Wachtler@cdc.com>
Subject: Re: Perl Sockets on Linux
Message-Id: <37B2FBCB.C0A8E718@cdc.com>

I R A Darth Aggie wrote:

> On Wed, 11 Aug 1999 09:07:16 -0700, Scott.R.Wachtler
> <Scott.Wachtler@cdc.com>, in <37B19FB4.4C3AD4DF@cdc.com> wrote:
>
> [under linux]
> + it receives a Connection Refused. The "offending" line  is
>
> Many flavors of linux fire up tcpwrappers by default. Check your
> /etc/hosts.deny and /etc/hosts.allow to see how it is configured.
> It may be denying access to your port. And this is the sort of error
> you'd get.
>
> James
>
> --
> Consulting Minister for Consultants, DNRC
> The Bill of Rights is paid in Responsibilities - Jean McGuire
> To cure your perl CGI problems, please look at:
> <url:http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html>

I've been checking and double checking my network settings. Nothing is
being denied and I'm able to telnet in on port 25 and access my web page
on port 80. The problem seems to come only when I try to access sockets
via perl. Nothing seems to affect it.
   Thanks for the idea though.
      Scott



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

Date: Thu, 12 Aug 1999 16:31:55 GMT
From: mujali@my-deja.com
Subject: Re: Perl/SSI hacking
Message-Id: <7oustr$bm7$1@nnrp1.deja.com>

In article <elWr3.28447$k8.1203623@newscene.newscene.com>,
  "Michael D. Kirkpatrick" <mkirkpatrick@webbuilders.top.net> wrote:
> Try this:
>
> <IMG SRC="/cgi-bin/test.pl?VAR=IMAGE_PROTECTION_CODE&VALUE=43@3!ERT">
>
> Have your perl code handle a get request.  With that, you can pass
anything
> you want to the script.
>
> You can put this in the beginning of your perl script:
>
> if ($ENV{'REQUEST_METHOD'} eq 'GET') {
>  $querystring=$ENV{'QUERY_STRING'};
>  @pairs = split(/&/, $querystring);
>  foreach $pair (@pairs){
>   ($name, $value) = split(/=/, $pair);
>   $value =~ tr/+/ /;
>   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>   $query{$name} = $value;
>  }
> }
>
> if ($query{'VAR'} eq "IMAGE_PROTECTION_CODE"){&run_my_routine;}
>
> sub run_my_routine{
>     $my_var = $query{'VALUE'};
> ## do what ever.....
> }
>
> Remember, in Perl, it is very case sensitive for both variables and
their
> values....
> Hope this helps...
>
> <mujali@my-deja.com> wrote in message
news:7oa5v6$tts$1@nnrp1.deja.com...
> > Hello all,
> >
> >   Anyone out there willing to take a shot at this? I would really
> > appreciate any hints. Here in an index.shtml (SSI-enabled) file:
> >
> > <HTML>
> > <HEAD><TITLE></TITLE></HEAD>
> > <BODY>
> > <!--#SET VAR="IMAGE_PROTECTION_CODE" VALUE="43@3!ERT" -->
> > <IMG SRC="/cgi-bin/test.pl">
> > </BODY>
> > </HTML>
> >
> > Here is test.pl:
> >
> > #!/usr/local/bin/perl
> > print "Content-type: image/gif\n\n";
> > # ---- Debug code ----
> > open (TEMP, ">temp.txt");
> > while (($key, $val) = each %ENV) {
> > print TEMP "$key = $val<BR>\n";
> > }
> > close TEMP;
> > # --------------------
> > if ($ENV{'IMAGE_PROTECTION_CODE'} eq "43\@3!ERT") {
> >    open (IMAGE, "can't_get_me.gif") or die "$!";
> >    }
> > else {
> >      open (IMAGE, "dummy.gif") or die "$!";
> >      }
> > print <IMAGE>;
> > close IMAGE;
> >
> > Problem is that the Perl script can't access the variable set by the
SSI
> > SET command in the index.shtml file becuase it has a different
> > environment space (at least that's my thinking).  If I had called
the
> > script using an SSI INCLUDE or EXEC command, it would have no
problem
> > seeing $ENV{'IMAGE_PROTECTION_CODE'}. Basically, is there any hack I
can
> > employ to get this variable from mod_include through the Perl
script? (I
> > hope that makes sense.) Or, is there a better way to do this?
> >
> > The purpose of this setup is of course to implement rudimentary
image
> > "protection". I am just doing this as an exercise. I understand
someone
> > could still get the image from their cache, etc. Thanks for any
help.
> >
> >       - Mujtaba Ali
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Share what you know. Learn what you don't.
>

Thanks for the reply. The problem I see with this scenario is that the
visitor can just look at the HTML source and see what's going on.  With
SSI commands, they can't do that. Thanks anyways. I learned a few
interesting techniques at least.

        - Mujtaba Ali


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 12 Aug 1999 13:39:30 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Perl/SSI hacking
Message-Id: <linberg-1208991339300001@ltl1.literacy.upenn.edu>

In article <7oustr$bm7$1@nnrp1.deja.com>, mujali@my-deja.com wrote:

> Thanks for the reply. The problem I see with this scenario is that the
> visitor can just look at the HTML source and see what's going on.  With
> SSI commands, they can't do that.

That is not correct.  The HTML source is the output of the code.  Not the
code itself.

> Thanks anyways. I learned a few
> interesting techniques at least.

I hope you learned to use CGI.pm, not the hacked reinvent-the-wheel-poorly
approach of trying to parse the CGI parameters yourself.  It will add
years to your life.

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
Be kind.  Remember, everyone you meet is fighting a hard battle.
print 'Just Another Perl ' . $perl_hierarchy[(USER+EXPERT)/2];


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

Date: Thu, 12 Aug 1999 12:10:20 -0400
From: "Mahesh Swaminathan" <mahesh@zedak.com>
Subject: Quick Question--OS Name
Message-Id: <7ouro1$cpn@dfw-ixnews6.ix.netcom.com>

I am looking for a Perl function which would let me find which operating
system i am on. I am looking for a Perl equivalent of Java's
System.getProperty("osname").

Thanks.




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

Date: 12 Aug 1999 16:29:15 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Quick Question--OS Name
Message-Id: <7ousor$r8e$1@lublin.zrz.tu-berlin.de>

Mahesh Swaminathan <mahesh@zedak.com> wrote in comp.lang.perl.misc:
>I am looking for a Perl function which would let me find which operating
>system i am on. I am looking for a Perl equivalent of Java's
>System.getProperty("osname").

$osname = $^O;

or

use English;
$osname = $OSNAME;

Anno


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

Date: Thu, 12 Aug 1999 16:32:17 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Reading from <DATA> more than once
Message-Id: <slrn7r5toh.ggv.jdporter@min.net>

In article <37B28A67.78829549@dial.pipex.com>, Jason Holland wrote:
>
>What's the easiest way of re-reading the data segment? I've tried doing
>a sysseek() back to file position 0, but that doesn't work. It actually
>reads the program text instead of the data.

Well, if seek 0 puts you back too far, don't seek so far back!

In fact, you want to seek to the same point in the file that your
first reading of DATA started at.  This works:

	my $data_starts_at = tell DATA;

	my @first_reading = <DATA>;

	seek DATA, $data_starts_at, 0;

	my @second_reading = <DATA>;

after which you will find that @first_reading and @second_reading
have identical contents.

-- 
John Porter



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

Date: Thu, 12 Aug 1999 19:32:27 +0200
From: A Zielke <azielke@hotmail.com>
Subject: Regexp question
Message-Id: <37B3052B.5BAA6790@hotmail.com>

Hi,

I'm really getting a bit desperate. Have a look at this

#!perl -w
use strict;
$_ = '19990812';
my ($year,$month,$day) = /(\d{4})(\d{2})(d{2})/;
# they're all undef but why????
print "$year , $month , $day\n";

# taken from llama-book
$_ = 'This is a test';
# Why's this working then???
my ($first,$second) = /(\w+)\W+(\w+)/;
print "$first , $second\n";

When I did 'x ($year,$month,$day) = /(\d{4})(\d{2})(d{2})/' within
the debugger $year,$month,$day were all defined.... so what's the
deal????

Thanks for all hints,
   A.


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

Date: Thu, 12 Aug 1999 17:53:03 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Regexp question
Message-Id: <3SDs3.1333$dr6.30228@news1.rdc2.on.home.com>

In article <37B3052B.5BAA6790@hotmail.com>,
 A Zielke <azielke@hotmail.com> wrote:
! Hi,
! 
! I'm really getting a bit desperate. Have a look at this
[snip] 
! $_ = '19990812';
! my ($year,$month,$day) = /(\d{4})(\d{2})(d{2})/;
! # they're all undef but why????
                                           ^^^^
maybe they're undef because the pattern doesn't match...
I don't see 4 digits followed by 2 digits followed by
2 'd' characters in $_.

regards
andrew


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu. 

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


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