[19484] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1679 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 2 11:05:31 2001

Date: Sun, 2 Sep 2001 08:05:06 -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: <999443106-v10-i1679@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 2 Sep 2001     Volume: 10 Number: 1679

Today's topics:
    Re: A Question about reference lifetimes <jamesrwagoner@yahoo.com>
        Advise on a basic perl script  <sammy@bigpond.net.au>
        Black Perl (N01937)
    Re: Black Perl (Martien Verbruggen)
        can't set permission on directory (Nils-Eric Pettersson)
    Re: can't set permission on directory <krahnj@acm.org>
    Re: DBI Question <jamesrwagoner@yahoo.com>
        IO::File->new_tmpfile (Tassilo v. Parseval)
    Re: IO::File->new_tmpfile (Martien Verbruggen)
    Re: IO::File->new_tmpfile <Tassilo.Parseval@post.rwth-aachen.de>
    Re: IO::File->new_tmpfile <bernie@fantasyfarm.com>
        Memory managment in perl (Nkhouri)
        Perl handcoded? (Lijiv Khil)
    Re: Perl handcoded? <dan@tuatha.sidhe.org>
    Re: Perl Project <bcaligari@fireforged.com>
    Re: Perl Project <bart.lateur@skynet.be>
    Re: Posting a pre-existing cookie using LWP? vze2nddi@mail.verizon.net
    Re: Script Error? <us@webhostwatch.co.ukNOSPAM>
    Re: Telnet front-end <jamesrwagoner@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 02 Sep 2001 10:26:15 GMT
From: James Wagoner <jamesrwagoner@yahoo.com>
Subject: Re: A Question about reference lifetimes
Message-Id: <20010902.10261500@tralfaz.bat.bellsouth.net>

What you REALLY want to do is run a query to a database asynchronously, =

using an idle callback in the Tk event loop to collect the output of the=
=20
query as it becomes available.

I don't think DBI provides an asynchronous interface; however, it does=20
allow you to call through to the underlying driver.  PostgreSQL, for=20
example, supports asynchronous interaction.  Check the documentation for=
=20
the interface driver you are using to see if it allows asynchronous=20
calls.

You will need to split the processing among several functions.  The=20
callback that starts the query needs to also register an idle procedure =

with the event loop.  That procedure then needs to unregister the=20
procedure when the query has completed processing.

Any good Tk or Perl/Tk manual should have hints or solutions about=20
hooking in to the event loop to allow for copious amounts of processing =

that won't interfere with the user's interaction with the GUI.  Most of =

the examples that I've seen(if my memory serves me) are for a fractal=20
program that recalculates in the idle loop.  After so many calculations =

it saves state and returns control to the event loop if any events are=20
pending.

In this case you would need to include a call to the database interface =

that provides a no-wait options for checking for available data.  You=20
don't want the idle procedure to enter into a wait condition, because=20
that will block your event loop just as if you had coded the query in th=
e=20
original callback.

Hope this helps!

James Wagoner
(usual caveats apply, YMMV, HAND, TMA...)

>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 8/29/01, 8:06:06 PM, stanb@panix.com (Stan Brown) wrote regarding A=20
Question about reference lifetimes:


> I'm going to need to spawn a child task with FileHandle->open, and hav=
e=20
it
> do a lengthy DBI query (thus allowing perlTK to continue updating the
> screen).

> Beacause of the ammount of data potentialy returned by this select, I =

need
> to use one of the DBI calls that returns a refernce to the returned da=
ta.

> The child task will exit at the end of the select, but I need to be ab=
le=20
to
> access the data untill the parent exits.

> Will this be OK? I'm concrend about cleanup on the exit of the child
> destroying the refeenced data.

> If this is a problem, is there some way to work around this?



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

Date: Sun, 02 Sep 2001 13:41:54 GMT
From: "sammy" <sammy@bigpond.net.au>
Subject: Advise on a basic perl script 
Message-Id: <CGqk7.7383$bY5.42729@news-server.bigpond.net.au>

Have unix text file which I tail and look for certain patterns I need to
certain patterns and in addition if it has the string  some where within the
second
field then ignore or just print message .

Appreciate if you could just take a look at this syntax and advise if okay
or not.

Ps I've have not any perl, mainly shell and just need to mod perl script

Thanks in advance

Sammy

#!/usr/contrib/bin/perl

  $command=sprintf("/usr/bin/tail -f /var/adm/log");
  open(TAILTRAP, "$command |");
  while ( <TAILTRAP> ) {
          @walk = split;
          $second_field=substr($walk[1],13);                            #get
from 2nd field         source_name="daisy-xxx800-44.fred.com"  and from the
13th char which is a double quote    "
                chop($second_field)
                @first=split(/\./, $second_field);
#get up to first .     eg   daisy-xxx800-44    or   tom
                @second=split(/\-/;
#split array by -  not sure ???
                $xxx_string="substr($second[1],0,2);                    #get
just the 3 letters xxx
                print "THIS IS XXX  $xxx"
                        if (/xxx/)
 #not sure if this statement  is correct   ???
                        print OKAY
#ie do nothing
                        }
                        else {
                                 $command="/usr/bin/mailx -s  blah blah
                        }
}

DATA

message_id="63-3d09801f0000" source_name="daisy-xxx800-44.fred.com" more
data ....
message_id="23-3d09801f0000" source_name="tom.700.44.fred.com" more data
 ....
message_id="73-3d09801f0000" source_name="patrick-xxx800-44.fred.com" more
data ....





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

Date: 2 Sep 2001 02:52:34 -0700
From: N01937@hushmail.com (N01937)
Subject: Black Perl
Message-Id: <622db6be.0109020152.693831a2@posting.google.com>

Does anyone know the author of the Black Perl poem found in the Camel Book?




$incerely                               =$_='
Kevin

';s;\s(.+)\s+;\1;;y;nK;lD;;$_="The $_";print;


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

Date: Sun, 2 Sep 2001 20:27:26 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Black Perl
Message-Id: <slrn9p42ce.3ga.mgjv@martien.heliotrope.home>

On 2 Sep 2001 02:52:34 -0700,
	N01937 <N01937@hushmail.com> wrote:
> Does anyone know the author of the Black Perl poem found in the Camel Book?

Hmm.. I thought it was by Larry Wall, himself, but it's actually by
Sharon Hopkins, who's done quite a few poems in Perl.

Martien
-- 
Martien Verbruggen              | Since light travels faster than
Interactive Media Division      | sound, isn't that why some people
Commercial Dynamics Pty. Ltd.   | appear bright until you hear them
NSW, Australia                  | speak?


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

Date: Sun, 02 Sep 2001 08:32:02 GMT
From: nils-eric@telia.com (Nils-Eric Pettersson)
Subject: can't set permission on directory
Message-Id: <3b91ed0a.169152558@news1.telia.com>

Perhaps this is a unix-problem but I have no problem doing this in
Unix direct... so I don't think so.

When I in Perl sets the permission on a directory

chmod 777 directory1;

nothong hapends.
Even if the parent directory of directory1 is set to 777.


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

Date: Sun, 02 Sep 2001 09:39:15 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: can't set permission on directory
Message-Id: <3B91FEB1.79A586E2@acm.org>

Nils-Eric Pettersson wrote:
> 
> Perhaps this is a unix-problem but I have no problem doing this in
> Unix direct... so I don't think so.
> 
> When I in Perl sets the permission on a directory
> 
> chmod 777 directory1;
> 
> nothong hapends.
> Even if the parent directory of directory1 is set to 777.

What did the error message say when you printed the $! variable?  Did
you really want the directory permissions set to 01411 (r----x--t)? 
(777 decimal is 01411 octal)  Did you read about chmod in the perlfunc
man page?  Did you even try to run it?

$ perl -e'chmod 777 directory1'
Bareword found where operator expected at -e line 1, near "777
directory1"
        (Missing operator before directory1?)
syntax error at -e line 1, next token ???
Execution of -e aborted due to compilation errors.



John
-- 
use Perl;
program
fulfillment


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

Date: Sun, 02 Sep 2001 10:42:37 GMT
From: James Wagoner <jamesrwagoner@yahoo.com>
Subject: Re: DBI Question
Message-Id: <20010902.10423700@tralfaz.bat.bellsouth.net>

fetchrow_array fetches only one row of the result set returned by the=20
query.  I have a feeling that syscomments contains multiple rows of text=
=20
with the object id you are querying on.

Also note that $row[0] is the first COLUMN of output returned by the=20
query.  $row[2] is the second column, and so forth.

Either put the fetchrow_array in a loop or use fetchall_arrayref to get =

the entire result set.  Be sure that the driver you are using with DBI=20
supports fetchall_arrayref.

Hope this helps!
James Wagoner



>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 8/28/01, 6:14:31 AM, "Markus Linke"=20
<markus.linke@ib.bankgesellschaft.de> wrote regarding DBI Question:


> Hi,

> I use the following script to get the SQL-Source of a view. The Proble=
m=20
is,
> that I only get the first few characters of the View like "CREATE VIEW=

> murfi_xx AS select distinct data.ownindex, data.text, data.trandat,
> data.ordrbuycod, stocks.Country_ISO, stocks.Murex_Id, data.trdqty,
> data.tradmtchprc, data.stldate, data.t " but not the complete string.
> $row[1] is empty. Any ideas?

> Thanks,
> Markus

> $dbh =3D DBI->connect($dsn, $user, $pass,{ RaiseError =3D> 1, AutoComm=
it =3D> 0 })
>             or die "Datenbankfehler";

> $sth =3D $dbh->prepare("select text from syscomments where id =3D
> object_id(\'murfi_$table\')");
> $sth->execute;
> @row=3D$sth->fetchrow_array;

> my $selectstatement =3D $row[0];

> $sth->finish;



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

Date: 2 Sep 2001 09:02:56 GMT
From: Tassilo.Parseval@post.rwth-aachen.de (Tassilo v. Parseval)
Subject: IO::File->new_tmpfile
Message-Id: <9mssk0$rvm$1@nets3.rz.RWTH-Aachen.DE>

Lately I had been in need of using IO::File->new_tmpfile which works
quite well....actually disturbingly well. The perldocs say:

		Creates an "IO::File" opened for read/write on a newly
		created temporary file.  On systems where this is
		possible, the temporary file is anonymous (i.e. it is
 		unlinked after creation, but held open). [...]

What does "anonymous" exactly mean? Will it be a sort of virtual file
held in memory? I couldn't find any tmp-file created on my disk and now
I am worried about memory-usage in case it would really keep this file
in memory.

Thanks for any help.
Tassilo
-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Sun, 2 Sep 2001 20:20:26 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: IO::File->new_tmpfile
Message-Id: <slrn9p41va.3ga.mgjv@martien.heliotrope.home>

On 2 Sep 2001 09:02:56 GMT,
	Tassilo v. Parseval <Tassilo.Parseval@post.rwth-aachen.de> wrote:
> Lately I had been in need of using IO::File->new_tmpfile which works
> quite well....actually disturbingly well. The perldocs say:
> 
> 		Creates an "IO::File" opened for read/write on a newly
> 		created temporary file.  On systems where this is
> 		possible, the temporary file is anonymous (i.e. it is
>  		unlinked after creation, but held open). [...]
> 
> What does "anonymous" exactly mean? Will it be a sort of virtual file
> held in memory? I couldn't find any tmp-file created on my disk and now
> I am worried about memory-usage in case it would really keep this file
> in memory.

It means exactly what it says between the parentheses: The file is
unlinked immediately after opening. This means that the program holds a
file handle (descriptor) to a file that no longer has a name on the file
system: hence 'anonymous'. The name only exists as long as needed to
open the file and unlink it.

It is exactly the same as a regular file, except that it no longer has a
name, which means that it will be removed from the file system as soon
as your program closes the file handle (either explicitly, or by
exiting). It is a very common technique used on Unix systems for
temporary files. It allows the programmer to open these files, and use
them, without having to worry about cleaning them up on program exit.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Unix is user friendly. It's just
Commercial Dynamics Pty. Ltd.   | selective about its friends.
NSW, Australia                  | 


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

Date: Sun, 02 Sep 2001 12:49:56 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: IO::File->new_tmpfile
Message-Id: <3B920ED4.8070602@post.rwth-aachen.de>

Martien Verbruggen wrote:

[anonymous files]

> It is exactly the same as a regular file, except that it no longer has a
> name, which means that it will be removed from the file system as soon
> as your program closes the file handle (either explicitly, or by
> exiting). It is a very common technique used on Unix systems for
> temporary files. It allows the programmer to open these files, and use
> them, without having to worry about cleaning them up on program exit.

Ah, very good, exactly what I wanted to know (and had been hoping for). 
Thanks for this enlighting!

Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Sun, 02 Sep 2001 07:43:04 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: IO::File->new_tmpfile
Message-Id: <5964pt8ig1nveptmaobdlalav0a44tlbne@news.supernews.net>

Tassilo.Parseval@post.rwth-aachen.de (Tassilo v. Parseval) wrote:

} ... The perldocs say:
} 
} 		Creates an "IO::File" opened for read/write on a newly
} 		created temporary file.  On systems where this is
} 		possible, the temporary file is anonymous (i.e. it is
}  		unlinked after creation, but held open). [...]
} 
} What does "anonymous" exactly mean?

Anonymous means that it has no *name* within the file system.  It is still
a disk file, not a memory block.  The trick on unix is that an inode
[=file] is not actually freed until its reference count goes to zero.  The
two major things that bump the reference count on inodes are: 1) directory
entries pointing at that inode, and 2) open-file structures associated with
that inode.

There's no way to *create* an anonymous file --- on unix, when you open a
file you *must* give it a name and its name must be in _some_ directory.
Note that that means that files are 'born' with a reference count of two:
one for the directory entry that was created and one for the process that
now owns the open-file-structure associated with the file.  BUT: you can
immediately unlink it after you create it ['unlink' means "remove this
directory entry".  There is *NO* "delete this file" system call in Unix]
Then it'll be invisible to the filesystem [since there is no "open file by
inode number" call in Unix and there is no longer any directory entry that
references that inode] but you still have it open and so it'll sit there
and you can do with it as you wish until you close the file.

there are two advantages of handling tmp files this way:

1) security --- it may well not matter in your apps, but temp file security
has been a problem with Unix [where sensitive data is written to a temp
file while the program is running, and another process can find a way to
peek at it].   This largely sidesteps this problem [although there is still
a tiny window of exposure between when the file was first created and when
its name got unlinked].

2) tidiness --  this is the big one for me: you don't need to catch every
exception nor do you need to remember to 'unlink'.  You simply let your
program exit and =poof= the file disappears.

   /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: 2 Sep 2001 07:47:41 -0700
From: circuller@yahoo.com (Nkhouri)
Subject: Memory managment in perl
Message-Id: <64ffc63e.0109020647.528ec839@posting.google.com>

mgjv@tradingpost.com.au (Martien Verbruggen) wrote in message news:<slrn9p3jdv.3ga.mgjv@martien.heliotrope.home>...
> [
> Subject: Re: How can I ...
> 
> Please, in the future, put a real subject in your subject line
> ]
> 
> On 1 Sep 2001 22:44:13 -0700,
> 	Nkhouri <circuller@yahoo.com> wrote:
> > hello good ppl ! 
> > 
> >  - how can i response back to client [ end-request ] explicitly while
> > keeping my cgi program contniues doing other stuff ?
> 
> This question is asked quite regularly here, and the answer can easily
> be found on groups.google.com.
> 
> You could fork a process and make sure that you close stdin and stdout
> in the child, or something like that. Use google to find examples. I
> believe the Perl Cookbook also has some info.
> 
> Also see perlipc, and fork() in perlop.
> 
> [Next time, please don't put two totally unrelated questions in one
> post.]
> 
> >  - where i can find a good resource about memory management in perl ?
> 
> Memory management in Perl is never necessary [1]. It does it all for
> you. What specifically do you want to know?
> 
> Martien
> 
> [1] Not entirely strictly true, circular references can stop Perl's
> automatic management.


 I use many sql statments in my perl program and a big hash table , 
i need to know how much mem  the hash is using and the mem address it
starts and ends at {i know its not always mem squenced} ! as for the
sql statments , i cant tell if the statments auto free its resources
after its executed and read ?
i dont want to call sql->finish explicitly and its being already auto
finished !

thx.


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

Date: 2 Sep 2001 05:28:30 -0700
From: lijivnews@yahoo.com (Lijiv Khil)
Subject: Perl handcoded?
Message-Id: <1b7d9ca0.0109020428.5f7ab74@posting.google.com>

Hi,
 I was going through the sources of perl v 1.0. Is Perl written
without using
any compiler construction tools like Lex and Yacc? I found that all
the transition tables etc were hand-coded in the sources.

With regards,
Lijiv


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

Date: Sun, 02 Sep 2001 15:03:37 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl handcoded?
Message-Id: <dTrk7.300354$v5.30205456@news1.rdc1.ct.home.com>

Lijiv Khil <lijivnews@yahoo.com> wrote:
> Hi,
>  I was going through the sources of perl v 1.0.

Wow, you found an ancient version there. 

> Is Perl written
> without using
> any compiler construction tools like Lex and Yacc? I found that all
> the transition tables etc were hand-coded in the sources.

Perl 5 uses a yacc grammar for part of its work. 

				Dan


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

Date: Sun, 2 Sep 2001 06:55:05 -0000
From: "Brendon Caligari" <bcaligari@fireforged.com>
Subject: Re: Perl Project
Message-Id: <9mskom01nuk@enews3.newsguy.com>


"renntech" <renntech750@yahoo.com> wrote in message
news:674fb37c.0109010559.5910007@posting.google.com...
> I'm bouncing around the perl discussion boards today looking for
> someone I can hire to write a perl script for me.  Is anyone out there
> interested, or know someone who is?

http://www.elance.com is a good place to post/find assignments.
B




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

Date: Sun, 02 Sep 2001 10:10:05 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl Project
Message-Id: <l914ptc0u1c3eqj3skruuutc1mbpau78an@4ax.com>

renntech wrote:

>I'm bouncing around the perl discussion boards today looking for
>someone I can hire to write a perl script for me.  Is anyone out there
>interested, or know someone who is?

	<http://jobs.perl.org>

-- 
	Bart.


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

Date: Sun, 02 Sep 2001 08:21:51 -0400
From: vze2nddi@mail.verizon.net
Subject: Re: Posting a pre-existing cookie using LWP?
Message-Id: <3B92245F.BAE87875@mail.verizon.net>

gnari wrote:

> did you look at the HTTP::Cookies::Netscape subclass of HTTP::Cookies
> the docs seem to indicate that such an object can read netscape cookie files.

Yes, but I don't want to read an existing cookie file, because I need to run this
on a couple of different machines, so I am trying to set the cookie as a string,
instead of reading from a file.

-clay




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

Date: Sun, 2 Sep 2001 11:12:43 +0100
From: "WHW" <us@webhostwatch.co.ukNOSPAM>
Subject: Re: Script Error?
Message-Id: <NJnk7.33038$Nb2.5436862@news2-win.server.ntlworld.com>

Hi,

> Did you cut and paste original code?

I've fixed the script now. The code was from some of my old scripts I wrote
although some of them were just rough outlines of scripts and were not bug
tested or code perfect.

Thanks

:o)

Rob





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

Date: Sun, 02 Sep 2001 10:54:46 GMT
From: James Wagoner <jamesrwagoner@yahoo.com>
Subject: Re: Telnet front-end
Message-Id: <20010902.10544600@tralfaz.bat.bellsouth.net>

Try taking a look at the Expect module.  It is quite close to the expect=
=20
program written as an addition to tcl.

James Wagoner

>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 8/26/01, 3:13:28 AM, Antonio <agm@physics.berkeley.edu> wrote regardi=
ng=20
Telnet front-end:


> I need to make a front-end to a program that, among other things,
> invokes standard telnet after soliciting a login and password. The
> program would prompt the user for various information, and then after
> having a login session, would let telnet function from that point on.

> Something like...

> >Would you like to check email now? (y/n)
> >Login: myself
> >Password:

> >You have mail.
> serverX>


> And then telnet would go from there.

> How do I handle the information in/out of the login and password, and
> feed it seemlessly into telnet? I know the basics of Term::Readkey for=

> the login prompts, but I have no idea how to feed the vital info into
> telnet and have it integrate itself into the program.

> Any suggestions? Antonio.



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

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


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