[7748] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1373 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 27 08:12:39 1997

Date: Thu, 27 Nov 97 05:02:18 -0800
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, 27 Nov 1997     Volume: 8 Number: 1373

Today's topics:
     Re: Problems with animated gifs in Netscape 3.01/ CGI (Tino)
     Re: Proxy Client <aaron@soltec.net>
     Re: Proxy Client (E.None Archibald)
     Re: Proxy Client (Faust Gertz)
     Re: Proxy Client <aaron@soltec.net>
     Re: Proxy Client <aaron@soltec.net>
     Re: Q: How to move files around ? (Jeremy D. Zawodny)
     regexp problem <rowanfan@algonet.se>
     Re: Removing Files older than 14 days (Mike Stok)
     Re: removing lines from a file?? <luu_tran@geocities.com>
     script/table-driven editing of many files (Michael Friendly)
     setting cookies with newCGI.pm (Mischa van Rijswijk)
     Re: shoving STDOUT into a scalar (Jonathan Feinberg)
     Strange 'print Location:' problem with Perl <tdgilman@DELETETHISbest.com>
     SUID + Linux (Helmut Jarausch)
     Re: sum in assoc array (Terry Michael Fletcher - PCD ~)
     Re: temporary file (Faust Gertz)
     Re: temporary file (Hans Juergen von Lengerke)
     tied variables and forking davidb@chelsea.net
     Re: Tk/Motif/Embedded Perl question (Ken Fox)
     Re: Variable Pattern Options (Mike Stok)
     Re: Variable Pattern Options (Andrew M. Langmead)
     Re: Want this script (Faust Gertz)
     Which port is better? activestate vs others (Michael Ng)
     Re: Yet Another Newbie Question (Faust Gertz)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 25 Nov 1997 21:50:46 GMT
From: eberl@berlin.snafu.de (Tino)
Subject: Re: Problems with animated gifs in Netscape 3.01/ CGI
Message-Id: <347b0a82.4375545@unlisys.snafu.de>

Hello,

warp@cia.com.au wrote in comp.lang.perl.misc:

>The gifs are set to loop forever, but for some reason, when
>called up by the script, they loop once then stop in Netscape.

If my memory serves me you must enable the local cache. Then it will loop.

Ciao,

Tino




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

Date: Tue, 25 Nov 1997 18:10:10 -0600
From: "Aaron Young" <aaron@soltec.net>
Subject: Re: Proxy Client
Message-Id: <aaron-2511971810100001@pool1-005.wwa.com>

Thank you all for your suggestions.



In article <34812965.4688452@news.wwa.com>, faust@wwa.com (Faust Gertz)
wrote:

> On Tue, 25 Nov 1997 08:37:25 -0600, "Aaron Young" <aaron@soltec.net>
> wrote:
> 
> >I originally posted this question under anothers email address because I
> >can't get to newsgroups at work.
> 
> Thanks for sharing.
> 
> >What I don't understand is why I was pointed toward another newsgroup
when I
> >asked how to do some client stuff in perl.....
> 
> Because you said "What I'm looking for is advice/pointers/help on how
> to authenticate with a proxy"  and  " I am not interested in
> using the LWP module (because I know how to do it with that)".  Thus,
> your question is not a perl specific question.  If you asked how to do
> something with the sockets library, then your question might have been
> received differently.
> 
> >granted I didn't pepper my post with references to perl, but that was 
> >because I figured that if I post to comp.lang.perl.misc...............it
would 
> >be understood that I was doing this in perl.
> 
> Yes, but it seemed your question was about how to "authenticate with a
> proxy" and not about your attempt to do it in perl.
> 
> >Is it that no one has done this?  
> 
> Do you mean in any language? 
> 
> >Is it that no one has done this in perl? 
> 
> Obviously you know the answer to this.  It can be done in perl and is
> often done using the libwww modules.  
> 
> >Is it that that other newsgroup can answer the question in perl as well?
> 
> I bet they can, but you might want them answered in English.
> 
> >I really really hope I wasn't pointed away because I didn't mention perl
in
> >my post some minimum number of times.
> 
> I think it was either your actual question or the way you phrased your
> question.
> 
> 
> Streben nach Wahrheit
> 
> Faust Gertz
> Philosopher at Large
> 
> "If only you had plead guilty!  We can manage the guilty - it is 
> the innocent who escape us, who cause nothing but anarchy" -- 
>  Jean Cocteau's _Bacchus_



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

Date: 25 Nov 1997 19:18:51 GMT
From: yevgene@xochi.tezcat.com (E.None Archibald)
Subject: Re: Proxy Client
Message-Id: <65f8ar$36r$1@tepe.tezcat.com>

Aaron Young <aaron@soltec.net> wrote:
<snippage occurs>
: Is it that no one has done this?  Is it that no one has done this in perl? 
: Is it that that other newsgroup can answer the question in perl as well?

Step off. Of course it has been done in perl, as you noted yourself.
If you want to know, read the source to LWP, *then* ask questions.

This is assuming you have the LWP source a command line away - as you
'already know how to do that.'

Not that you're likely to get a polite response after publically (but
feebly) insulting those who respond.

: I really really hope I wasn't pointed away because I didn't mention perl in
: my post some minimum number of times.

Nope. You were pointed away because your question, in its current
incarnation, would have been better-placed somewhere else.

Any questions? Good, start reading.

--eugene


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

Date: Tue, 25 Nov 1997 20:04:35 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Proxy Client
Message-Id: <34812965.4688452@news.wwa.com>

On Tue, 25 Nov 1997 08:37:25 -0600, "Aaron Young" <aaron@soltec.net>
wrote:

>I originally posted this question under anothers email address because I
>can't get to newsgroups at work.

Thanks for sharing.

>What I don't understand is why I was pointed toward another newsgroup when I
>asked how to do some client stuff in perl.....

Because you said "What I'm looking for is advice/pointers/help on how
to authenticate with a proxy"  and  " I am not interested in
using the LWP module (because I know how to do it with that)".  Thus,
your question is not a perl specific question.  If you asked how to do
something with the sockets library, then your question might have been
received differently.

>granted I didn't pepper my post with references to perl, but that was 
>because I figured that if I post to comp.lang.perl.misc...............it would 
>be understood that I was doing this in perl.

Yes, but it seemed your question was about how to "authenticate with a
proxy" and not about your attempt to do it in perl.

>Is it that no one has done this?  

Do you mean in any language? 

>Is it that no one has done this in perl? 

Obviously you know the answer to this.  It can be done in perl and is
often done using the libwww modules.  

>Is it that that other newsgroup can answer the question in perl as well?

I bet they can, but you might want them answered in English.

>I really really hope I wasn't pointed away because I didn't mention perl in
>my post some minimum number of times.

I think it was either your actual question or the way you phrased your
question.


Streben nach Wahrheit

Faust Gertz
Philosopher at Large

"If only you had plead guilty!  We can manage the guilty - it is 
the innocent who escape us, who cause nothing but anarchy" -- 
 Jean Cocteau's _Bacchus_


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

Date: Tue, 25 Nov 1997 18:03:31 -0600
From: "Aaron Young" <aaron@soltec.net>
Subject: Re: Proxy Client
Message-Id: <aaron-2511971803310001@pool2-036.wwa.com>

I appreciate allthe responses to my question.

Thank you for your suggestions.



In article <34812965.4688452@news.wwa.com>, faust@wwa.com (Faust Gertz)
wrote:

> On Tue, 25 Nov 1997 08:37:25 -0600, "Aaron Young" <aaron@soltec.net>
> wrote:
> 
> >I originally posted this question under anothers email address because I
> >can't get to newsgroups at work.
> 
> Thanks for sharing.
> 
> >What I don't understand is why I was pointed toward another newsgroup
when I
> >asked how to do some client stuff in perl.....
> 
> Because you said "What I'm looking for is advice/pointers/help on how
> to authenticate with a proxy"  and  " I am not interested in
> using the LWP module (because I know how to do it with that)".  Thus,
> your question is not a perl specific question.  If you asked how to do
> something with the sockets library, then your question might have been
> received differently.
> 
> >granted I didn't pepper my post with references to perl, but that was 
> >because I figured that if I post to comp.lang.perl.misc...............it
would 
> >be understood that I was doing this in perl.
> 
> Yes, but it seemed your question was about how to "authenticate with a
> proxy" and not about your attempt to do it in perl.
> 
> >Is it that no one has done this?  
> 
> Do you mean in any language? 
> 
> >Is it that no one has done this in perl? 
> 
> Obviously you know the answer to this.  It can be done in perl and is
> often done using the libwww modules.  
> 
> >Is it that that other newsgroup can answer the question in perl as well?
> 
> I bet they can, but you might want them answered in English.
> 
> >I really really hope I wasn't pointed away because I didn't mention perl
in
> >my post some minimum number of times.
> 
> I think it was either your actual question or the way you phrased your
> question.
> 
> 
> Streben nach Wahrheit
> 
> Faust Gertz
> Philosopher at Large
> 
> "If only you had plead guilty!  We can manage the guilty - it is 
> the innocent who escape us, who cause nothing but anarchy" -- 
>  Jean Cocteau's _Bacchus_



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

Date: Tue, 25 Nov 1997 18:00:23 -0600
From: "Aaron Young" <aaron@soltec.net>
Subject: Re: Proxy Client
Message-Id: <aaron-2511971800230001@pool2-036.wwa.com>

How about this...


I'll post the question again trying to be as clear as possible seeing as how
I obviously wasn't the first time.

I am attempting to write a proxy client in perl.  I do not want to do this
using the LWP module as I am more interested in how the LWP module itself
works.  I looked at the source for the LWP module but my perl obviously
isn't up to snuff to understand it that way just yet. 

What I get is this:

I connect to the port
Pass a request to the proxy server
The server then responds with a 407 error and then the "Your client doesn't
know how to authenticate message."

My understanding of the way this should work is as follows

I connect to the port
Pass a request to the proxy server
The server responds that it needs me to authenticate with the
proxy-authenticate header

I retransmit the request with the proxy-authorize header

The proxy server is netscape.  I can post the source if that will make it
clearer (I can't right now as I don't have it handy)


In article <34812965.4688452@news.wwa.com>, faust@wwa.com (Faust Gertz)
wrote:

> On Tue, 25 Nov 1997 08:37:25 -0600, "Aaron Young" <aaron@soltec.net>
> wrote:
> 
> >I originally posted this question under anothers email address because I
> >can't get to newsgroups at work.
> 
> Thanks for sharing.
> 
> >What I don't understand is why I was pointed toward another newsgroup
when I
> >asked how to do some client stuff in perl.....
> 
> Because you said "What I'm looking for is advice/pointers/help on how
> to authenticate with a proxy"  and  " I am not interested in
> using the LWP module (because I know how to do it with that)".  Thus,
> your question is not a perl specific question.  If you asked how to do
> something with the sockets library, then your question might have been
> received differently.
> 
> >granted I didn't pepper my post with references to perl, but that was 
> >because I figured that if I post to comp.lang.perl.misc...............it
would 
> >be understood that I was doing this in perl.
> 
> Yes, but it seemed your question was about how to "authenticate with a
> proxy" and not about your attempt to do it in perl.
> 
> >Is it that no one has done this?  
> 
> Do you mean in any language? 
> 
> >Is it that no one has done this in perl? 
> 
> Obviously you know the answer to this.  It can be done in perl and is
> often done using the libwww modules.  
> 
> >Is it that that other newsgroup can answer the question in perl as well?
> 
> I bet they can, but you might want them answered in English.
> 
> >I really really hope I wasn't pointed away because I didn't mention perl
in
> >my post some minimum number of times.
> 
> I think it was either your actual question or the way you phrased your
> question.
> 
> 
> Streben nach Wahrheit
> 
> Faust Gertz
> Philosopher at Large
> 
> "If only you had plead guilty!  We can manage the guilty - it is 
> the innocent who escape us, who cause nothing but anarchy" -- 
>  Jean Cocteau's _Bacchus_



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

Date: Tue, 25 Nov 1997 18:07:21 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Q: How to move files around ?
Message-Id: <347d13c4.441970660@igate.hst.moc.com>

[original author automagically cc'd via e-mail]

On Tue, 25 Nov 1997 17:56:31 GMT, stewart@circustuff.co.uk (Stewart
Hutton) wrote:

>I've hacked quite a number of scripts by now - but have never had to
>move files around the disk.
>
>Until now. =:>
>
>Can someone point me to any references or samples please?

You may want to investigate the File::* modules.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Tue, 25 Nov 1997 20:39:08 +0100
From: Calle <rowanfan@algonet.se>
Subject: regexp problem
Message-Id: <347B295C.1430@algonet.se>

Hi,

I want to replace all the links in a document with another link,
I only want to change the href-attribute, the other shall be intact
a) <a href="http://www.asd.com" target="top">
b) <a target="out" href="http://www.asd.com">

how do I do it? I tried this, but it won4t work when the case is as in
example b) above

$doc =~ s/\<a(.*?)href=(.*?)\s*(.*?)\>/&fixurl($1,$2,$3)/egs;

what is wrong?  (fixurl is a subroutine that will generate the new
url)


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

Date: 25 Nov 1997 21:31:05 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Removing Files older than 14 days
Message-Id: <65fg2p$oqu@news-central.tiac.net>

If you have a reasonably installed and recent version of perl then you
should habve the File::Find module.

One example in the docs is:

       This library is primarily for the find2perl tool, which
       when fed,

           find2perl / -name .nfs\* -mtime +7 \
               -exec rm -f {} \; -o -fstype nfs -prune

       produces something like:

           sub wanted {
               /^\.nfs.*$/ &&
               (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
               int(-M _) > 7 &&
               unlink($_)
               ||                
               ($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) &&
               $dev < 0 &&
               ($File::Find::prune = 1);
           }

which might make some sense to you if you're on a unix like system and can
check out the man page for the find command.

Hope this helps,

Mike


In article <880492908.29258.0.nnrp-02.c2de48f0@news.demon.co.uk>,
Hugh <hnews@harvest-lodge.demon.co.uk> wrote:
>I am having difficulty writing an efficient script to delete all files in a
>preset directory over a certain age. If a file is older than 14 days I want
>to delete it. There are likely to be upwards of a couple of thousand or so
>files in the directory. How is the best way to check the create dates and
>delete if appropriate. As I said there is no need to recurse subdirs as they
>won't exist. All files to be deleted will have a .ABC suffix, the routine
>should ignore files without this.
>
>Thanks
>
>Hugh
>Hugh@harvest-lodge.demon.co.uk
>
>
>
>


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 25 Nov 1997 18:42:07 GMT
From: "Luu Tran" <luu_tran@geocities.com>
Subject: Re: removing lines from a file??
Message-Id: <35759.4465365741luutrangeocitiescom@207.217.243.50>

[posted and mailed]

On Sat, 22 Nov 1997, Burt Lewis <burt@ici.net> wrote:

>Hi,
>
>I need to remove the lines that end with a - and keep the rest.
>
>Not having much luck with this and would appreciate any help/
>
>Thanks!
>

something like this:

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

$fn = "foo";
open FILE, "$fn" or die "cannot open for read $!";
my @lines = <FILE>;
close FILE;

open FILE, ">$fn" or die "cannot open for write $!";
foreach (@lines) {
	unless (/\-$/) { print FILE; }
}
close FILE;

--------

This just slurps the whole file into the array @lines and writes out those 
that don't end in -

If you have a largish file, you'll end up with a largish array and a 
largish process.  You may want to read line by line and write out to a temp 
file instead.  At the end, you can unlink the original file and rename the 
temp file (left as an exercise :)

-- luu

	http://www.bayscenes.com/np/mdonline/
Please remove the underscore _ in my address when replying by email


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

Date: 25 Nov 1997 21:31:52 GMT
From: friendly@hotspur.psych.yorku.ca (Michael Friendly)
Subject: script/table-driven editing of many files
Message-Id: <65fg48$l63$1@sunburst.ccs.yorku.ca>

For a project I need to be able to extract specified segments from
many files, and would like to be able to describe those segments
in a script or table something like this

ASSOCPL1 :0 delete /title/
         /data boxes/ delete *
ASSOCPL2 :0 select /data boxes/
AUTO     :0 delete /data auto/
BASEBA1  :0 delete /include BASEBALL/
         /*(2)/ delete *

where each entry consists of an input filename followed by one or
more commands to be applied to extract the required segment, and
each command consists of 

/start-regexp/ or :line-num,  command-word, /end-regexp/ or *=last line

Is there any perl application which does anything like this that
I could adapt for my needs?


--
Michael Friendly     Internet: friendly@hotspur.psych.yorku.ca (NeXTmail OK)
Psychology Dept
York University      Voice: 416 736-5118  Fax: 416 736-5814
4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA


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

Date: Tue, 25 Nov 1997 23:57:18 GMT
From: mischa@pi.net (Mischa van Rijswijk)
Subject: setting cookies with newCGI.pm
Message-Id: <347b64fc.3515445@news.pi.net>

Hello,

Can somebody explain to me how I can set a cookie with newCGI.pm?
I tried the following:

$new_cookie = query->cookie(-name=>'bla');
print query->cookie etc.

but it doesn't work. I don't get errors, but the thing just doesn't
set the cookie. 
Thank you for your trouble to help me.

Mischa


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

Date: Tue, 25 Nov 1997 19:08:44 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: shoving STDOUT into a scalar
Message-Id: <MPG.ee53297fe69190e98969a@news.concentric.net>

> > To the point: what I'd like to do is capture everything printed to STDOUT
> > for a portion of my script and concatenate it all together in one scalar.

> Is there a reason you're not using
>    $scalar = join("",<STDIN>) 

And, what the heck, there's always
{
   local $/ = undef;
   $scalar = <STDIN>;
}
-- 
Jonathan Feinberg    jdf@pobox.com    Sunny Brooklyn, NY


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

Date: Tue, 25 Nov 1997 16:58:43 -0800
From: "Tim Gilman" <tdgilman@DELETETHISbest.com>
Subject: Strange 'print Location:' problem with Perl
Message-Id: <65fs8b$8hs$1@nntp2.ba.best.com>

I'm using the

print ("Location: URL\n\n");

feature in a server-side Perl script to print out a pdf article that a user
selects from a form.  I've run into what I think is a strange problem.

This works fine:

print("Location: sib97181.pdf\n\n");

However, this doesn't work (it just shows a blank page in the target frame):

$article = $in{'ArticleList'};
print "Location: $article\n\n";

and I have confirmed that $article is being set equal to sib97181.pdf.  I
confirmed this by printing the statement to text.

The strange things, this works:

$foo = "sib97181.pdf";
print "Location: $foo\n\n";

and $foo is as far as I can tell exactly equal to $article!

Please help!

--
Tim Gilman (remove DELETETHIS from the address when replying)
http://www.best.com/~tdgilman




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

Date: 25 Nov 1997 18:40:23 GMT
From: jarausch@numa1.igpm.rwth-aachen.de (Helmut Jarausch)
Subject: SUID + Linux
Message-Id: <65f62n$5bt$1@news.rwth-aachen.de>

I have a problem when using an SUID perl script on Linux (suidperl exists).
The effective and real UID is zero but still I cannot do
system("/bin/mount" ....)

since the kernel still claims "only root may use mount".
How can I become "really" root?

Thanks for any hints,
Helmut.


-- 
Helmut Jarausch
Lehrstuhl f. Numerische Mathematik
Institute of Technology, RWTH Aachen
D 52056 Aachen, Germany


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

Date: 25 Nov 1997 19:12:46 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: sum in assoc array
Message-Id: <65f7ve$18m$1@news.fm.intel.com>

Michael R. Harper (mikihasa@worldnet.att.net) so eloquently and verbosely pontificated:
> I am a newbie having trouble with the following snippet:
> 
> foreach $key (keys(%SUM)) {
>  ($RESULT{'R'},
>   $RESULT{'I'},
>   $RESULT{'A'},
>   $RESULT{'S'},
>   $RESULT{'E'},
>   $RESULT{'C'}) += split(" ", $SUM{$key});
> }
> 
> %SUM contains one string:    "2 2 2 2 2 2"
> It will eventually contain more entries, which I want to sum up and
> store in each of the RESULTS elements.

unfortunately, there is no big LIST += LIST construct.  you have to
improvise and make one yourself.  i find that every time i come across it,
it requires a unique algorithm.  your case is no different.  i thought of
this:

$i = 0;
for $key (R,I,A,S,E,C) {
        $RESULTS{$key} =
		eval eval 'join "+", 
			map { $SUM{$_} =~ /^(?:\d+\s+){$i}(\d+)/ } 
			keys %SUM';       # note this  ^^  index here
        $i++;
}

note:
1) your numbers can be varying numbers of digits (no decimals, but
that is an easy change) and varying spaces between
2) you dont have to care what the keys of %SUM are.

but:
1) are there always six numbers for the six keys in %RESULTS?
2) probably hella-slow on large records.

the first eval forms a string of "#+#+#+#+#+#" and the second eval returns
the value of that executed string.

hope that gives a good starting point.

-- 
#!/usr/local/bin/perl -w- tfletche@pcocd2.intel.com
sleep 1;$"=(time-$^T)<<1;$SIG{ALRM}=sub{print};${q$_$}=join"",
map{chr(hex)}split/(..)/,"4a75737420";alarm$";<>;s y(\0\w){4}.
?yreverse q brehtonabyex;alarm$";<>;for(;length>4;chop){}tr&to
an&empti&;alarm$";<>;s@$_@reverse',ret'.q csaw c@e;alarm$";<>;



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

Date: Tue, 25 Nov 1997 20:04:23 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: temporary file
Message-Id: <347f2319.3075690@news.wwa.com>

On Mon, 24 Nov 1997 17:47:27 -0500, "Michael R. Harper"
<mikihasa@worldnet.att.net> wrote:

>Any good ideas out there for deleting a dynamically created HTML file
>off the server after the user has downloaded it to their browser?  

Not from me.

>[A]fter the user gets the HTML I do not care if it is not there for them 
>later.  Just as long as they can get it once immediately after the Perl 
>script finishes and then have it deleted so my ISP doesn't get upset.

Can't you just unlink/delete the file right after the script displays
it?  If not, could you do something like

:for (<*>) {  (-M $_ < .25) || unlink $_ or warn "$0 is having trouble deleting $_: $!" }

each time you script is evoked?


Strebe nach Wahrheit

Faust Gertz
Philosopher at Large

"Two things fill the mind with ever new and increasing admiration and
awe, the oftener and the more steadily we reflect on them: the starry
heavens above and the moral law within. I have not to search for them
and conjecture them as though they were veiled in darkness or were in
the transcendent region beyond my horizon; I see them before me and
connect them directly with the consciousness of my existence." -- 
Immanuel Kant, _The Critique of Practical Reason_


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

Date: Tue, 25 Nov 1997 21:38:36 GMT
From: lenkerWEEDS@dircon.co.uk (Hans Juergen von Lengerke)
Subject: Re: temporary file
Message-Id: <347c4523.14040703@news.dircon.co.uk>

Faust Gertz wrote:

>Strebe nach Wahrheit

Are you suddenly switching from advisory to imperative? ;-)

Hans
Philosopher at Pub

>Faust Gertz
>Philosopher at Large


--
To mail me, just pull the WEEDS!


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

Date: Tue, 25 Nov 1997 18:22:14 -0600
From: davidb@chelsea.net
Subject: tied variables and forking
Message-Id: <880503509.21044@dejanews.com>

Oh Perl wizards,

I have a rather interesting problem (interesting to me, at least).  I
have a program that has a medium sized in-core memory database and some
variables, some of which are tied hashes on disk.  The program is
watching a log file, and with every new line, the master program calls
fork() to spawn a child. The child does some work which may take a few
minutes, and I can't afford to have the master program hanging while this
work is being done.

Unfortunately, that child now has those same tied variables in memory -
and when the child exists, those tied variables are flushed to disk,
potentially corrupting or otherwise destroying the files held by the
parent.

So, the question - is there a good way to force the child to
automatically close all filehandles outside of STDIN/STDOUT, while still
keeping all of the data in memory?  Having the parent close everything,
then fork, and then reopen everything has a lot of overhead.  The child
doesn't need the variables which are tied to disk, but it does need the
other information in memory which is time-consuming to read in and build.
 I did some examination of various fcntl() calls, but they only seem to
apply to exec.	I also tried to untie() or undef all of the arrays, first
thing when the child forks, but that doesn't really fix my problem, it
just reduces the chance of it occurring.  The FAQ doesn't have anything
along these lines, so now I'm stumped for the moment.

Any ideas on handling this problem would be appreciated.  Please CC
responses via email, as I do not have access to a regular news feed.

Thanks,

David.

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 25 Nov 1997 23:11:59 GMT
From: fox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: Tk/Motif/Embedded Perl question
Message-Id: <65flvv$a5o1@eccws1.dearborn.ford.com>

korf@informatik.uni-koblenz.de (Frank Korf) writes:
> fox@pt0204.pto.ford.com (Ken Fox) writes:
> > I'm working on a Motif module that provides full access to the X,
> > Xt and Xm libraries.  ...
>
> Where can I find it?

http://www.msen.com/~fox/X11-Motif-1.1a.tar.gz

I haven't moved it to CPAN because it's not quite beta yet -- documentation
and demos are missing.  If you've used Xt/Motif in C, then you will be
comfortable with the module because the module supports almost-verbatim Xt/Xm
source code.  Otherwise, just take a look at the existing examples and tell me
what you think.

If you don't have Motif, I've had reports that this module works with the
Motif freeware clone LessTif.  LessTif doesn't fully implement Motif though
so some of the module may not work.

The Motif module is also interesting simply to see how a very complex C
library (almost 1000 functions, more than 100 classes) can be (nicely IMHO)
wrapped in Perl.

- Ken

-- 
Ken Fox (kfox@ford.com)                  | My opinions or statements do
                                         | not represent those of, nor are
Ford Motor Company, Powertrain           | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section             | "Is this some sort of trick
                                         |  question or what?" -- Calvin


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

Date: 25 Nov 1997 21:41:03 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Variable Pattern Options
Message-Id: <65fglf$pd8@news-central.tiac.net>

You might be interested in this snippet from the perlre man page: 

     (?imsx)   One or more embedded pattern-match modifiers.
               This is particularly useful for patterns that are
               specified in a table somewhere, some of which want
               to be case sensitive, and some of which don't.
               The case insensitive ones merely need to include
               (?i) at the front of the pattern.  For example:

                   $pattern = "foobar";
                   if ( /$pattern/i )

                   # more flexible:

                   $pattern = "(?i)foobar";
                   if ( /$pattern/ )

In the debugger:

  DB<1> $p = "(?i)mike"

  DB<2> print 'Mike' =~ /$p/
1
  DB<3> print $]
5.00401

Hope this helps,

Mike

In article <347B403A.500F@gsao.med.ge.com>,
Greg Derzay 4-6601 GSAO  <derzayg@gsao.med.ge.com> wrote:
>In a Perl script, I'd like to have the following statement:
>
>@matches = ($lines =~ /$pattern/$options);
>  
>However, the compiler will not allow me to use the $options variable.
>I am using Perl version 5.004_01.  It has no problem with using 
>a variable for the pattern, but chokes on the variable for the 
>options.  Why can't I do this?  I'm trying to write a UNIX script
>to perform grep-like things in Perl, and need to have dynamic 
>options in pattern matching.
>
>Thanks,
>Greg


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Tue, 25 Nov 1997 22:05:39 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Variable Pattern Options
Message-Id: <EK82pF.5pD@world.std.com>

Greg Derzay 4-6601 GSAO <derzayg@gsao.med.ge.com> writes:

>In a Perl script, I'd like to have the following statement:

>@matches = ($lines =~ /$pattern/$options);
>  
>However, the compiler will not allow me to use the $options variable.

If the options are only the /i,/m,/s, or /x options, you can use the
embedded (?imsx) construct.

@matches = ($lines =~ /(?$options)$pattern/);

Don't forget the /o option if you can use it. If you can't, then maybe
the efficiency hint in <URL:http://www.perl.com/CPAN/doc/manual/html/
pod/perlfaq6/How_do_I_eficiently_match_many_.html>

If you need other options as well (I don't see why someone would
toggle /g or /o programatically, but you never know) The best I can
see that you could do is a well placed eval(). (placed outside of the
outermost loop you can manage.)

eval <<CODE;
   \@matches = (\$lines =~ /$pattern/$options);
CODE
-- 
Andrew Langmead


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

Date: Tue, 25 Nov 1997 20:04:21 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Want this script
Message-Id: <347e20e5.2512159@news.wwa.com>

On 25 Nov 1997 15:40:42 GMT, gt2863a@acmey.gatech.edu (Mark) wrote:

>
>I would like to find if it is available or
>something like that I could modify, I PERL script
>that connects with a web page and captures the HTML
>from it. 

This script uses the libwww bundle which is available at a CPAN
(http://www.perl.com/CPAN) near you.  After installing the needed
modules, just type the name of the script followed by the web page in
question (like this 'scriptname.pl http://www.asen.com/').

#!/usr/local/bin/perl5.004 -w
use strict;
use LWP::Simple;
print (get $ARGV[0]);
exit;

If you don't want to bother installing the bundle, feel free to try to
do it with the socket library.


Streben nach Wahrheit

Faust Gertz
Philosopher at Large

Sting once asked Elvis Costello, "Why don't you stop singing in that
fake American accent?" Costello replied, "I will, as soon as you stop
using the fake Jamaican one."


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

Date: 25 Nov 1997 19:02:45 GMT
From: syng@jalisco.engr.ucdavis.edu (Michael Ng)
Subject: Which port is better? activestate vs others
Message-Id: <65f7cl$5pn$2@mark.ucdavis.edu>

Hi!  I appologize if this question has been asked lately.

I am currently using Win95 and NT.  I am interested in knowing the 
difference between the Perl5 from active state and the Perl5 from 
standard distribution(? I downloaded a binary via www.perl.com)

Any recommendation?.  Which one is preferred?

Thanks!

--
Michael (syng@engr.ucdavis.edu)
+--------------------------------------------------------------+
| http://www.engr.ucdavis.edu/~syng/                           |
| <PGP public key: http://www.engr.ucdavis.edu/~syng/mike.pgp> |
+--------------------------------------------------------------+


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

Date: Tue, 25 Nov 1997 20:04:18 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Yet Another Newbie Question
Message-Id: <347d1d47.1586563@news.wwa.com>

On 25 Nov 1997 15:49:46 GMT, jarkko@avalon.merikoski (Jarkko Juntunen)
wrote:

>I'm trying to write program for cleaning up html-files back to 
>plain text files --so the program should remove everything inside
>angle brackets.

I wonder if this has been attempted before.

>This line: s/<.*?>//sgx; works something like, BUT it won't remove
>anything if tag begins in one line and continue to next line.

It sure won't.
	
>So, plase somebody help Me, and tell how that is possible in Perl.
>I feel that it must be possible!

Here is what the FAQ has to say:

:How do I remove HTML from a string? 
:
:The most correct way (albeit not the fastest) is to use HTML::Parse from CPAN (part of the libwww-perl distribution, which is a
:must-have module for all web hackers). 
:
:Many folks attempt a simple-minded regular expression approach, like s/<.*?>//g, but that fails in many cases because the tags
:may continue over line breaks, they may contain quoted angle-brackets, or HTML comment may be present. Plus folks forget to
:convert entities, like < for example. 
:
:Here's one ``simple-minded'' approach, that works for most files: 
:
:    #!/usr/bin/perl -p0777
:    s/<(?:[^>'"]*|(['"]).*?\1)*>//gs
:
:If you want a more complete solution, see the 3-stage striphtml program in
:http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/striphtml.gz . 

You might also think about looking at the HTML::Parse module
distributed with libwww.  You can get it at a CPAN
(http://www.perl.com/CPAN) near you.


Streben nach Wahrheit

Faust Gertz
Philosopher at Large

"For what had embittered him Fitz had no name.  Yet he knew that every
daybreak duped him into waking and every evening conned him into
sleep.  The feeling of having been cheated - of having been cheated -
that was it.  Nobody knew why nor by whom." -- Nelson Algren, _A Walk
on the Wild Side_ 


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1373
**************************************

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