[19026] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1221 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 30 00:05:31 2001

Date: Fri, 29 Jun 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: <993873907-v10-i1221@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 29 Jun 2001     Volume: 10 Number: 1221

Today's topics:
    Re: Code Review Needed! (Craig Berry)
    Re: Code Review Needed! <krahnj@acm.org>
    Re: coding technique - how would you do this? (TuNNe|ing)
    Re: converting shell "sort" command to perl.. <krahnj@acm.org>
    Re: Create unique file in dir? (Tony L. Svanstrom)
    Re: Create unique file in dir? <ren@tivoli.com>
    Re: diff btw. open("|-") && pipe? was: Re: how can i ge <ren@tivoli.com>
    Re: diff btw. open("|-") && pipe? was: Re: how can i ge <ren@tivoli.com>
        Faster yet way to count lines in a file (or at least co (R. McGillis)
    Re: getting a defined value from a html page (TuNNe|ing)
    Re: How to install Math-Round on windows <randy@theory.uwinnipeg.ca>
    Re: Is the Perl working...or what have  I messed up now (gail pickens-barger)
    Re: limiting cgi input from specific IP's (Craig Berry)
        newbie directory exists? question <"goodrow"@opencity. com>
    Re: newbie directory exists? question <krahnj@acm.org>
    Re: newbie directory exists? question (Clinton A. Pierce)
    Re: Newbie question: What's the opposite of chop? <qumsieh@sympatico.ca>
        Passing Large Values via GET <bcoon@sequenom.com>
    Re: Passing Large Values via GET (Clinton A. Pierce)
    Re: Perl from VXML <howard@brazee.net>
    Re: problems with mod_perl <randy@theory.uwinnipeg.ca>
    Re: pull out last line in a text file <qumsieh@sympatico.ca>
    Re: regular expression problem <bart.lateur@skynet.be>
    Re: unix `ps` <jeneag@home.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 29 Jun 2001 23:28:31 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Code Review Needed!
Message-Id: <tjq3ovifjioaeb@corp.supernews.com>

Dave Hoover (redsquirreldesign@yahoo.com) wrote:
: Craig Berry wrote...
: > Uri Guttman (uri@sysarch.com) wrote:
: > : that is one reason i almost always run tar ztvf foo.tar.gz on tarballs
: > : of unknown origin. it is amazing how many don't have a parent dir they
: > : create and they would untar all their files into the current dir. what
: > : were those people thinking when they made that tarball?
: > 
: > Your question contains a hidden assumption. :)
: 
: Hey, it was the first tarball I've ever made, I was literally reading
: the GNU tar and gzip manpages as I was making it. I'll readily admit
: I'm a newbie which is why I was asking for a code review in the first
: place.

Sorry, didn't mean to knock you in particular.  Everybody is a newbie at
every new task at first.  I meant to cast aspersions on more experienced
folks who continue to do this; the generic 'those people' to whom Uri
referred.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Magick is the art and science of causing change in conformity
   |   with Will."  - Aleister Crowley


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

Date: Sat, 30 Jun 2001 03:43:26 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Code Review Needed!
Message-Id: <3B3D4AE5.457F506C@acm.org>

Dave Hoover wrote:
> 
> John W. Krahn wrote ...
> 
> > sub convertApos {
> >     for ($s->{param}{title}, $s->{param}{summary},
> > $s->{param}{keywords}) {
> >         s/\Q'/&#039\E/g; # Converting apostrophe
> >           ^^       ^^
> >     }
> > }
> >
> > The "\Q" and "\E" aren't needed and the "\E" is in the wrong place
> > anyways. (also in sub formatTerms)
> 
> Noted.  Thanks for your time John.  This is exactly the kind of
> feedback I was hoping to get.

From Soapbox.pm

###############################################
# Cleaining and preparing terms for searching #
# action: assigning to $s->{terms}	      #
###############################################
sub formatTerms {
    my $s = shift;
    my @search = split(/[^\w']+/, $s->{param}{search});
#                         ^^^
# @search contains only \w and ' characters.

    for (@search) {
        unless (/^\W+$/) {

# This only lets \w characters through, strings with an ' in them don't
get this far.

            s/\Q'/&#039\E/g; # Converting apostrophe

# The substitution does nothing, no apostrophes.

            push(@{$s->{terms}}, $_)
        }
    }
}


sub formatTerms {
    my $s = shift;
    my @search = $s->{param}{search} =~ /([\w']+)/g;

    for (@search) {
        s/'/&#039/g; # Converting apostrophe
        push @{$s->{terms}}, $_;
    }
}



John
-- 
use Perl;
program
fulfillment


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

Date: Sat, 30 Jun 2001 03:29:12 GMT
From: troll@gimptroll.com (TuNNe|ing)
Subject: Re: coding technique - how would you do this?
Message-Id: <3b3d623a.19186361@news>

Thanks.
I did manage to run across CGI::FastTemplate last night. For some
reason I've been avoiding modules, guess I'll have to get past the "do
it myself" phase.

I just checked the Troll thing, that's funny. I'll have to get another
email address.

Regards,
Jason LeBlanc
http://www.gimptroll.com


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

Date: Sat, 30 Jun 2001 00:00:51 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: converting shell "sort" command to perl..
Message-Id: <3B3D16BA.40E46CCE@acm.org>

Patrick Erler wrote:
> 
> [snip]
> 
> only the simplest thing with this code i don't get solved right now.. how
> should this line look like correctly?
> 
> $#ARGV >= 1 or die "Usage:\n\t$0 [logfile]\n";

@ARGV == 1 or die "Usage:\n\t$0 [logfile]\n";



John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 29 Jun 2001 23:03:59 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Create unique file in dir?
Message-Id: <1evsiuq.1dxtn9lleeesaN%tony@svanstrom.com>

Craig Berry <cberry@cinenet.net> wrote:

> Tony L. Svanstrom (tony@svanstrom.com) wrote:
> : Personally i use time-pid-[4 random numbers], if that fails then the you
> : most likely have a lot more serious server-related problems to deal with
> : then non-unique files. Besides, since you lock the file nothing bad will
> : happen anyways...
> 
> I'd prefer something deterministic (I know, I'm obsessive).  The FAQ
> answer (perldoc -q temp, as suggested in another response) involving POSIX
> tmpnam and sysopen seems to be the right course.  I missed finding it
> because my intended use is not as a temporary file.

well, for time-pid to fail you need to have (dependin on the set up on
the machine, of course) more than 10'000 processes running at the same
time, and you have to be so unlucky that, if things work at all then
(anyone geekier than me that knows?), that your script has the same pid
as the first one... and then adding four random numbers/characters... It
just won't happen.


        /Tony
-- 
the truth is dead, faith is gone, reality killed... ruled by the plastic
laws of modern life we're pushed towards the hell of personal doubt,
betrayal, hate, lust and murder... the now has become an illusion, a
paradise of a dead tomorrow... (c)2000-2001 tony@svanstrom.com


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

Date: 29 Jun 2001 18:12:49 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Create unique file in dir?
Message-Id: <m3sngiriby.fsf@dhcp9-173.support.tivoli.com>

On Fri, 29 Jun 2001, tony@svanstrom.com wrote:

> Craig Berry <cberry@cinenet.net> wrote:
> 
>> Tony L. Svanstrom (tony@svanstrom.com) wrote: : Personally i use
>> time-pid-[4 random numbers], if that fails then the you : most
>> likely have a lot more serious server-related problems to deal with
>> : then non-unique files. Besides, since you lock the file nothing
>> bad will : happen anyways...
>> 
>> I'd prefer something deterministic (I know, I'm obsessive).  The
>> FAQ answer (perldoc -q temp, as suggested in another response)
>> involving POSIX tmpnam and sysopen seems to be the right course.  I
>> missed finding it because my intended use is not as a temporary
>> file.
> 
> well, for time-pid to fail you need to have (dependin on the set up
> on the machine, of course) more than 10'000 processes running at the
> same time, and you have to be so unlucky that, if things work at all
> then (anyone geekier than me that knows?), that your script has the
> same pid as the first one... and then adding four random
> numbers/characters... It just won't happen.

Until your code becomes multi-threaded on a high transaction-per-
second system.  Arbitrary restrictions should be avoided if possible
-- particularly when the avoidance mechanism is straight-forward.

(And no, I don't know if the POSIX solution is thread-safe, but that's
not the point.  The point is that you never know what the future
holds, so putting in unnecessary restrictions should be avoided.)

-- 
Ren Maddox
ren@tivoli.com


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

Date: 29 Jun 2001 16:52:20 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: diff btw. open("|-") && pipe? was: Re: how can i get the output of a forked child?
Message-Id: <m3zoarq7hn.fsf@dhcp9-173.support.tivoli.com>

On 29 Jun 2001, ren@tivoli.com wrote:

> On Fri, 29 Jun 2001, goldbb2@earthlink.net wrote:
> 
>> No there isn't really much difference between this and an explicit
>> fork/pipe, but using open is less code, and is easier on the eyes.
>> Plus, neither parent nor child has to remember to close one end of
>> the pipe after forking.
> 
> The other difference being that the child no longer has access to
> the parent's STDIN, which is usually a good thing. :)

(Or STDOUT, depending on which of "-|" or "|-" are used....)

-- 
Ren Maddox
ren@tivoli.com


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

Date: 29 Jun 2001 16:09:52 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: diff btw. open("|-") && pipe? was: Re: how can i get the output of a forked child?
Message-Id: <m38zibro0v.fsf@dhcp9-173.support.tivoli.com>

On Fri, 29 Jun 2001, goldbb2@earthlink.net wrote:

> Thomas Schulze-Velmede wrote:
>> 
>> In the camel book I found another way to talk to your child:
>> $pid = open(PIPEHANDLE, "-|");
>> 
>> Is there any difference between using the pipe-command and that
>> open(.."|-") / open(..."-|")-solution? It seems to be the same.
> 
> No there isn't really much difference between this and an explicit
> fork/pipe, but using open is less code, and is easier on the eyes.
> Plus, neither parent nor child has to remember to close one end of
> the pipe after forking.

The other difference being that the child no longer has access to the
parent's STDIN, which is usually a good thing. :)

-- 
Ren Maddox
ren@tivoli.com


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

Date: Fri, 29 Jun 2001 15:25:21 -0700
From: rick@library.ucsd.edu (R. McGillis)
Subject: Faster yet way to count lines in a file (or at least cooler)
Message-Id: <rick-2906011525210001@cul89-158.ucsd.edu>

I use the following to count lines in a file:


!#/usr/local/bin/perl -n

END{print "$.\n"};


Thats it! (Also assuming lines delineated by "\n").
Note that this is done from the command line, i.e. you would type from the
command prompt:  > "this_program.pl" "name_of_file_to_count" and you will
get your answer. Without the END, you will get a column of numbers; one
for each line in the file. END forces only the number of the last line to
get printed.


-R.M.


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

Date: Sat, 30 Jun 2001 03:43:08 GMT
From: troll@gimptroll.com (TuNNe|ing)
Subject: Re: getting a defined value from a html page
Message-Id: <3b3d65f5.20142157@news>

#!/usr/bin/perl -w

open(FILE,"newsletter.htm");
	while(<FILE>) {
		$temp .= $_;
	}
close(FILE);
print $temp =~ /\<Temperatuur\>(.+)\<\/Temperatuur\>/s;


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

Date: Fri, 29 Jun 2001 21:44:33 -0500
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: How to install Math-Round on windows
Message-Id: <9hjeuf$dpo$1@canopus.cc.umanitoba.ca>

"keng" <keng@spinalfluid.com> wrote in message
    news:9hhk0j$pdf$1@coco.singnet.com.sg...

> i need to use Nearest in the Math-Round module but cannot/ don't know how
to
> install using ppm on win98. Can anyone help me?

ActiveState comes with a very good set of docs, including FAQs - in
this there's a discussion of using ppm for installing modules, as
well as directions on how to install modules manually.

best regards,
randy kobes





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

Date: 29 Jun 2001 20:49:41 -0700
From: gaileee@yahoo.com (gail pickens-barger)
Subject: Re: Is the Perl working...or what have  I messed up now? - happy dance
Message-Id: <b65ab7bb.0106291949.50cf527e@posting.google.com>

> You need to add a content type print to your script. Lack of
> this content type print will not cause your script to fail
> to return results to your shtml page but will generate an
> error message within your server's log record.
> 
> No promises on correcting your problems.
> 
> Change your cgi script to:
> 
> 
> #!/usr/local/bin/perl
> 
> print "Content-type: text/plain\n\n";
> print "Hello World!";
> exit;
>

Thank you!  I did this to my hello.cgi file.  I'm going to need to
study syntax (quite a bit)!
> 
> 
> Change your server side include call to:
> 
> <!--#exec cgi="gail/hello.cgi" -->

Did that.  Surprizingly, when I had access to the unix/shell the space
worked, but that could have been a different version of perl too.
> 
> <!--#exec cmd="gail/hello.cgi" -->
> 
> 
This didn't work for me.  I took it out.

> Double check your path. You may need to use
> a full path to satisfy your server's specific
> configuration needs. My guess is, based on
> information you are giving, your call should be:
> 
> <!--#exec cgi="hello.cgi" -->

Right again.  Had to take out the gail, and tried other combinations
of pathways and the error log quit loggin errors....
> 
> Your script resides in the same directory as your
> shmtl file. No need to include "gail/" in your call,
> unless a full path is needed per server configuration.
> 
So your suggestions and my permutations/combinations worked.  Thank
you!

Do I need to suggest anything to my ISP?  (Yeah, quit taking my
calls!)
Perl-ing away...

Gail P-B.


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

Date: Fri, 29 Jun 2001 23:30:20 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: limiting cgi input from specific IP's
Message-Id: <tjq3scnnb0eb43@corp.supernews.com>

news.sohoskyway.com (jestersi@metacrawler.com) wrote:
: >  --*--  "Magick is the art and science of causing change in conformity
: >    |   with Will."  - Aleister Crowley
: You should read the book "Satan wants me" is a good read and some of the
: plot has to do w/mr. crowley
: although they kinda depict him as a fat heroine addict.

Quite likely because he was, in fact, a fat heroin addict.  Among many,
many other things, of course.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Magick is the art and science of causing change in conformity
   |   with Will."  - Aleister Crowley


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

Date: Fri, 29 Jun 2001 20:58:29 -0400
From: Jason Goodrow <"goodrow"@opencity. com>
Subject: newbie directory exists? question
Message-Id: <9hj80m$60i$1@news.panix.com>

Hi Usenet - feable minded newbie here

I want to open a directory for reading if it exists, if not, create it
and open it.

if (opendir (NEWDIR, $WEB{newdir}) = 0)  {
mkdir $WEB{newdir}, 755;
opendir (NEWDIR, $WEB{newdir});}

I also tried
opendir (NEWDIR, $WEB{newdir}) or
{
mkdir $WEB{newdir}, 755;
opendir (NEWDIR, $WEB{newdir});
}

parenthetically - can I use a block statement after a success check?

I know I'm missing the easy stuff -

thanks for any info,
goodrow@panix.com




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

Date: Sat, 30 Jun 2001 01:31:47 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: newbie directory exists? question
Message-Id: <3B3D2C06.8533DAA7@acm.org>

Jason Goodrow wrote:
> 
> Hi Usenet - feable minded newbie here
> 
> I want to open a directory for reading if it exists, if not, create it
> and open it.
> 
> if (opendir (NEWDIR, $WEB{newdir}) = 0)  {
> mkdir $WEB{newdir}, 755;
> opendir (NEWDIR, $WEB{newdir});}
> 
> I also tried
> opendir (NEWDIR, $WEB{newdir}) or
> {
> mkdir $WEB{newdir}, 755;
> opendir (NEWDIR, $WEB{newdir});
> }
> 
> parenthetically - can I use a block statement after a success check?
> 
> I know I'm missing the easy stuff -

unless ( -d $WEB{newdir} ) {
    mkdir $WEB{newdir}, 755 or die "Cannot create $WEB{newdir}: $!";
    }
opendir NEWDIR, $WEB{newdir} or die "Cannot open $WEB{newdir}: $!";



John
-- 
use Perl;
program
fulfillment


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

Date: Sat, 30 Jun 2001 01:52:39 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: newbie directory exists? question
Message-Id: <Hha%6.142041$DG1.23787585@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <9hj80m$60i$1@news.panix.com>,
	Jason Goodrow <"goodrow"@opencity. com> writes:
> Hi Usenet - feable minded newbie here
> 
> I want to open a directory for reading if it exists, if not, create it
> and open it.
> 
> if (opendir (NEWDIR, $WEB{newdir}) = 0)  {
> mkdir $WEB{newdir}, 755;
> opendir (NEWDIR, $WEB{newdir});}

Uh.. Why not code the problem just as you described it?

	$dir="/Your/pathname/here";
	if (! -d $dir) {
		mkdir $dir, 0755 or die "Can't create directory $dir: $!";
	}
	opendir(D, $dir) || die "Cannot open directory $dir: $!";

-- 
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org                Perl Developer's Dictionary
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Fri, 29 Jun 2001 22:45:13 -0400
From: "Ala Qumsieh" <qumsieh@sympatico.ca>
Subject: Re: Newbie question: What's the opposite of chop?
Message-Id: <F_a%6.8732$lp3.759400@news20.bellglobal.com>


"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:3b3ac213$1@news.microsoft.com...
> "Richard Wellum" <rwellum@cisco.com> wrote in message
> news:3B3A71F0.2A8DEFE6@cisco.com...
> At least two issues here
>
> > I used chop after reading a file to an array, to remove the "\n"'s, so I
> > can process the array:
>
> You may want to use chomp instead of chop, it is much safer.
>
> > Now I have finished my manipulation of the array, and want to write this
> > array back to the file. How to I add "\n"'s back to the end of each line
> > in my array?
> >  $ctr=0;
> >  foreach $some (@raw_data)
> >  {
> >      @raw_data[$ctr]="$some\n";
> >      $ctr++;
> >  }
>
> Why not just
>     $some = "$some\n"
> inside of the loop (forget about the $crt, it complicates things
> unnecessary)?

It is unnecessary to do that. You can use Perl's special $\ variable
(checkout perlvar) to automagically add newlines to your print() statements:

    $\ = "\n";
    for my $line (@raw_data) {
        print $line;
    }

Note that $\ does NOT affect the behaviour of printf().

--Ala





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

Date: Fri, 29 Jun 2001 18:03:43 -0700
From: BCC <bcoon@sequenom.com>
Subject: Passing Large Values via GET
Message-Id: <3B3D256F.FA780B64@sequenom.com>

I have run into a small problem with one of my scripts.  In one user
input form, users can enter a large list of numbers (8000 or so) which
are processed via post and a mysql query into a result set.  This is all
cool.

But to view results from 8000 queries, I implemented pagination, which
are simply links back to the same cgi with sql limits on query size.
But this is only acceptable via the GET method.  So of course I am
getting the 'URI - Requested url length exceeds capacity of server'
error.

So the question:
How can I pass such a large string via GET?  Is it possible?  If this
were a subroutine, I would parse the string of ids into an array and
pass the reference.  But I had no luck passing an array by reference via
GET.

Anyone have any ideas other than writing string to a file and reading it
back in?

Thanks,
Bryan



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

Date: Sat, 30 Jun 2001 01:37:27 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Passing Large Values via GET
Message-Id: <r3a%6.141946$DG1.23778617@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <3B3D256F.FA780B64@sequenom.com>,
	BCC <bcoon@sequenom.com> writes:
> I have run into a small problem with one of my scripts.  In one user
> input form, users can enter a large list of numbers (8000 or so) which
> are processed via post and a mysql query into a result set.  This is all
> cool.
> 
> But to view results from 8000 queries, I implemented pagination, which
> are simply links back to the same cgi with sql limits on query size.
> But this is only acceptable via the GET method.  So of course I am
> getting the 'URI - Requested url length exceeds capacity of server'
> error.
> 
> So the question:
> How can I pass such a large string via GET?  Is it possible?  If this

Wrong question.  The right question is, "what am I doing wrong here?"

The simple answer is, you're trying to pass back the data to the server in the 
URL.  Stop it. Instead just encode the original query in the first returned 
page, along with the SQL limits, as hidden fields in the HTML.  When they want 
to go to the next "page", just have them do something to submit the form.

An alternative answer (and the SMART one) is don't pass back and forth the 
8000 pieces of data needed to build the query.  Ugh.  Instead, store that
on the server side somewhere (database?) and had the user back a unique
key.  This key will be used to retrieve the data from the database to restart
the query.  This is called session management, and how most large systems
deal with this problem.  Get familiar with it.

-- 
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org                Perl Developer's Dictionary
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Fri, 29 Jun 2001 06:09:02 -0600
From: Howard Brazee <howard@brazee.net>
Subject: Re: Perl from VXML
Message-Id: <3B3C6FDE.C38D0FD8@brazee.net>



Tad McClellan wrote:

> Howard Brazee <howard@brazee.net> wrote:
>
> >I am trying out some VXML,
>
> What is VXML?
>
> Is it XML of some flavor or another?

Voice - XML


> >calling a Perl script written to be called by
> >HTML.
>
> CGI programs are called by www *servers* (not by browsers).
>
> Which computer your program is running on is an important
> thing to know.

The server is a Sun.


> >I am not familiar with Perl, but the VXML debugger is finding a
> >mismatched tag, leading me to infer that I am receiving some HTML code
> >back.
> >
> >I changed print "<html><body>Unknown Request Method.</html><body>","\n"
>                                                             ^^
>                                                             ^^
> >;
> >
> >     To       print "<html><body>Unknown Request
> >Method.<body></html>","\n" ;
>         ^^
>         ^^
>         ^^ </body>
>
> >because XML is fussy about closing inner tags before outer tags.
>
> That can't be the reason, because you _still_ haven't closed
> any <body> sections, you just opened a second one.   :-)
>
> >I am not sure how this works.
>
> That will make things hard to troubleshoot  :-)  :-)
>
> >I am an old CoBOL programmer and this is
> >all new to me.
>
> "this" is actually "these".
>
> Folks just starting with CGI programming are often new to
> several different domains all at once. This can easily
> lead to overload.
>
> My advice it to slow down and try and learn them only one
> or two at a time.
>
> These may not apply to you, if not then just ignore me.
>
>    1) Usenet - what newsgroups exist, netiquette for posting...
>
>    2) Unix - home system is Bill's, ISP's web server in *nix.
>
>    3) Perl - and often new to programming in general too
>
>    4) CGI - programming an application in the CGI environment
>
> Try and learn programming/Perl first. You can do this on your
> home machine without an ISP. Perl is free, just download and
> install it.
>
> First get comfortable writing programs that run from the
> command line before adding the complications of a particular
> application area (CGI).
>
> Then use the CGI module for your CGI programs, and you will be
> able to test it from the command line locally, again with no
> web server involved.
>
> After you get your CGI program working from the command line,
> _then_ is when you need to know the particulars of how your
> web servers is setup. You should ask your provider to tell
> you how they have set things up. Also ask them about access
> to the web server's error logs.
>
> You might also get a free web server to run locally.
>
> There are newsgroups for discussing servers and the CGI
> environment:
>
>       comp.infosystems.www.authoring.cgi
>       comp.infosystems.www.servers.mac
>       comp.infosystems.www.servers.misc
>       comp.infosystems.www.servers.ms-windows
>       comp.infosystems.www.servers.unix
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: Fri, 29 Jun 2001 21:59:59 -0500
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: problems with mod_perl
Message-Id: <9hjfrf$e8q$1@canopus.cc.umanitoba.ca>

"S.E.Franke" <snefski@hotmail.com> wrote in message
news:MPG.15a643c6dc816ce1989687@news.cistron.nl...
> In article <9hfp4k$l9k$1@canopus.cc.umanitoba.ca>,
> randy@theoryx5.uwinnipeg.ca says...
> > [ ... ]
> > The mod_perl guide at http://perl.apache.org/guide/ has a discussion
> > of the "variable will not stayed shared ..." problem.
> >
> I know,....I've read it, but I've problems to translate the solution to
> my problem.....

This relates to the way Apache::Registry works in running scripts -
it basically creates and loads a package with the following
generic structure:

package Apache::ROOT::perl_2dbin::something;
use Apache qw(exit);
sub handler {
  BEGIN {
     $^W = 1;
  };
  $^W = 1;
#
#  your_script_here
#
}
1;

Thus, your script will appear within a handler() subroutine,
and a subroutine within your script can become nested in
this context - that's a reason for the "variable not stayed shared ..."
warning. This illustrates the importance, as you found, of running
Apache::Registry scripts with warnings turned on, as the same
script run as an ordinary cgi script wouldn't suffer this particular
problem. The guide offers a few suggestions for avoiding this - one
way is to  pass explicitly any needed parameters into your routine.

best regards,
randy kobes





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

Date: Fri, 29 Jun 2001 22:06:00 -0400
From: "Ala Qumsieh" <qumsieh@sympatico.ca>
Subject: Re: pull out last line in a text file
Message-Id: <Upa%6.8674$lp3.741624@news20.bellglobal.com>

"Patrick Flaherty" <Patrick_member@newsguy.com> wrote in message
news:9hgfbe01ehm@drn.newsguy.com...
> Hello,
>
> How, in Perl, do I pull out the last line (or lines plural as in tail) of
a text
> file?

By checking the FAQs:

    % perldoc -q tail

--Ala





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

Date: Fri, 29 Jun 2001 23:29:42 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: regular expression problem
Message-Id: <9h2qjtc1fnrj1bkueasb00robjiisv7178@4ax.com>

Xtreme wrote:

>Apologies for starting this thread up again, but I stumbled upon
>something when I was looking for something completely different.  In
>perlfaq6, under the question "What good is \G in a regular
>expression?" I read the following:
><quoted>
>The notation \G is used in a match or substitution in conjunction with
>the /g modifier to anchor the regular expression to the point just
>past where the last match occurred, i.e. the pos() point.
></quoted>
>
>A little lower down, an example is given:
><quoted>
>s/\G>/:/g;
></quoted>
>
>This leads me to believe that, as opposed to what was discussed in
>this thread, \G in conjunction with a /g *is* valid.

I don't get it. Of course \G plus /g is valid. In fact, \G without /g is
almost useless. You need /g to affect pos, and \G anchors at pos
position. And if pos is not set, it acts as if it is zero, i.e. \G
anchors at the start of the string.

Here is what it was originally intended for:

	$_ = 'aaa<aaa>aaa<aa>a';
	while(/</g) {
	    while(/\Ga/gc) {
	        print "ding! ";
	    }
	   print "\n...\n";
	}
-->
	ding! ding! ding! 
	...
	ding! ding! 
	...

As you can see, it only matches a's following "<", either immediately,
or after another such case.

This works on 5.005_03, too.

I was a bit surprised to see that s/\G/!/ works fine *without* /g. Er,
on 5.6.0 and 5.6.1. See what happens in 5.6.x:

	$_ = 'aaa<aaa>aaa<aa>a';
	while(/</g) {
	    s/\Ga/A/g;
	}
	print;
-->
	aaa<AAA>aaa<AA>a

Instead of printing "ding!" every time such an "a" is encountered, it
replaces it with an upper case "A".

This is the result in earlier perls:

	AAA<aaa>aaa<aa>a$
	
In earlier perls, \G in s/// only matches at the start of the string,
irrespective of the value of pos.

But on 5.6.x, I'm not too happy with this:

	$\ = "\n";
	$_ = 'aaa<aaa>aaa<aa>a';
	while(/</g) {
	    s/\Ga/A/g;
	    print;
	    print pos || 0;
	}
	print;
-->
	aaa<AAA>aaa<aa>a
	0
	aaa<AAA>aaa<aa>a
	4
	aaa<AAA>aaa<AA>a
	0
	aaa<AAA>aaa<AA>a
	4
	aaa<AAA>aaa<AA>a
	12
	aaa<AAA>aaa<AA>a

As you can see, pos is reset every time s///g does a succesful
substitution, so next time, //g starts again from the starting position.
Only if s/// fails, it doesn't affect pos. Adding a //c doesn't help:
same result. Talk of counter-intuitive.

-- 
	Bart.


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

Date: Sat, 30 Jun 2001 02:45:20 GMT
From: John Golubenko <jeneag@home.com>
Subject: Re: unix `ps`
Message-Id: <Pine.LNX.4.33.0106291945570.16443-100000@linda.javagui.com>

I don't know the answer, but probably no.
You'd better try like 'lsof' application, which lists all processes, and
what they use, etc.

On Fri, 29 Jun 2001, Todd Smith wrote:

> My server was rooted today by some script-kiddie, and ls, ps, and du were
> trojaned. Is there a way to list all the pids and process names with perl,
> similar to the unix ps but without all the options?
>
>
>



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

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


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