[7670] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1296 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 10 14:14:55 1997

Date: Mon, 10 Nov 97 11:00:42 -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           Mon, 10 Nov 1997     Volume: 8 Number: 1296

Today's topics:
     Re: CPAN confusion <zenin@best.com>
     Re: CPAN confusion (Honza Pazdziora)
     Re: Decimal rounding and lining up decimals? <jaydee@worsdall.demon.co.uk>
     Re: Distribution of perl for windows platforms <zenin@best.com>
     Re: glob not working (Umm)
     Re: Help! with CGI (Pete Barker)
     Re: interrupt system("$cmd") if timeout <jay@rgrs.com>
     IPC module implemented in Perl5.004/Windows_NT? <Sudhir_Kadkade@SiFR.com>
     Re: is it possible to reference a sub-array? (+ questio <zenin@best.com>
     Job in UK:  Internet Programmer for Foresight New Media (Stewart Dean)
     Re: multithreading <zenin@best.com>
     Re: multithreading <tchrist@mox.perl.com>
     Re: Passing Variables <dchavez@horizonint.com>
     Re: Passing Variables (Pete Barker)
     perl 5 good simple book? <mehta@mama.indstate.edu>
     Perl and MAPI (COWBYS)
     Re: PERL interpreter in Java? <zenin@best.com>
     perl script for generating simple web page <saul@utb1.utb.edu>
     Problem with read (COWBYS)
     Re: Problem with read (Honza Pazdziora)
     Problems with Win32 Perl 5.00402 on NT 4.0 <kim.kulasa@daytonoh.ncr.com>
     Problems:need help <icer@vacationtime.net>
     Re: Problems:need help (Mike Stok)
     Re: Problems:need help (Henry Gabryjelski)
     Re: Problems:need help (Honza Pazdziora)
     SQL statement in Perl <henry@DotRose.com>
     Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 10 Nov 1997 15:27:20 GMT
From: Zenin <zenin@best.com>
Subject: Re: CPAN confusion
Message-Id: <64794o$ddn$1@nntp2.ba.best.com>

Kermit Tensmeyer <kermit@ticnet.com> wrote:
:   I doubt if the win32 version of perl can be used across the net
: either.
	>snip<

	Actually, the Winsock module does a pretty good job of maping
	IO::Socket calls correctly.  I've had most of my networking
	programs run with little or no modifications.  I'd be surprised
	if it didn't work, actually.

:    If and only if you are using a Unix workstation on the bare network.

	Like I said, Winsock support is pretty darn good.  As for your fire
	walls, can't the Net::* stuff be configured to get through them?  I
	could have swarn I saw that option fly by when installing it.

-- 
-Zenin (zenin@best.com)
 The Bawdy Caste (San Jose, CA)       http://www.netmagic.net/~dmcgrath/bawdy/
 Barely Legal   (Berzerkly, CA)                    http://www.barelylegal.org/
 Zenin's Rocky Archive (Moving soon!)              http://www.best.com/~zenin/


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

Date: Mon, 10 Nov 1997 15:26:40 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: CPAN confusion
Message-Id: <adelton.879175600@aisa.fi.muni.cz>

Kermit Tensmeyer <kermit@ticnet.com> writes:

[...]

> >         readme modulename
> 
>   and the assumption is that perl can connect to the CPAN site all on
>  it lonesome..  not a good assumption. 
>   At work I sit behind a firewall. I can browse the CPAN site all I want
>  with a browser, but the CPAN module can not connect unless the perl
>  is socksified.
> 
>   I doubt if the win32 version of perl can be used across the net
> either.

Unfortunately (or fortunately for me ;-) I do not really know where
the problem with Windoze is. However, I believe that the
improvements should be done on the low-lever (e.g. probaly Perl here)
side, so that all the higher lever interface could relly on that.

>  so providing a pod-html or cgi interface to provided modules would be
>  a Good Thing. If done "right", then it could provide some method
>  to tell the difference between various versions as well.

Yes, but on cgi level, not as extracted html documentation in CPAN.
And since you have to consider the variability of ftp/http servers
that mirror the site, you have to be on the GCD to allow every of them
to be usable.

So, you are welcome to write module that would provide the module
docs on the fly in the httpd and I will be glad to make my httpd
administrator to add it to our http CPAN mirror but I do not want
CPAN to grow in size just because of the duplicate docs.

>    As I recall there are some amazing transformations of data formats
>  available in WuFTPD. Given the general nature of Perl, and the
>  integration of Perl with Httpd servers this should be a natural
>  enhancment of basic facility.

Not portable.

>   And no, most of the readme's associated with the Modules are 
>  lacking in Detail.  (but that's an Author problem)
> 
>    [ for examples of how it _should_ be done look at the CGI.pm
>      or any of Graham Barr's IO modules. If they all were done
>      that way then this would be a no-brainer...  ]

Well, I am not really sure that README's with either CGI and IO would
give you enough information whether you need the module or not. Most
of the readmes have short summary (but you might not understand it if
you are not familiar with the goals), installation instructions and
links to other information sources (usually base URL for the module).

[...]

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Mon, 10 Nov 1997 17:39:46 +0000
From: Mark Worsdall <jaydee@worsdall.demon.co.uk>
Subject: Re: Decimal rounding and lining up decimals?
Message-Id: <vCGGQBAib0Z0EwFG@worsdall.demon.co.uk>

In article <Pine.OSF.3.95q.971109041721.22043C-100000@osf1.gmu.edu>,
shiva mantri <smantri@gmu.edu> writes
>use printf function 
>       printf "%2.2f", $dollar_val;
>
        $total = int($total * 100) / 100;

But the previous method was more sexy, with currency I believe rounding
down is the correct way also I have been told that one should do all
ones work in pence or cents (whole numbers) stored in integers then when
necessary to display/write devide 100.

-- 
Mark Worsdall - Oh no, I've run out of underpants :(
Home:- jaydeeATworsdall.demon.co.uk  WEB site:- http://www.worsdall.demon.co.uk
Shadow:- webmasterATshadow.org.uk    WEB site:- http://www.shadow.org.uk


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

Date: 10 Nov 1997 16:09:53 GMT
From: Zenin <zenin@best.com>
Subject: Re: Distribution of perl for windows platforms
Message-Id: <647bkh$ddn$5@nntp2.ba.best.com>

Aviel Rubin <rubin@quip.eecs.umich.edu> wrote:
: 2. Has anyone considered a self-extracting, self-installing distribution
:    of perl for windows, say perl.exe?

	Yes.  But that's all I've done.  Considered it. :-)

: Perhaps an Installshield version would be best.

	I would LOVE this myself.  If it combined the Tk::* modules
	I'd be a _vary_ happy camper.

: 3. Is there any other way to target users who may not have tar or
:    gzip, and may not be that sophisticated, but who we still want
:    to have and use perl on their system? Is this a consideration any
:    of the lords of Perl have thought of?

	If you're on a Unix system and have installed unix zip(1):

	gunzip < perl-XXXX.tar.gz | tar -xvf - && zip -mk9r perl.zip perl-XXXX

-- 
-Zenin (zenin@best.com)
 The Bawdy Caste (San Jose, CA)       http://www.netmagic.net/~dmcgrath/bawdy/
 Barely Legal   (Berzerkly, CA)                    http://www.barelylegal.org/
 Zenin's Rocky Archive (Moving soon!)              http://www.best.com/~zenin/


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

Date: 10 Nov 1997 18:15:55 GMT
From: l41484@alfa.ist.utl.pt (Umm)
Subject: Re: glob not working
Message-Id: <647j0r$8pq$1@ci.ist.utl.pt>

Andrew M. Langmead (aml@world.std.com) wrote:
: l41484@alfa.ist.utl.pt (Umm) writes:
: >what i've discovered is (someone correct me if i'm wrong) perl relies on the
: >csh to glob, and i don't have csh installed. :-(

: If perl is trying to use the C shell, and there is none present, then
: your perl is misconfigured. (Most likely, it was configured on a

:-( How can re-configure it? (presuming it can be done without recompiling)

: machine that did have csh present and the binary and associated files
: were copied to your machine with a different "Configuration".

i don't think so. Anyway i've tried to make a csh link to bash, and no
sucess either. Can this hack have some sort of sucess??

--
                         Tiago Umm Pascoal
                    'The unstoppable mail machine'
                        l41484@alfa.ist.utl.pt

 I believe in making trouble. If women have any duty at all, essentially
it's to be a pain in the arse. (avital ronell)



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

Date: 10 Nov 1997 17:08:21 GMT
From: on.maps.barker@cix.co.uk (Pete Barker)
Subject: Re: Help! with CGI
Message-Id: <memo.19971110170703.151B@mt.cix.co.uk>

In article <01bcec37$f4042500$243f86c2@default>, medcon@euronet.nl
(Alwin Bijvoet) wrote:

>
>
> Toutatis <toutatis@_SPAMTRAP_toutatis.net> wrote in article
> <toutatis-ya023180000711971436070001@news.euro.net>...
> > Alwin Bijvoet <info@audiovisueel.com> wrote:
> >
> > > Hello,
> > >
> > > I am using win95
> > > I installed perl for Win32 Build 306 (apr 97)
> > > I am using frontpage97
> > > The problem:
> > > When I try tu run a cgi-script I get the error message:
> > >
> > >   CGI Error
> > >   The specified CGI application misbehaved by not returning
a comple
> te
> set
> > > of HTTP headers. The headers it did return are:
> > >   Can't open perl script "_vti_cnf": Permission denied
> > >
> > > What to do?
> >
> > Jump out of the window.
> >
>
> I won't help. I am working in the basement.
> Thanks anyway
>
> > --
> > Toutatis
> >
>

Have you put the script in the correct virtual directory, and
referenced it properly in your HTML? For example, a script
residing in \Inetpub\wwwroot\cgi-bin called fred.pl should be
referenced in the HTML as /cgi-bin/fred.pl.

Also, make sure that you have the proper registry entry to allow
IIS to run Perl scripts. This is as follows...

HKEY_LOCAL_SYSTEM
  System
    CurrentControlSet
      Services
        W3Svc
          Parameters
            Script Map
              .pl: REG_SZ: <PATHTOPERL>\BIN\PERL.EXE %s %s

I'm assuming you are using IIS for your server, as I had
exactly the same error message. Hope this helps you.

Pete Barker
P.S. Please remove on.maps. to mail me.



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

Date: 10 Nov 1997 13:39:20 -0500
From: Jay Rogers <jay@rgrs.com>
To: Helina Chan <helina@torus.eng.yale.edu>
Subject: Re: interrupt system("$cmd") if timeout
Message-Id: <82ra8otwyv.fsf@shell2.shore.net>

Helina Chan <helina@torus.eng.yale.edu> writes:

> Cameron Simpson wrote:
> 
> > Helina Chan <helina@torus.eng.yale.edu> writes:
> > |     I could not find information about interrupting
> > | a process started by system("$cmd") if a specified timeout
> > | occured.
> > |     For example, rsh will time out in 75 seconds if the
> > | remote machine is down. Suppose I want to do
> > |     system("rsh $host $cmd");
> > | and if it did not succeed in $timeout seconds, interrupt
> > | the above process and print out "system is down".
> >
> > You need to break the system() up - internally it sort of goes
> >
> >         Parent program  Child program
> >
> >         fork()
> >               --------->exec(sh,-c,$cmd)
> >         wait()...       ... child runs ...
> >                         exit()
> >               <--------
> >         wait() returns
> >         ... parent continues ...
> >
> > Use fork() instead of system. In the child, set an alarm for 75 seconds.
> > Then wait() in the parent, more or less as normal.
> >
> > See fork(), exec(), alarm(), waitpid().
> 
>   Thanks for your help. However, it does not seem to work.
> The problem is that, at least tested on my linux machine,
> sh spawns another process. So after the sh process timed
> out, its child continues. Here is an example code:

The easy specific way to fix your problem is to do the output
redirection yourself instead of relying on the shell.

Change:

    exec (qq(sh -c "ls -lR / > /tmp/ls.out 2>/dev/null"));

to:

    open STDOUT, ">/tmp/ls.out"
        or die $!;
    open STDERR, ">/dev/null"
        or die $!;
    exec "ls -lR /"
        or die $!;
    
For a more general approach to killing a process and ensuring that all
its children die, you need more advanced unix ipc techniques.

A unix process belongs to a process group.  When you create a process
that you might want to potentially timeout - place it in its own
process group.  By default, any children that it in turn creates will
also be in that process group.

Note that when you create a new process group, the perl debugger will
no longer be able to follow that process.  You can always comment out
the line that creates a new process group while debugging.

When it comes time for the parent to "timeout" the command, you can
send a signal to the entire process group.  You do this in perl by
indicating a negative signal to kill()

    kill -1, $pid;

Here's some code that illustrates:

    unless ($pid = open CMD, "-|") {  # we're the child process
        die $! unless defined $pid;  # fork failed
        
        ## Create a new process group.
        setpgrp(0, $$)
            or die;
    
        exec "ls -lR / >/tmp/ls.out 2>/dev/null"
            or die $!;
    }
    
    if (&timed_out(1.5, \*CMD)) {
        kill -1 => $pid;  # a negative signal sends to process group
        warn "command timed-out\n";
    }
    
    close CMD;
    warn "command exited with non-zero status\n" if $?;
    
    
    sub timed_out {
        my($timeout_secs, $handle) = @_;
        my $rin;
    
        vec($rin='', fileno($handle), 1) = 1;
        if (select $rin, undef, undef, $timeout_secs) {  # handle finished
            return '';
        }
        else {  # handle timed-out
            return 1;
        }
    }

--
Jay Rogers
jay@rgrs.com


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

Date: Mon, 10 Nov 1997 10:08:21 -0800
From: "Sudhir D. Kadkade" <Sudhir_Kadkade@SiFR.com>
Subject: IPC module implemented in Perl5.004/Windows_NT?
Message-Id: <647ibn$5ke@dfw-ixnews3.ix.netcom.com>

Hi all,
I am trying to use the IPC module on WinNT (specifically the open3 function)
to capture all the output and provide all the input to a child process. I'm
trying
to provide the same functionality as Expect in a Perl script.

When I tried to do this in Perl 5.004_02 (from Gurusamy Sarthy) it complains
that fork() is not implemented. If this is true then how does system work?
Does it not require fork() too?

BTW, is it possible to capture output from the child process to the console
and provide input that it expects from the console from the Perl script?

The code I wrote to test the IPC feature was:
#!/bin/perl -w
# mostly copied from the "Programming Perl" book by Wall, et al.
use lib "c:/perl/lib";
use IPC::Open2;
use Symbol;
$WTR = gensym();
$RDR = gensym();
$pid = open2($RDR, $WTR, 'echo');
print @INC;
while (<>)
{
    print $WTR $_;
    $line = <$RDR>;
    print "sdk: $line";
}

Thanks,
Sudhir

P.S. If perl -v reports "This is perl, version 5.004_02", why does
require 5.004 not work? It claims I am using 5.002!



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

Date: 10 Nov 1997 16:02:12 GMT
From: Zenin <zenin@best.com>
Subject: Re: is it possible to reference a sub-array? (+ question!)
Message-Id: <647b64$ddn$3@nntp2.ba.best.com>

Mark Mielke <markm@nortel.ca> wrote:
: Is there a way then to do the following C code in perl?
	Hmm, funky.  I hate C, but this is it:

	sub my_function {
	    my @ARGV	= @_;
	    printf "%s %s\n", ${ $ARGV[0] }, ${ $ARGV[2] };
	}

	my_function ( \(@ARGV[0..$#ARGV]) );
	my_function ( \(@ARGV[2..$#ARGV]) );

	I do not however, recommended _ever_ doing this in production code.
	Playing with array slice references is just begging for pain...

: This is what the persons original question was. As you pointed out, my
: example doesn't work for "pass by reference" if you wish to modify @ARGV
: (something that shouldn't be done anywayz?)

	That depends.  I've writen a few apps that allow settings by both
	command line, and config file.  They read the config file first and
	plug any extra needed options into the @ARGV, before passing the
	thing off to Getopt::Long::GetOptions().

-- 
-Zenin (zenin@best.com)
 The Bawdy Caste (San Jose, CA)       http://www.netmagic.net/~dmcgrath/bawdy/
 Barely Legal   (Berzerkly, CA)                    http://www.barelylegal.org/
 Zenin's Rocky Archive (Moving soon!)              http://www.best.com/~zenin/


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

Date: Mon, 10 Nov 1997 16:46:36 GMT
From: stewart@foresight.co.uk (Stewart Dean)
Subject: Job in UK:  Internet Programmer for Foresight New Media
Message-Id: <346739dd.22629583@news.demon.co.uk>

PROGRAMMING JOBS AT  FORESIGHT

Foresight New Media is part of a Foresight Europe based in West
London, a promotion company with many clients in the  entertainment
market .  Foresight New Media produces  a wide range of new media
solutions  for companies such as Disney, Sun, British Telecom, Fox and
Paul Smith. We have been around for  over  3 years, have over 20 full
time staff and are one of the most successfull, and fun,  new media
companies in the Europe.  

For more details see  http://www.foresight.co.uk   


SENIOR PROGRAMMER 

We are looking for someone with ideally 2 + years experience with on
line environments. You need to be knowledgeable with web site creation
and the specialist problems they face. creation. Experience in
intergrating relational or object based databases with web front ends
is needed.  Your skills should include as many as possible of the
following. 

CGI (Perl, C) scripting, Java, C++, SQL, Html

JUNIOR PROGRAMMER 

To support our web production team we are looking for a programmer
with CGI, Java and some database knowledge. You would ideally have a
computer science degree or have solid industry experience. You will
have an understanding of web sites and ideally had at least 6 months
experience in dealing with on line applications


If you are interested please send your cv by email to Gifford
Morley-Fletcher:
gifford@foresight.co.uk or by post to:
Gifford Morley-Fletcher, Foresight New Media, 3-4 Galena Road, London,
W6 OQT





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

Date: 10 Nov 1997 16:04:08 GMT
From: Zenin <zenin@best.com>
Subject: Re: multithreading
Message-Id: <647b9o$ddn$4@nntp2.ba.best.com>

Thane & Leslie Eisener <thaneles@removethis.cyberus.ca> wrote:
: I have a script that gathers data from the network for me three times.
: Currently these are performed in series.  How can I make these three
: function all at the same time?

	Assuming (danger!) a _real_ OS:

	perldoc -f fork

	Hope this helps! :-)

-- 
-Zenin (zenin@best.com)
 The Bawdy Caste (San Jose, CA)       http://www.netmagic.net/~dmcgrath/bawdy/
 Barely Legal   (Berzerkly, CA)                    http://www.barelylegal.org/
 Zenin's Rocky Archive (Moving soon!)              http://www.best.com/~zenin/


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

Date: 10 Nov 1997 16:24:22 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: multithreading
Message-Id: <647cfm$667$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "Thane & Leslie Eisener" <thaneles@cyberus.ca> writes:
:I have a script that gathers data from the network for me three times.
:Currently these are performed in series.  How can I make these three
:function all at the same time?

You learn how to use select() and I/O multiplexing.  No fork, 
no thread.  Get Steven's book on Unix Network Programming.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    "Nowadays people just don't distinguish between prudence and paranoia."
    	--Larry Wall


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

Date: Mon, 10 Nov 1997 09:33:13 -0700
From: Dale Chavez <dchavez@horizonint.com>
Subject: Re: Passing Variables
Message-Id: <34673749.716230FA@horizonint.com>

Myles Lawrence wrote:

> I tried this under NT and nothing. Is there and equivalent to the $ENV
> variables?

I ran into the same problem with NT.  I thought it was me!

Dale



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

Date: 10 Nov 1997 17:08:15 GMT
From: on.maps.barker@cix.co.uk (Pete Barker)
Subject: Re: Passing Variables
Message-Id: <memo.19971110170657.151A@mt.cix.co.uk>

In article <un5iAcM78GA.244@upnetnews03>,
myleslawrence@email.msn.com (Myles Lawrence) wrote:

> I tried this under NT and nothing. Is there and equivalent to
the $ENV
> variables?
> myleslawrence@msn.com
> Mark Mielke wrote in message ...
> >Dale Chavez <dale@horizonint.com> writes:
> >
>
>
>
>

With a little adjustment, Mark's scripts worked under NT for me...

Script A (a.pl)
---------------
$ENV{COMMAND} = "Be Happy!";
system "PERL b.pl";

Script B (b.pl)
---------------
print $ENV{COMMAND},"\n";

Under NT4, system "b.pl" would work assuming file associations are
setup ok, but under NT 3.51, you need to prefix with PERL to
explicitly tell the command interpreter the program to run.

Regards,

Pete Barker
P.S. Please remove on.maps. to mail me.



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

Date: Mon, 10 Nov 1997 03:12:14 GMT
From: Miten S Mehta <mehta@mama.indstate.edu>
To: Gary Howland <ghowland@hotlava.com>
Subject: perl 5 good simple book?
Message-Id: <Pine.LNX.3.96.971109220801.32306A-100000@mama.indstate.edu>


11/9/97

Hello Perl guys,

I am wanting to learn perl 5 oo stuff.  I have read the perl programming
book by Randal and it is somewhat hard for me when it gets to packages.
could you please guide?

I mean I want to write some classes and use them just as I would in java.
sorry about that.

Thanx.

Have a good day !!!

Best Regards,

Miten Mehta.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
Res:                                            |
Miten S Mehta                                   |
311 S Lasalle St, 39E,		                |
Durham, NC 27705                                |
Tel: 919 416 3889                               |             
e-mail: mehta@mama.indstate.edu                 |
resume url:                                     |
ftp://mama.indstate.edu/users/mehta/resume.html | 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~             





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

Date: 10 Nov 1997 15:57:22 GMT
From: cowbys@aol.com (COWBYS)
Subject: Perl and MAPI
Message-Id: <19971110155700.KAA00265@ladder02.news.aol.com>

Is there any way to use Perl to check a MS Exchange inbox for new messages, and
 say copy a new message to a file?

What I want to do is have it check for a new message, if there is a new
 message, copy that message to a file, and then ftp the file somewhere.

I AM using Perl (Win32) 5004 on NT 4.0 with IIS 3.0

Any advice greatly appreciated


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

Date: 10 Nov 1997 15:43:31 GMT
From: Zenin <zenin@best.com>
Subject: Re: PERL interpreter in Java?
Message-Id: <647a33$ddn$2@nntp2.ba.best.com>

Jim Voll <jjv@netapp-nospam.com> wrote:
: This may seem silly, but does anyone know of a PERL interpreter
: written in Java?

	No, but there is a Perl regexp engine in Java, somewere.  Check
	out the search engines.

-- 
-Zenin (zenin@best.com)
 The Bawdy Caste (San Jose, CA)       http://www.netmagic.net/~dmcgrath/bawdy/
 Barely Legal   (Berzerkly, CA)                    http://www.barelylegal.org/
 Zenin's Rocky Archive (Moving soon!)              http://www.best.com/~zenin/


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

Date: Mon, 10 Nov 1997 11:47:07 -0600
From: Saul Lopez <saul@utb1.utb.edu>
Subject: perl script for generating simple web page
Message-Id: <3467489B.8CACEE46@utb1.utb.edu>

Does anyone know of a simple perl script that takes the input of a form
and simply appends it to an HTML file?
I'd appreciate any help.



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

Date: 10 Nov 1997 15:43:29 GMT
From: cowbys@aol.com (COWBYS)
Subject: Problem with read
Message-Id: <19971110154300.KAA29773@ladder01.news.aol.com>

I am using the following code to read each line of a file, ($FILENAMES[2]),
and write each line of output to a variable ($One_Line), which then gets
 appended to another variable ($Data2_Send), which will eventually contain all
 of the lines of the file I am reading In ($FILENAMES[2]). The reason I am
 doing this is because I need to email the contents of my input file
 ($FILENAMES[2]), to someone , but the contents of the message has to be the
 actual file, they cant receive it as an attachment.

Anyway, my question is this:

$Data2_Send ends up being a line by line copy of my input file ($FILENAMES2]),
 just like I wanted,

 EXCEPT that its missing the last 4 or so lines.
It appears to either stop reading from my input file about 4 lines too soon, or
 it stops writing out to my output, is there some Perl limitation I am reaching
 here?, for the record, my input file is 400 lines long, and each line contains
 a record that is 105 chars (including spaces long).

HERES MY CODE:

$position=0;                                         # set so 1st read is from
 beginning of first line

open (READFROM, "$FILENAMES[2]") || die "cant open $FILENAMES[2]: $!\n";
print "\nReading from $FILENAMES[2]"; # this is only here for sending output to
 my log file
@records = <READFROM>;
foreach $record (@records) {                   
  seek(READFROM,$position*105,0);     # move to beginning of 1st line
  read(READFROM,$One_Line,105);      # read the entire line into $One_Line
  $Data2_Send .=$One_Line;                # append $One_Line to $Data2_Send
  $position++;                                      # increment $position so
 next read is from beginning  
                                                          # of next line

I tried using pack and unpack instead, with the same result... any advice?   
 TIA ....   DCF


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

Date: Mon, 10 Nov 1997 16:13:05 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Problem with read
Message-Id: <adelton.879178385@aisa.fi.muni.cz>

cowbys@aol.com (COWBYS) writes:

> I am using the following code to read each line of a file, ($FILENAMES[2]),

[...]

> $position=0;                                         # set so 1st read is from
>  beginning of first line
> 
> open (READFROM, "$FILENAMES[2]") || die "cant open $FILENAMES[2]: $!\n";
> print "\nReading from $FILENAMES[2]"; # this is only here for sending output to
>  my log file
> @records = <READFROM>;
> foreach $record (@records) {                   
>   seek(READFROM,$position*105,0);     # move to beginning of 1st line
>   read(READFROM,$One_Line,105);      # read the entire line into $One_Line
>   $Data2_Send .=$One_Line;                # append $One_Line to $Data2_Send
>   $position++;                                      # increment $position so
>  next read is from beginning  
>                                                           # of next line
> 
> I tried using pack and unpack instead, with the same result... any advice?   

Use

	$Data2_Send = join "", <READFROM>;

I can't really see a reason to first read the input into @records and
then use some seek'n'read to read it again.

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Mon, 10 Nov 1997 10:27:15 -0500
From: "Kim Kulasa" <kim.kulasa@daytonoh.ncr.com>
Subject: Problems with Win32 Perl 5.00402 on NT 4.0
Message-Id: <01bcedec$f8ced2e0$85e57fc0@aohkulask>

We have installed Win32 Perl5.004_02 on a Windows NT 4.0 server with SP3. 
Perl is used extensively for web scripting, primarily using Netscape
Enterprise Server 2.01 (although we also have IIS 3.0 running on another
port).  Prior to this, we were using the perl5.003 version from ActiveWare.

Since the installation of the newer version we have noticed that we have a
number of processes that are not completing successfully.  If we look at
the tasklist under NT, we can frequently see perl processes out there using
no processor time and little memory.  They just don't go away by
themselves.  If enough of these processes appear, it seems to degrade the
server performance.  With most perl processes, they show up briefly on the
tasklist then disappear.   

Does anyone have any ideas about what may be causing these processes to
hang around?  Our web site has about 5GB, and has a large group of
developers all over the world.  It is difficult to pin down which scripts
are causing the problem.  We have checked the error log, and so far have
not found any correlation between its entries and the lingering perl
processes on the tasklist.

We'd appreciate any help.

kim.kulasa@daytonoh.ncr.com


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

Date: Mon, 10 Nov 1997 11:01:31 -0800
From: David Maynor <icer@vacationtime.net>
Subject: Problems:need help
Message-Id: <34675A0B.14296AF8@vacationtime.net>

I am trying to write a prog in perl to scan a text file and copy certian
information out of it.
For instance I want to know wevery word that has a P in a text file, and
then everyword that has a q.
Any suggestions.



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

Date: 10 Nov 1997 17:00:15 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Problems:need help
Message-Id: <647eiv$2l5@news-central.tiac.net>

In article <34675A0B.14296AF8@vacationtime.net>,
David Maynor  <icer@vacationtime.net> wrote:
>I am trying to write a prog in perl to scan a text file and copy certian
>information out of it.
>For instance I want to know wevery word that has a P in a text file, and
>then everyword that has a q.
>Any suggestions.

You might want to read an introduction to perl suct as Learning Perl
published by O'Reilly & Associates as this is the kind of thing that
perl's pretty good at e.g.

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

while (<>) {
  foreach $word (/(\w+)/g) {
    print "$word\n" if $word =~ /p/;
  }
}
__END__

will print words containing p as they're found, but you might need a
different definition of 'word'...

If you have a recent veriosn of perl then the description of what's going
on can be found in the manual pages.

Hope this helps,

Mike
-- 
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: 10 Nov 1997 16:35:53 GMT
From: henryg@ernie.WPI.EDU (Henry Gabryjelski)
Subject: Re: Problems:need help
Message-Id: <647d59$4nu$1@bigboote.WPI.EDU>

David Maynor  <icer@vacationtime.net> wrote:
>I am trying to write a prog in perl to scan a text file and copy certian
>information out of it.
>For instance I want to know wevery word that has a P in a text file, and
>then everyword that has a q.
>Any suggestions.

perl -lne 'while ( /(\b\w*?[qP]\w*?\b)/g ) { print "$1" }'

You searched-for chars are ^^^^ there.

Minimal matching on word boundaries is done with \b\w*? for before the
characters you are looking for, and \w*?\b for after.  /g finds them
all.  I suggest the O'Reilly book "Programming Perl" <2nd ed>, and
read up on regular expressions, certainly one of the most powerful
features of Perl.

HTH,

Henry Gabryjelski




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

Date: Mon, 10 Nov 1997 16:56:29 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Problems:need help
Message-Id: <adelton.879180989@aisa.fi.muni.cz>

David Maynor <icer@vacationtime.net> writes:

> I am trying to write a prog in perl to scan a text file and copy certian
> information out of it.
> For instance I want to know wevery word that has a P in a text file, and
> then everyword that has a q.
> Any suggestions.

Use regualr expressions for that:

while (<>)
	{
	for my $word (grep { /[Pq]/ } split /\W+/)
		{ print $word, "\n"; }
	}
__END__

Hope this helps,

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Mon, 10 Nov 1997 12:26:35 -0500
From: Henry Hartley <henry@DotRose.com>
Subject: SQL statement in Perl
Message-Id: <346743CB.8461D604@DotRose.com>

I'm working on an Intranet '411' application for my company.  I have a
Perl script that looks up data in a MS Access database depending upon
what the user enters into the five fields.  It MOSTLY works.  What I
can't get to work is the sorting of the data.  I have the following SQL
statment (the first line part is all one line):

      $sql = sprintf("select * from phonebook where LastName like '%s'
and FirstName like '%s' and Extension like '%s' and Building like '%s'
and Room like '%s' order by '%s'", $lastname . "\%", $firstname . "\%",
$exten . "\%", $bldg . "\%", $roomnum . "\%", $sortby);
      $query->Sql($sql);

This returns the correct data but the "order by $sortby" portion seems
to do nothing.  $sortby contains one of the field names from the Access
table.  Any suggestions?

Henry




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

Date: 10 Nov 1997 16:27:21 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <647cl9$38a$1@info.uah.edu>

Following is a summary of articles spanning a 7 day period,
beginning at 01 Nov 1997 13:18:11 GMT and ending at
08 Nov 1997 19:31:46 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" e-mail address and name.
    - Original Content Rating is the ratio of the original content volume
      to the total body volume.
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.

Excluded Posters
================

perlfaq-suggestions@mox.perl.com

Totals
======

Total number of posters:  387
Total number of articles: 837 (315 with cutlined signatures)
Total number of threads:  313
Total volume generated:   1377.2 kb
    - headers:    559.3 kb (11,417 lines)
    - bodies:     757.6 kb (23,663 lines)
    - original:   536.7 kb (17,453 lines)
    - signatures: 58.3 kb (1,240 lines)
Original Content Rating: 0.7084

Averages
========

Number of posts per poster: 2.16
    median: 1 post
    mode:   1 post - 274 posters
    s:      4.73 posts
Number of posts per thread: 2.67
    median: 2 posts
    mode:   1 post - 111 threads
    s:      2.25 posts
Message size: 1684.9 bytes
    - header:     684.2 bytes (13.6 lines)
    - body:       926.8 bytes (28.3 lines)
    - original:   656.6 bytes (20.9 lines)
    - signature:  71.3 bytes (1.5 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

   64   105.8 ( 54.0/ 38.0/ 23.8)  Tom Phoenix <rootbeer@teleport.com>
   47    76.5 ( 32.7/ 34.1/ 19.0)  brian d foy <comdog@computerdog.com>
   37    73.9 ( 22.3/ 51.6/ 34.3)  Tad McClellan <tadmc@flash.net>
   21    44.8 ( 13.8/ 31.0/ 20.2)  Mark Mielke <markm@nortel.ca>
   13    16.3 (  8.4/  7.6/  3.1)  Toutatis <toutatis@_SPAMTRAP_toutatis.net>
   11    20.6 (  6.4/ 10.7/  6.8)  Mike Stok <mike@stok.co.uk>
   11    20.9 (  5.7/ 15.0/ 11.8)  Andrew M. Langmead <aml@world.std.com>
   10    18.5 (  7.3/ 11.2/  6.2)  "Allen Evenson" <ase@seanet.com>
   10    15.5 (  7.1/  6.3/  3.6)  Martien Verbruggen <mgjv@comdyn.com.au>
   10    22.9 (  6.5/ 14.0/ 10.0)  William R. Ward <hermit@cats.ucsc.edu>

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

 105.8 ( 54.0/ 38.0/ 23.8)     64  Tom Phoenix <rootbeer@teleport.com>
  76.5 ( 32.7/ 34.1/ 19.0)     47  brian d foy <comdog@computerdog.com>
  73.9 ( 22.3/ 51.6/ 34.3)     37  Tad McClellan <tadmc@flash.net>
  44.8 ( 13.8/ 31.0/ 20.2)     21  Mark Mielke <markm@nortel.ca>
  22.9 (  6.5/ 14.0/ 10.0)     10  William R. Ward <hermit@cats.ucsc.edu>
  20.9 (  5.7/ 15.0/ 11.8)     11  Andrew M. Langmead <aml@world.std.com>
  20.6 (  6.4/ 10.7/  6.8)     11  Mike Stok <mike@stok.co.uk>
  18.5 (  7.3/ 11.2/  6.2)     10  "Allen Evenson" <ase@seanet.com>
  16.3 (  8.4/  7.6/  3.1)     13  Toutatis <toutatis@_SPAMTRAP_toutatis.net>
  15.9 (  4.6/ 11.4/  3.3)      6  Justin Wills <justin@nectar.com.au>

Top 10 Posters by OCR (minimum of five posts)
==============================================

          (kb)    (kb)
OCR       orig /  body  Posts  Address
------  --------------  -----  -------

0.9988     3.4 /   3.4      5  John Moreno <phenix@interpath.com>
0.9872     2.4 /   2.4      6  "Rick" <rlluhman@netins.net>
0.9848     4.6 /   4.6      9  Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh" <bsa@void.apk.net>
0.7849    11.8 /  15.0     11  Andrew M. Langmead <aml@world.std.com>
0.7426     2.3 /   3.1      8  Calle Dybedahl <qdtcall@esb.ericsson.se>
0.7366     5.9 /   8.0      7  Ronald L. Parker <ron@farmworks.com>
0.7338     5.2 /   7.1      8  Steve Kilbane <Steve_Kilbane@cegelecproj.co.uk>
0.7099    10.0 /  14.0     10  William R. Ward <hermit@cats.ucsc.edu>
0.7035     2.6 /   3.7      5  Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
0.6641    34.3 /  51.6     37  Tad McClellan <tadmc@flash.net>

Bottom 10 Posters by OCR (minimum of five posts)
=================================================

          (kb)    (kb)
OCR       orig /  body  Posts  Address
------  --------------  -----  -------

0.5560     6.2 /  11.2     10  "Allen Evenson" <ase@seanet.com>
0.5124     3.0 /   5.9      6  Mike Heins <mheins@prairienet.org>
0.4975     3.9 /   7.9      5  Douglas SEAY <seay@hol.fr>
0.4955     2.1 /   4.3      5  Bart Lateur <bart.mediamind@tornado.be>
0.4909     3.8 /   7.7      7  Ilya Zakharevich <ilya@math.ohio-state.edu>
0.4422     2.7 /   6.0      7  cornelio@home.com
0.4179     1.7 /   4.1      7  Jason Gloudon <jgloudon@bbn.com>
0.4091     3.1 /   7.6     13  Toutatis <toutatis@_SPAMTRAP_toutatis.net>
0.3685     1.6 /   4.3      5  Charles DeRykus <ced@bcstec.ca.boeing.com>
0.2913     3.3 /  11.4      6  Justin Wills <justin@nectar.com.au>

Top 10 Threads by Number of Posts
=================================

Posts  Subject
-----  -------

   24  An excellent example of perl madness (or "split stupidity")
   12  Seeking Year 2000 checker OR comment stripper for C/C++
   11  Sorting and Counting with PERL
   10  Regular Expressions
    9  Chomp vs Chop
    8  Perl->Java? Java->Perl? Gaaaaa!
    8  What to do with Bitwise operators?
    8  CPAN confusion
    8  One slice of hash, please...
    8  Puzzle: palindromep

Top 10 Threads by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Subject
--------------------------  -----  -------

  48.1 ( 17.0/ 28.9/ 18.3)     24  An excellent example of perl madness (or "split stupidity")
  22.6 (  9.2/ 12.3/  8.5)     12  Seeking Year 2000 checker OR comment stripper for C/C++
  20.9 (  5.8/ 14.6/  8.7)      9  Chomp vs Chop
  20.9 (  7.9/ 11.3/  7.7)     11  Sorting and Counting with PERL
  19.2 (  5.2/ 13.3/  7.9)      8  Perl->Java? Java->Perl? Gaaaaa!
  18.5 (  5.3/ 12.0/  5.8)      8  CPAN confusion
  14.9 (  4.1/ 10.8/  6.8)      6  Real Newbie Question
  14.5 (  7.5/  6.1/  3.3)     10  Regular Expressions
  13.9 (  5.1/  7.6/  5.0)      8  Puzzle: palindromep
  13.8 (  2.0/ 11.3/ 10.6)      3  Tricky problem... how to use open3() in "open3.pl" ??

Top 10 Targets for Crossposts
=============================

Articles  Newsgroup
--------  ---------

      12  comp.lang.perl.modules
       6  comp.lang.java
       3  alt.fan.e-t-b
       3  pl.comp.lang.perl
       2  comp.lang.perl
       2  it.comp.lang.perl
       2  comp.unix.solaris
       2  comp.lang.perl.tk
       1  comp.lang.modula3
       1  comp.os.vms

Top 10 Crossposters
===================

Articles  Address
--------  -------

      10  "Manfred Schneider" <manfred.schneider@rhein-neckar.de>
       3  Tom Phoenix <rootbeer@teleport.com>
       3  ngrp@q-d.com
       2  Mike Heins <mheins@prairienet.org>
       2  ap296@torfree.net
       2  Nicco <niccotnt@mbox.vol.it>
       2  indhiraa@hotmail.com
       2  yanoff@alumni.cs.uwm.edu
       2  Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
       1  Carey Evans <c.evans@clear.net.nz>


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

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

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