[13359] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 769 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 12 07:07:22 1999

Date: Sun, 12 Sep 1999 04:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 12 Sep 1999     Volume: 9 Number: 769

Today's topics:
    Re: adding garbage to a file (Abigail)
    Re: Any news about Win32 Threads <nickread@primus.com.au>
        concurrent GDBM_File access? <joern@netcologne.de>
    Re: Could someone break this down for me? <brownen@stolaf.edu>
        Discussion: compiled perl program as shareware <werner@hiz.de>
    Re: division by zero <jbc@shell2.la.best.com>
        how is the best way to search the perl newsgroup archiv <wedeking@msa.attmil.ne.jp>
    Re: I want to exit my script without sending anything b <mike@crusaders.no>
        Newbie Q: Web Crawling <gn888@hotmail.com>
    Re: Newbie Q: Web Crawling (Eric Bohlman)
        Operating system problems? (Peter Wilford)
        Perl Language Reference <icsmc@iafrica.com>
    Re: Perl's underlying implementation of Arrays - Low Pr <nickread@primus.com.au>
    Re: Perl's underlying implementation of Arrays - Low Pr <nickread@primus.com.au>
        Problems with Net::POP3->list marcza@my-deja.com
    Re: Problems with Net::POP3->list (Eric Bohlman)
        Q: regarding clibrary usage. <s.j.c.jonker@getronics.nl>
        Question about perlembed horan@inetarena.com
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 12 Sep 1999 03:28:34 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: adding garbage to a file
Message-Id: <slrn7tmp6m.7c5.abigail@alexandra.delanet.com>

T Fiedler (tfiedler@elvis.icontech.com) wrote on MMCCII September
MCMXCIII in <URL:news:37da7770.0@mail.icontech.com>:
`` i need to add a line of garbage:
`` XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
`` after every 500 lines in a file,

perl -wpe '$.%500 or $_.="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"'



Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Tue, 7 Sep 1999 18:18:45 +1000
From: "Nick Read" <nickread@primus.com.au>
Subject: Re: Any news about Win32 Threads
Message-Id: <937123835.677561@diddley.primus.com.au>


Kangas <kangas@anlon.com> wrote in message
news:37BBAA89.3296E19F@anlon.com...
> Who knows if threads are available in Win32 yet??

Surf the virtual white-wash over www.petes-place.com and grab his threaded
build of Perl for Win32.

I've been testing it for months now and everything seems to be going great.
I've never had any problems or crashes.

Be aware though, that using a build of Perl with threads enabled will slow
everything down about 10-20% than normal, even if you don't use threads.
I'm not trying to put you off though, they're definately worth it.

Best Regards,
Nick Read

==========================
"Noise proves nothing.  Often a hen who has merely
laid and egg cackles as if she had laid an asteroid."

 -- Mark Twain, Follow the Equator
==========================




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

Date: Sun, 12 Sep 1999 12:12:55 +0200
From: Joern Reder <joern@netcologne.de>
Subject: concurrent GDBM_File access?
Message-Id: <37DB7CA7.39062EDA@netcologne.de>


Hi,

I've got problems with concurrent accesses on GDBM_File's. I made a
module for this purpose long time ago, using DB_File successfully. Now I
switched to GDBM_File and strange things happen.

I use an extra file to set an flock on it to control the access on the
original GDBM_File. 

Think of two programms accessing the same GDBM_File:

The first sets the lock. The second tries to set a lock but has to wait
until the first program released the lock.

The first program does its work (add a key/value) and releases the lock.
Now the second tries to tie the GDBM_File but this fails. The error
message is: "Resource temporarily unavailable".

I wrote a simple test script to demonstrate this behaviour. The output
of programe one and two follows:

program one
-----------
open database...
insert a value (press enter):   < meanwhile start program two >
dump database...
$VAR1 = {
          16287 => 16287,
          16289 => 16289,
          16286 => 16286,
          16290 => 16290
        };
DESTROY: testdb


program two: (started while program one waits on your keystroke)
------------
open database... < blocked until you press enter for program one >
can't tie testdb: Resource temporarily unavailable at ./gdbm_test.pl
line 10


I don't understand this at all! The first program unlocks *after*
untieing the GDBM_File (in the destructor method of the class), so
what's the problem? It seems that as long as the first process lives the
second is unable to open the GDBM_File.

Here's my testcode:

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

use strict;
use Data::Dumper;

$| = 1;

main: {
	print "open database...\n";
	my $lk = new LKDB ("testdb");
	
	print "insert a value (press enter): ";
	<STDIN>;
	
	$lk->{hash}->{$$} = $$;
	
	print "dump database...\n";
	print Dumper ($lk->{hash});
}

package LKDB;
use strict;
use Carp;
use FileHandle;
use GDBM_File;
use Fcntl ':flock';

sub new {
	my $type = shift;
	my ($filename) = @_;
	
	my $lock_file = "$filename.lck";
	my $fh = new FileHandle;
	
	open ($fh, "> $lock_file")
		or croak "can't write $lock_file";
	flock ($fh, LOCK_EX)
		or croak "can't flock $lock_file";
	
	my %hash;
	tie ( %hash, 'GDBM_File', $filename,
	      &GDBM_File::GDBM_WRCREAT, 0660)
		or croak "can't tie $filename: $!";

	my $self = {
		fh => $fh,
		filename => $filename,
		lock_file => $lock_file,
		hash => \%hash
	};
	
	return bless $self, $type;
}

sub DESTROY {
        my $self = shift;
	
	print "DESTROY: $self->{filename}\n";
	
        untie %{$self->{hash}}
		or croak "can't untie $self->{filename}";
	flock ($self->{fh},LOCK_UN)
		or croak "can't unlock $self->{filename}.lck";
        close $self->{fh};
}
---cut---

I checked this under Solaris 7 Sparc (Perl 5.004_04) and Linux (Perl
5.005_03).

Does anyone has an idea what's going wrong?

Thanks in advance,

Joern

-- 
Joern Reder -- joern@netcologne.de
countdown:     2653 hours, 17 minutes
supporting:    http://www.zyn.de/y2k/
unbelievable:  http://www.netcologne.de/~nc-joernre/


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

Date: Sat, 11 Sep 1999 15:15:31 -0500
From: Eric Brown <brownen@stolaf.edu>
Subject: Re: Could someone break this down for me?
Message-Id: <37DAB863.41399F15@stolaf.edu>

Paul Kester wrote:
> 
> I am trying to find out some information on what a specific section of > code means in a line..
> 
> The code I am inquiring about is two slashes "/\"  I have seen many
> references to it, but not what exactally it does..
> 
> Here is an example of a line that has it in the coding:
> 
> ($stocknum,$name,$price,$status) = split(/\|/,$i);
> 

The split function takes a regular expressions as an argument.  What
/\|/ does is split the text in the variable $i at every pipe (|).  Since
the pipe is a symbol that has special meaning in a regular expression it
has to have a backslash before it to be treated as text.  Other special
characters are (, ), [, ], ., and *.  To use any of these you have to
precede them with a backslash.  If you wanted to have your columns
separated by a character that isn't special such as a colon (:) you
could use split(/:/,$i);

Enjoy,
Eric


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

Date: Sun, 12 Sep 1999 11:24:10 +0200
From: Werner Diwischek <werner@hiz.de>
Subject: Discussion: compiled perl program as shareware
Message-Id: <37DB713A.59EF1C2E@hiz.de>

Hallo,

I'm developing perl programms within projects since four years, and now
one programm is ready to be distributed as shareware in the compiled
version. I had a lot of benefits from the perl modules for interfaces.

What do you think about it?!

best regards

Werner

PS. The core-parsing-module of my programm will be distributed as source
code for free.
--
---------------------------
Werner Diwischek
Web-Publishing
Siegenburgerstr.33
81373 München
Tel.: 0172/8520642
Fax: 089/74370713
http://www.hiz.de/eng/index.htm
werner.diwischek@hiz.de
---------------------------




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

Date: 12 Sep 1999 07:09:39 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: division by zero
Message-Id: <37db51b3$0$214@nntp1.ba.best.com>

RAGGMOPP <raggmopp@ix.netcom.com> wrote:

>    $tot = $veg + $fruit;
>    $perveg = ($veg  /  $tot) * 100;
>    $perfru = ($fruit / $tot) * 100;

Decide what you want to have happen in cases where $tot equals 0, and
then make it so. For example, you could put this after the assignment
to $tot:

if ($tot == 0) { $tot = 1 }

which would avoid the divide-by-zero, and leave you with 0 in $perveg
and $perfru (assuming $veg and $fruit are both 0).

-- 
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Sun, 12 Sep 1999 16:08:09 +0900
From: "Dan and/or Shelly" <wedeking@msa.attmil.ne.jp>
Subject: how is the best way to search the perl newsgroup archives?
Message-Id: <7rfjfo$ilf$1@news.misawa.attmil.ne.jp>

I found an ftp site that is supposed to have perl archives but nothing
happens when I try to go to:  ftp.cis.ufl.edu:/pub/perl/comp.lang.perl

does anyone have a better site to search the perl archives?  What is the MH
pick
command?  I read it is supposed to make it easy to search all 18000 articles
in the perl archives.

Dan




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

Date: Sun, 12 Sep 1999 12:57:20 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: I want to exit my script without sending anything back to the users   browser
Message-Id: <LDLC3.1273$rf1.7749@news1.online.no>


Abigail <abigail@delanet.com> wrote in message
news:slrn7tm1g6.71l.abigail@alexandra.delanet.com...
> cLive hoLLoway (cLive@direct2u.co.uk) wrote on MMCCI September MCMXCIII
> in <URL:news:37D95B5E.4F19DF0D@direct2u.co.uk>:

> %% I would also add an onSubmit javascript to your form so that the user
> %% gets a pop-up alert() saying 'Thank you for submitting your form. This

> And people who don't do JavaScript will just keep on clicking?

Well, onSubmit is at least a bit more friendly than onClick=this.form.submit
(or something similar)

--
Trond Michelsen






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

Date: Sun, 12 Sep 1999 15:56:58 +0800
From: Crom <gn888@hotmail.com>
Subject: Newbie Q: Web Crawling
Message-Id: <37DB5CC9.DC7D2193@hotmail.com>

I about to attempt (sigh!) making a perl-based website.  I have never
used perl before but am a reasonable programmer using other languages
such as C, Cobol, Pascal, blah blah blah.  So I am not new to
programming.   I have been reading all a gazillion of PERL docs
everywhere and can't seem to nail down a command or method to do web
crawling.  This is driving me nuts.  I am sure it is a piece of cake for
some of you experts.

What I am looking to do:  Given a URL, e.g. http://www.targetsite.com,
retrieve the top level web page and search for a particular word and
print out the line.

I would really love to have the webpage source in some sort of an array
for further manipulation, much like a very long string in C.  I am
looking to search some really long text pages.  Other functions I am
looking to implement is to print out the previous 10 characters and the
next 10 characters after the found keyword.

I read some of the manuals and most of the examples are looking through
a bunch of html files in a given directory.  Is there an equivalent of
Fileopen("d:\myfile.dat") like HttpOpen("http://www.targetsite.com/")?
Then used some sort of a read to stuff it all into an array for
processing?

Heeeeelp.  This is driving me nuts just thinking about it..........

Gerard



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

Date: 12 Sep 1999 09:19:37 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Newbie Q: Web Crawling
Message-Id: <7rfr79$o49@dfw-ixnews17.ix.netcom.com>

Crom (gn888@hotmail.com) wrote:
: What I am looking to do:  Given a URL, e.g. http://www.targetsite.com,
: retrieve the top level web page and search for a particular word and
: print out the line.

The LWP module has methods for retrieving Web resources, and comes with 
excellent documentation.  If it's not already on your system, get it from 
CPAN.  It can be as simple as:

use LWP::Simple;
my $content=get('http://www.targetsite.com');
#do something with the returned string.




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

Date: Sun, 12 Sep 1999 10:55:28 GMT
From: psw@net1plus.com (Peter Wilford)
Subject: Operating system problems?
Message-Id: <37db79b9.175881531@news.net1plus.com>

I am quite new to Perl, so please forgive the foolish questions...

I am running Windows '98, which I realize is not Win32, but I have no
choice due to other applications which require Win '95/'98...

I have written a small routine to help me do a system backup for a
small home network (using ethernet).  However, when I attemp to 'use'
the Win32::NetResource module, it won't parse, and comes back with an
error in my debug window, which states:

 'Can't load the
C:/Perl/site/lib/auto/Win32/NetResource/NetResource.dll' for module
Win32::NetResource: load_file: A device attached to the system is not
functioning at C:/Perl/lib/DynaLoader.pm at line 169.'

If I 'use' the File::Basename module all of the functions are work and
are available to me from that module

Here is a code sample:

use Win32;
use Win32::NetResource;
use File::Basename;


$ShareInfo = {
                    'path' => "D:\\",
                    'netname' => "psw_D",
                    'remark' => "It is good to share",
                    'passwd' => "",
                    'current-users' =>0,
                    'permissions' => 0,
                    'maxusers' => -1,
                    'type'  => 0,
                    };
    
    Win32::NetResource::NetShareAdd( $ShareInfo,$parm )
        or die "unable to add share";

The above 'snippet' fails to parse, however the following line of code
works correctly in the same script:

	($base,$path,$type) = fileparse($lentry{ZipFile});

My question is, is it because I am using Win'98 that I get a load
module failurein the NetResource module?  The error seems to be
indicating a problem with the 'Hardware Access Layer' (HAL) on the Win
NT platform...  Could this be true?  Has anyone else had the same
problem?  Any help would be appreciated...

Thanks, and I look forward to your responses...

Peter Wilford




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

Date: Sun, 12 Sep 1999 10:10:04 +0200
From: "Martin McMahon" <icsmc@iafrica.com>
Subject: Perl Language Reference
Message-Id: <7rfn5s$24ch$1@nnrp01.ops.uunet.co.za>

Hi

Does anyone know where I can find a comprehensive Perl language reference?
Thanks.

Peter




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

Date: Tue, 7 Sep 1999 18:01:09 +1000
From: "Nick Read" <nickread@primus.com.au>
Subject: Re: Perl's underlying implementation of Arrays - Low Priority
Message-Id: <937123833.883109@diddley.primus.com.au>


Dan Sugalski <dan@tuatha.sidhe.org> wrote in message
news:hG_z3.154$lT.757@news.rdc1.ct.home.com...
> Nick Read <nickread@primus.com.au> wrote:
>
> When you shift things off the front of the array, perl just moves the
> 'beginning of array' pointer over by one. When you pop something off the
> end it just moves the end of the array pointer. When you unshift something
> on, perl will move the beginning pointer if there's empty space at the
> beginning or really shift everything over if there's not. When you push on
> the end, perl will just move the end of array pointer if there's unused
> space (which there often is, as perl allocates some padding for just such
> an occasion) or reallocs the array if there isn't. Inserting into the
> middle causes perl to do a block move of everything past the insert point.

I agree, this is a much more simpler and efficient implementation than using
linked lists.

One question then.... what is the default allocation size of this array?  Or
put differently, how many elements can you store in a Perl array before it
requires reallocation?

Best Regards,
Nick Read

==========================
"A wide screen just makes a bad film twice as bad."

 -- Samuel Goldwyn
==========================




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

Date: Tue, 7 Sep 1999 18:02:53 +1000
From: "Nick Read" <nickread@primus.com.au>
Subject: Re: Perl's underlying implementation of Arrays - Low Priority
Message-Id: <937123834.776471@diddley.primus.com.au>

> I haven't personally used linked lists in 'C' since my first programming
> job.

Ah, but are you sure you haven't used them without noticing!!!  For example,
Trees

Best Regards,
Nick Read

==========================
"...the wisest prophets make sure of the event first."

 -- Horace Walpole
==========================





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

Date: Sun, 12 Sep 1999 08:47:42 GMT
From: marcza@my-deja.com
Subject: Problems with Net::POP3->list
Message-Id: <7rfpbc$i52$1@nnrp1.deja.com>

Everything seems to be o.k. with my implementation of Net::POP3
(see bottom) under Linux. New works, login works - but list does NOT
work.

The Debug output looks similar to:
<SNIP>
Net::POP3: Net::POP3(2.09)
Net::POP3:   Net::Cmd(2.0801)
Net::POP3:     Exporter
Net::POP3:   IO::Socket::INET
Net::POP3:     IO::Socket(1.1602)
Net::POP3:       IO::Handle(1.1504)

Net::POP3=GLOB(0x80cccd8)<<< +OK POP3 xxxxxx.xxx v4.39 server ready
Net::POP3=GLOB(0x80cccd8)>>> USER yyyyyy
Net::POP3=GLOB(0x80cccd8)<<< +OK User name accepted, password please
Net::POP3=GLOB(0x80cccd8)>>> PASS ....
Net::POP3=GLOB(0x80cccd8)<<< +OK Mailbox open, 6 messages
Net::POP3=GLOB(0x80cccd8)>>> LIST
Net::POP3=GLOB(0x80cccd8)<<< +OK Mailbox scan listing follows
Net::POP3=GLOB(0x80cccd8)>>> QUIT
Net::POP3=GLOB(0x80cccd8)<<< +OK Sayonara

</SNIP>

The print output is m= N=0#0#
The foreach loop is never executed (entered) but there ARE definitively
messages in the queue !

What does "Mailbox scan listing follows" mean ? Where and WHEN is it
printed ? Is there a time lag between call of list and returning the
list ?

How do I get all the 6 announced msgid's ???

Bye

Marcus


sub get_mail {

 $pop = Net::POP3->new($mailserver, 'Debug' => 9)  or die "Can't open
connection to $mailserver : $!\n";
 $pop->login($username, $password)  or die "Can't authenticate: $!\n";
 $messages = $pop->list or die "Can't get list of undeleted messages:
$!\n";
 print "m=$messages N=".(keys %messages)."#".(%messages)."#"\n");
 foreach $msgid (keys %messages) {
   $message = $pop->get($msgid);
   unless (defined $message) {
    warn "Couldn't fetch $msgid from server: $!\n";
    next;
   }
  $pop->delete($msgid);
 }
}


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


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

Date: 12 Sep 1999 09:25:17 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Problems with Net::POP3->list
Message-Id: <7rfrht$o49@dfw-ixnews17.ix.netcom.com>

marcza@my-deja.com wrote:
: Everything seems to be o.k. with my implementation of Net::POP3
: (see bottom) under Linux. New works, login works - but list does NOT
: work.

[snip]
:  $messages = $pop->list or die "Can't get list of undeleted messages:
: $!\n";

$messages is a *reference* to a hash.  %messages is something else entirely.

:  print "m=$messages N=".(keys %messages)."#".(%messages)."#"\n");
:  foreach $msgid (keys %messages) {

You need to dereference the hash in these two lines.


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

Date: Sun, 12 Sep 1999 09:45:04 +0200
From: Stijn Jonker <s.j.c.jonker@getronics.nl>
Subject: Q: regarding clibrary usage.
Message-Id: <37DB5A00.EC92F3F8@getronics.nl>

Hello all,

I'm looking for a step by step guide to use a c library from perl. I
readed perlxs perlxstuts and h2xs. But my C knowledge just doesn't cut
it somehow.


I want to use the libsensors from perl  (http://www.netroedge.com/~lm78)
but every time i tried as in the perlxs or perlxstut pages and via swig
it barfs and i have nog clue why.
So if there are some more examples plz give me a url.


-- 
Met Vriendelijke groet/Yours Sincerly
Stijn Jonker               __   _
                          / /  (_)__  __ ____  __
  joker@sjc.nl           / /__/ / _ \/ // /\ \/ /  
  s.jonker@multiweb.nl  /____/_/_//_/\_,_/ /_/\_\ 
            * * * THE CHOICE OF A GNU GENERATION * * *


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

Date: Sun, 12 Sep 1999 08:45:07 GMT
From: horan@inetarena.com
Subject: Question about perlembed
Message-Id: <7rfp6i$hts$1@nnrp1.deja.com>

I'm working on embedding Perl in a C app, and I want to be able
to set up an environment. The last arg to perl_parse below is
a pointer to an array of strings, representing the environment to
be set up. I just dont have a clue about how to represent this
environment. Can anyone help in terms of some sample code that
creates a couple environment variables I can pass to this function?

perl_parse(my_perl, xs_init, argc, argv, env);


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


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

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

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

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 769
*************************************


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