[7777] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1402 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 2 12:27:32 1997

Date: Tue, 2 Dec 97 09:00:28 -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           Tue, 2 Dec 1997     Volume: 8 Number: 1402

Today's topics:
     ++/-- rounds only neg. numbers? (Jack Bennetto)
     Re: ++/-- rounds only neg. numbers? <tycage@infi.net>
     Re: ++/-- rounds only neg. numbers? speed@racer.cartoon.spam.address
     can perl do multi-threaded programming? <dave@digidem.com>
     Re: can perl do multi-threaded programming? (Jeremy D. Zawodny)
     Re: can perl do multi-threaded programming? <zenin@best.com>
     cgi/catch output of Perl-Programm (Tobias Poppe)
     Re: Confused about regex (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Re: eliminating part of file (Mick Farmer)
     Re: eliminating part of file (Lloyd Zusman)
     Getting rid of non-Y2K Perl4 (was Re: Pattern matching  <merlyn@stonehenge.com>
     Re: HELP WWW Program!!!!  Need help fast!!! (Jeremy D. Zawodny)
     Re: HELP WWW Program!!!!  Need help fast!!! <billg@networkapparel.com>
     Re: HELP WWW Program!!!!  Need help fast!!! (Andrew Williams)
     Re: Informic DBD/DBI . . . (Clay Irving)
     Re: Looking for better development envirement for PERL lvirden@cas.org
     Re: Opening files in a Perl/Win32 script (Jeremy D. Zawodny)
     Re: Perl Plug-In for Netscape? lvirden@cas.org
     Perl_markstack_ptr compile problem <sherlock.holmes@worldnet.att.net>
     Re: Q: I can't print to a file. <billg@networkapparel.com>
     Re: Q: Learning perl with no progr. experience <lhampton@ics.com>
     Re: read from end of file (by line) <bruni@micso.levalo.it>
     Re: Scoring A Group of Arrays Part II <tycage@infi.net>
     Re: some good perl-sites (Burt Lewis)
     Re: some good perl-sites (Clay Irving)
     Srvinfo  WinNT Howto?? <lynet@bigblue.no>
     String to Integer <hvanlint@lodestar.be>
     Re: String to Integer (Jeremy D. Zawodny)
     Re: String to Integer <zenin@best.com>
     Re: String to Integer (brian d foy)
     switch stdout and stderr <seh@pecc.co.uk>
     Re: switch stdout and stderr <zenin@best.com>
     Uploading binary files with Perl <stevie@steviek.demon.co.uk>
     Re: Uploading binary files with Perl <zenin@best.com>
     Re: Uploading binary files with Perl (Jeremy D. Zawodny)
     Re: What's the problem with this regex? <Harald.Joerg@mch.sni.de>
     Re: What's the problem with this regex? (Abigail)
     where is info-mode Perl documentation? (Lynn D. Newton)
     Year 2000: -M -A -C operators <gilles@tls-cats.sps.mot.com>
     Re: Year 2000: -M -A -C operators (brian d foy)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 2 Dec 1997 09:35:38 -0500
From: bennetto@plasmon.rutgers.edu (Jack Bennetto)
Subject: ++/-- rounds only neg. numbers?
Message-Id: <6616bq$f1o@plasmon.rutgers.edu>
Keywords: increment decrement rounding perl

Running the perl program:


$a = 2.5;
$b = -2.5;
$a++;
$b++;
print "$a $b\n";

Gives the result:

3.5 -1

Basicly, the autoincrement and decrement operators, when confronted with
a negative (but not positive) number, truncate first.  Is there a reason
for this?  Is there a reason for this?  I can't find it in the
documentation; should it be?  Is 

I'm mystified.


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

Date: Tue, 02 Dec 1997 10:05:25 -0500
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: ++/-- rounds only neg. numbers?
Message-Id: <348423B5.527977F@infi.net>

Jack Bennetto wrote:
> 
> Running the perl program:
> 
> $a = 2.5;
> $b = -2.5;
> $a++;
> $b++;
> print "$a $b\n";
> 
> Gives the result:
> 
> 3.5 -1

I get
3.5 -1.5
just as you'd expect.  That's on perl5.004_04 on Linux 2.0.32

What perl are you running and on what kind of system?
Did you try this exact example, or was there other code involed that
might have had something to do with it?

Hope this helps,
  Ty

-- 
+---+
Ty Cage Warren                                           tycage@infi.net
Systems Engineer                                                 InfiNet
The Web Site of Love: http://tazer.engrs.infi.net/mst3k/
PGP Public Key: http://tazer.engrs.infi.net/~tycage/pgpkey.html
PGP Fingerprint: FF C1 28 CA 80 B5 31 78  B1 24 2E 8C AB DA FB D2
------------->Never invoke anything bigger than your head.<-------------


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

Date: 02 Dec 1997 08:54:00 -0700
From: speed@racer.cartoon.spam.address
Subject: Re: ++/-- rounds only neg. numbers?
Message-Id: <yz2afejbv1j.fsf@advtech.uswest.com>


That's not what I get:

>> perl -e '
> $a = 2.5;
> $b = -2.5;
> $a++;
> $b++;
> print "$a $b\n";
> '
3.5 -1.5
 
-- 
  Bruce W. Hoylman (303/541-6557) -- bhoylma@advtech.USWest.COM ._ 0  
   -     __0    Speaking for myself...        /\/\    /\       /  //\.
-  - - _-\<,_   "Please saw my legs off".    /~/~~\/\/~~\     '  \>> |
 -  __(_)/_(_)_____________________________/\ /    \ \/\ \________\\ `_


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

Date: 2 Dec 1997 14:31:46 GMT
From: "David M Rosner" <dave@digidem.com>
Subject: can perl do multi-threaded programming?
Message-Id: <01bcff25$8fb46b90$7a1aa8c0@andersen13>

i have a program where i want to kick off several other programs all at
once. i could fork each one into its own process and then exec it, but i'd
rather have the advanatages of true-multithreading and do each one as a
seperate task. i've searched around and i can't seem to find any
multi-threading information on Perl. is there such a thing? 

thanks!

- dmr


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

Date: Tue, 02 Dec 1997 15:26:33 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: can perl do multi-threaded programming?
Message-Id: <3487288c.1037123004@igate.hst.moc.com>

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

On 2 Dec 1997 14:31:46 GMT, "David M Rosner" <dave@digidem.com> wrote:

>i have a program where i want to kick off several other programs all at
>once. i could fork each one into its own process and then exec it, but i'd
>rather have the advanatages of true-multithreading and do each one as a
>seperate task. i've searched around and i can't seem to find any
>multi-threading information on Perl. is there such a thing? 

Perl5.005 (currently under development) will have the beginnings of
true multi-threading support.

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


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

Date: 2 Dec 1997 15:35:08 GMT
From: Zenin <zenin@best.com>
Subject: Re: can perl do multi-threaded programming?
Message-Id: <881077079.806215@thrush.omix.com>

David M Rosner <dave@digidem.com> wrote:
: i have a program where i want to kick off several other programs all at
: once. i could fork each one into its own process and then exec it, but i'd
: rather have the advanatages of true-multithreading and do each one as a
: seperate task. i've searched around and i can't seem to find any
: multi-threading information on Perl. is there such a thing? 

	5.005 will have threads, but it's not ready for prime time yet. 
	Check the Perl 5 porters mailing list for details:

	http://www.rosat.mpe-garching.mpg.de/mailing-lists/perl-porters/

-- 
-Zenin
 zenin@best.com


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

Date: 2 Dec 1997 16:02:25 GMT
From: udta@rz114s1.rz.uni-karlsruhe.de (Tobias Poppe)
Subject: cgi/catch output of Perl-Programm
Message-Id: <661beh$8op$1@nz12.rz.uni-karlsruhe.de>

Hello...

I have a problem with my Perl5-code.

Within the Code of Prg1 I call Prg2 with the "do(Prg2.pl)" statement.

Prg2.pl prints "Hello World".
How can i catch the output of Prg2 within Prg1 ?

I want to use Prg1 and also Prg2.pl on the web (./cgi-bin).
Prg2.pl is normaly called by a link on a WebPage and
send's a little new Webpage (a "Hello World" Page:-) to the User who
klicked on the Link. 
NOW Prg1.pl (instead of the user) calls Prg2.pl...

Letz have a look at my little Prgs :-)

Prg1.pl
[..heavy code..]
do("Prg2.pl");
# How can i catch the output of Prg2.pl ???
[..more code..]

Prg2.pl
[..heavy code...followed by:]
print "Content-type: text/html \n\n";
print "Hello World!";
[... more code...]

Thanks to all people in the world....

CU on the bitstream....

--
MfG Tobias Poppe - Informatik HQ Karlsruhe
  *** eMail udta@rz.uni-karlsruhe.de ***
          ** sysop@hmc-bbs.org **


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

Date: Tue, 02 Dec 97 10:39:41 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: Confused about regex
Message-Id: <34842bec$2$ofn$mr2ice@speaker>

In <19971202024600.VAA03765@ladder02.news.aol.com>, on 12/02/97 at 02:46 AM,
   mark666769@aol.com (Mark666769) said:
+-----
| Just curious, why wasn't ! chosen instead of ^ ? Wouldn't that be more
| consistent, since ! is already the Not operator?
+--->8

Existing practice in both cases:  regexp "^" from Unix regex-using programs,
"!" as "not" from C.

-- 
brandon s. allbery           [Team OS/2][Linux][JAPH]        bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)                  KF8NH
"Never piss off a bard, for they are not at all subtle and your name scans to
 `Greensleeves'."  ---unknown, quoted by Janet D. Miles in alt.callahans



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

Date: Tue, 2 Dec 1997 12:15:02 GMT
From: mick@picus.dcs.bbk.ac.uk (Mick Farmer)
Subject: Re: eliminating part of file
Message-Id: <EKKA12.3xJ@mail2.ccs.bbk.ac.uk>

Dear Steve,

If the file is small enough to live in memory, then
something like the following will work.

	$file = join '', <INPUT>;
	$file =~ s/<tag>.*?</tag>//g;
	print OUTPUT $file;

Regards,

Mick


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

Date: 2 Dec 1997 13:32:42 GMT
From: ljz@asfast.com (Lloyd Zusman)
Subject: Re: eliminating part of file
Message-Id: <slrn6883g8.ff.ljz@ljz.asfast.net>

On Tue, 2 Dec 1997 12:15:02 GMT, Mick Farmer <mick@picus.dcs.bbk.ac.uk> wrote:
> Dear Steve,
> 
> If the file is small enough to live in memory, then
> something like the following will work.
> 
> 	$file = join '', <INPUT>;
> 	$file =~ s/<tag>.*?</tag>//g;
> 	print OUTPUT $file;

Two small points:  I recommend changing the second line as follows ...

   $file =~ s:<tag>.*?</tag>::sg;

It ends with an "sg" and not just a "g", and it uses ":" instead of "/"
as a delimiter in the substitute command.  

The "s" operand (in "sg") will cause the "." character to match
newlines as well as other characters, thereby allowing you to match
text that spans multiple lines.  The ":" (or some other character) is
needed because your match pattern contains a "/".


-- 
 Lloyd Zusman
 ljz@asfast.com


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

Date: 02 Dec 1997 09:03:07 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Falcon@darkwave.org.uk
Subject: Getting rid of non-Y2K Perl4 (was Re: Pattern matching (or not....))
Message-Id: <8cpvnf4ts4.fsf@gadget.cscaper.com>

>>>>> "-=Falcon=-" == -=Falcon=-  <Falcon@darkwave.org.uk> writes:

-=Falcon=-> With Perl4 (yes I know it's not 5, but what can you do when the
-=Falcon=-> management
-=Falcon=-> won't upgrade?) [...]

You keep repeating to them over and over:

	"Perl4 is not Y2K"
	"Perl4 is not Y2K"
	"Perl4 is not Y2K"

until they read some trade story about the horrors of Y2K problems,
and remember what you said (but only the buzzwords :-), and then ORDER
you to "upgrade at once!".

It's actually rather simple.  All grunts should have
pointy-hair-manager tricks like this.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 272 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Tue, 02 Dec 1997 15:17:37 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: HELP WWW Program!!!!  Need help fast!!!
Message-Id: <34842660.1036567054@igate.hst.moc.com>

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

On Tue, 02 Dec 1997 07:55:06 GMT, rmk1825@cs.tamu.edu (Rob King)
wrote:

>I am trying to make a program that interacts with a database and shows
>the information on a web page.  If anyone knows of any web pages with
>information on how to do this or if anyone has some sample files
>(code) that would help me, would you please send them to me?  They
>don't only have to be in PERL, I am willing to try any language that
>will make it easier for me to get this done soon.

The *entire text* of "Database Driven Web Sites" is on the web.
Perhaps it will help.

No, I don't have the URL memorized, but it shouldn't be hard to find.

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


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

Date: Tue, 02 Dec 1997 10:19:39 -0500
From: Bill Guindon <billg@networkapparel.com>
To: Rob King <rmk1825@cs.tamu.edu>
Subject: Re: HELP WWW Program!!!!  Need help fast!!!
Message-Id: <3484270B.92AD8D43@networkapparel.com>

(Sender CC'd via email)

Rob King wrote:
> 
> I am trying to make a program that interacts with a database and shows
[snip]
> don't only have to be in PERL, I am willing to try any language that
> will make it easier for me to get this done soon.

Not sure if this will help (as I JUST found out about it myself), but
you might want to take a look at:

http://php.iquest.net/

It's a scripting language that allows you to embed database queries in
your HTML files.  And it's free!

Good luck!
Bill Guindon


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

Date: Tue, 02 Dec 1997 16:09:18 GMT
From: andrew@edoc.com (Andrew Williams)
Subject: Re: HELP WWW Program!!!!  Need help fast!!!
Message-Id: <348c3243.947125265@news.clark.net>

On Tue, 02 Dec 1997 07:55:06 GMT, rmk1825@cs.tamu.edu (Rob King)
wrote:

>Hello,
>
>I am trying to make a program that interacts with a database and shows
>the information on a web page.  If anyone knows of any web pages with
>information on how to do this or if anyone has some sample files
>(code) that would help me, would you please send them to me?  They
>don't only have to be in PERL, I am willing to try any language that
>will make it easier for me to get this done soon.


What kind of database are you using?  what platform are you running
on.  how big does the database need to scale.  It generally helps if
you provide people enough information to answer the question.




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

Date: 2 Dec 1997 09:33:48 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Informic DBD/DBI . . .
Message-Id: <66168c$oth@panix.com>

In <348375A1.2515@informix.com> Mark Taylor <mtaylor@informix.com> writes:

>We just installed Perl with the Informix DBD/DBI part and all the tests
>(except a blob test) passed.  But when I try a simple sonnect to a DB I
>get several "can't load library" messages.  I of course don't have the
>names with me at home but they seem to be the Informix libraries that it
>needs just to get started.  I have checked and the libraries are there
>and readable by me . . . What am I forgetting to do?

You probably forgot to set a couple of environment variables -- From the
README file:

    Please ensure that you have $INFORMIXDIR set, and that $INFORMIXDIR/bin
    is on your PATH.  The build no longer works unless these environment
    variables are set.  Also, if you are using ESQL/C version 6.x or later,
    you may be using ESQL/C shared libraries which are found in
    $INFORMIXDIR/lib and $INFORMIXDIR/lib/esql.  You need to ensure that
    these will be found when you run Perl with DBD::Informix.  On SVR4
    machines, this means adding these directories to LD_LIBRARY_PATH; on
    HP-UX, the variable is SHLIB_PATH; other systems may have other
    variable names.  You need to set INFORMIXSERVER correctly if you are using
    version 6.0x or later.  You may need to set other environment variables
    too -- consult the Informix manuals for more information.

Check LD_LIBRARY_PATH.

-- 
Clay Irving <clay@panix.com>                   http://www.panix.com/~clay/


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

Date: 2 Dec 1997 15:47:09 GMT
From: lvirden@cas.org
Subject: Re: Looking for better development envirement for PERL
Message-Id: <661aht$dg6$2@srv38s4u.cas.org>


According to Phil R Lawrence <prl2@lehigh.edu>:
:Edris Abzakh <edris@canaan.co.il> wrote 
:> I was wondering if any body knows about a better developing envirement
:> for Perl than using Emacs and the primitive debugger of Perl .
:> If there is any thing close to the modern envirements then please
:buy.  As for debugging, I use 
:
:#!/usr/local/bin/perl -w
:use diagnostics;
:use strict;

:To test my work as I go I just save my changes (click), FTP the file over
:to my AIX system (click), and run it from my PowerTerm emulator.  This is
:the best system so far for me.

I suspect that what is really being asked for here is a graphical
development environment similar to perhaps VisualBasic or some of the newer
Java IDEs.  

If folk are looking for 'something better' could you be specific about
what it is better that you are seeking?  The more specific you are,
the more likely if something exists you will find it.

However, be aware that the trend at least in this newsgroup seems to be
to flame or at least disregard requests for pointers to something more
than a text editor and command line...
-- 
Larry W. Virden                 INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.


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

Date: Tue, 02 Dec 1997 15:19:11 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Opening files in a Perl/Win32 script
Message-Id: <348526c7.1036669582@igate.hst.moc.com>

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

On Tue, 02 Dec 1997 12:28:26 +0100, Leon Boot <l.boot@exacomm.nl>
wrote:

><HTML>
>Hi!
>
><P>I'm having this particular problem:

Yes. You've posted in HTML. That's a no-no.

><P>P.S.: Please respond by e-mail, since I haven't got much time to check
>newsgroups!</HTML>

You've not read the comp.lang.perl.misc FAQ, have you?

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


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

Date: 2 Dec 1997 15:39:40 GMT
From: lvirden@cas.org
Subject: Re: Perl Plug-In for Netscape?
Message-Id: <661a3s$dg6$1@srv38s4u.cas.org>


According to Tad McClellan <tadmc@metronet.com>:
:Eric Hilding (eric@hilding.com) wrote:
:: I've looked around but just can't seem to find the
:: info on an alleged Perl 'Plug-In' for Netscape.  Any
:: references would be appreciated.  Tnx.
:
:
:Where did you hear the allegations?
:
:I've not heard of such a thing.
:
:What do you want to do that you need a plugin for?

To write HTML pages with inline perl code?


As for where one might hear such allegations, I know I've heard of
it here on this newsgroup in the past, as well as on a number of perl
related mailing lists, as well as on a website regarding an OpenGL/Perl
plugin in the past.  However, the web site is no longer available, so
it appears that the one occurance of someone doing this has disappeared.

-- 
Larry W. Virden                 INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.


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

Date: Tue, 2 Dec 1997 10:39:35 -0500
From: "Alan Fahrner" <sherlock.holmes@worldnet.att.net>
Subject: Perl_markstack_ptr compile problem
Message-Id: <661ad3$mvl@mtinsc02.worldnet.att.net>

Hi Folks...

I was putting of compiling up perl 5.004, but another problem with 5.003 has
made me want to get the "upgrade."

I'm trying to compile it on a DG/UX system, R4.11MU03.  Compilation of 5.003
was no problem, and compilation of 5.004 appears the same.

However, when I do a "make test" afterward it gives me errors like this
every time it tries to load a library dynmically:

lib/filecopy......Can't load '../lib/auto/IO/IO.so' for module IO: dynamic
linker: ./perl: relocation error: symbol not found: Perl_markstack_ptr at
 ../lib/DynaLoader.pm line 166.
at ../lib/IO/Handle.pm line 248

Anyone seen this and figured out the solution?  I used the defaults given by
the Configure script -- which, up to now, has been perfect.

Thanks ahead of time!

Alan





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

Date: Tue, 02 Dec 1997 10:15:54 -0500
From: Bill Guindon <billg@networkapparel.com>
To: Jerry Lineberry <jerryl@connecti.com>
Subject: Re: Q: I can't print to a file.
Message-Id: <3484262A.27E32801@networkapparel.com>

(Sender CC'd via email)

Jerry Lineberry wrote:
> 
> Hello,
>         I'm very new to PERL. But I'm already writing scripts. Right now,

Welcome to the club!

[snip]
> results to a file I simply get the file names without any contents. Here's
> how my files look:
[snip]
 
> ###script###
> #!/usr/bin/perl -w
> 
> open(STRIP, "str.txt") or die "Can't read from str.txt.\n";
> while (<STRIP>) {
> /fred barney dino/;
> @duck = $`."\n";
> print @duck;
> }

Try:
print STRIP @duck;

You need to tell it to print to the filehandle, not STDOUT.

Hope that helped,
Bill Guindon

btw... comp.lang.perl, is now: comp.lang.perl.misc


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

Date: Tue, 02 Dec 1997 09:54:29 -0600
From: Lance Hampton <lhampton@ics.com>
Subject: Re: Q: Learning perl with no progr. experience
Message-Id: <34842F34.8E7BD8DF@ics.com>

Hello,

I just began programming just under a year ago.  First, the books you are
going to want to learn most of your Perl from will be the llama, and camel
books.  But, with no programming experience, I found that the curve on
both books was a little too steep.  I found that the "Learning Perl in 21
days" book was suffiicient to get me pointed in the right direction.  It
has some very specific examples of how to do things, without any
extraneous code.  Even the llama book throws in some extra stuff.  A
person that is accustomed to reading technical material knows when to
ignore such stuff.  I used the 21 day book for about 2 weeks, then never
touched it again.  After that, I moved to the llama book to teach me
stuff, and looked up all my questions in the Camel book.  Also, I read
this newsgroup everyday, even though I couldn't understand any code, it
let me know what Perl was capable of, and suited for.

good luck

-Lance



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

Date: Tue, 02 Dec 1997 14:40:12 +0100
From: Emiliano Bruni <bruni@micso.levalo.it>
Subject: Re: read from end of file (by line)
Message-Id: <34840FBC.69BD64BD@micso.levalo.it>

Scott Anthony Hamilton wrote:
> Dean Inada suggested (via email) a similar approach:
> 
>         for $scalar (reverse <FH>) { }
> 
> This works, but does it mean that, like the above approach, the entire
> file is read into memory? I specifically want to avoid this. It is why
> I want to read from the end of the file first, ie. anything of possible
> interest to me will be at the end of the file.
> 

This works for me and i use it to read my linux wtmp from the end

my ($len)=156; # Len of every line   
my ($offset)=(stat($wtmp))[7]; # Len of file ascii        
my ($righe)=$offset/$len; # Number of lines     
my $x=1;                                                             
                                                         
open(IN,$wtmp) || die $!;  # $wtmp if the path of
file                                         
seek(IN,$offset,0);                                                   
while ($righe>0) {
	# go back one ($x) line                           
        seek(IN,-$x*$len,1); 
	# read line
	read(IN,$buff,$len);    
	# from now, till end loop, go back two ($x)
line                                        
        $x=2;      
	# decrease number of lines to read
	$righe--;
}                                                   



BYE
                                        
                         

------------------------------------------------------------
+               Bruni Emiliano - nick "Emi_B"              +
------------------------------------------------------------
+Software developer          +Software developer           +
+             &              +              &              +
+          internet assistant+        network administrator+
+                            +                             +
+Istituto zoo----profilattico+ -- --     ____  ____   ____ +
+sperimentale ///"G.Caporale"+|  |  | | |     |      | S. |+
+dell'abruzzo/// e del molise+|     | | |      ----  | r. |+
+  64100    ----    TERAMO   +|     | | |____  ____| |_l._|+
+                            +                             +
+http://www.izs.it/~ebruni/  + http://www.micso.it/bruni   +
+e-mail:ebruni@izs.levalo.it + e-mail:bruni@micso.levalo.it+
+----------------------------------------------------------+
+ Per inviarmi un messaggio elimina la parola "levalo" dal +
+ mio e-mail                                               +
+--------------------------------------------------------- +


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

Date: Tue, 02 Dec 1997 09:10:47 -0500
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: Scoring A Group of Arrays Part II
Message-Id: <348416E7.2CC6E681@infi.net>

Daniel G. Drumm wrote:

[snip]

> What I am trying to do is this:
> 
> 1. Create 6 arrays, @a to @f.

Do the really need to be in @a to @f?  An array of arrays would be
easier
to handle, I'd think.

> 2. Roll a dice 10 times and put the results in each array, such that each
> array contains 10 results.
> 3. Go through each array, and find out how many times each number was
> rolled in TOTAL, across all 6 arrays.

[snip]

> #!/usr/local/bin/perl
                         ^----- No -w?  *sigh* -w is always a good
thing.
> 
> srand(time|$$);
> 
> # Part A
> 
> for ($arr = 'a'; $arr le 'f'; $arr++) {
>     for ($iteration = 1; $iteration < 10; $iteration++) {
                                      ^
This only does nine iterations, btw --|

>         $number = int(rand(6)) + 1;
>         push (@$arr, $number);
>     }
> }
I'd make this something like
   for ($arr = 0; $arr < 6; $arr++) { 
        for ($iteration = 0; $iteration < 10; $iteration++) {
            $number = int(rand(6)) +1;
            $dice[$arr][$iteration] = $number;
        }
    }

> # Part B
> 
> for ($arr = 'a'; $arr le 'f'; $arr++) {
>     foreach (@$arr) {
>       $temp{$_}++;
>     }
>     foreach (keys %temp) {
>       $scores{$_}++;
>     }
>     %temp = ();
> }

This I'd do this way.
    for ($arr = 0; $arr < 10; $arr++) {
        foreach (@{$dice[$arr]}) {
            $scores[$_]++;
        }
    }
                       

Then I'd print everything out like this

    for ($die = 1; $die <= 6; $die++) {
        $scores[$die] = 0 if (!$scores[$die]);
        print "$scores[$die]\n";
    }
    print "----------\n";
    for ($arr = 1; $arr <= 6; $arr++) {
        print @{$dice[$arr]},"\n";
    }


I haven't tested any of this, btw, it's off the top of my head.  But the
array of arrays should work better, and I think it's a lot easier to
generalize and add more runs if you want.  It also would make it easier
to use strict later if you needed to. If you wanted to be really smart
you could put the 6 and 10 into vars at the top of the code so it would
be easy to change. (Not the 6 for the die rolls, the 6 for the number of
arrays you want. =) ).

Anyway, I hope this helps.

--
+---+
Ty Cage Warren                                           tycage@infi.net
Systems Engineer                                                 InfiNet
The Web Site of Love: http://tazer.engrs.infi.net/mst3k/
PGP Public Key: http://tazer.engrs.infi.net/~tycage/pgpkey.html
PGP Fingerprint: FF C1 28 CA 80 B5 31 78  B1 24 2E 8C AB DA FB D2
------------->Never invoke anything bigger than your head.<-------------


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

Date: 2 Dec 1997 13:16:23 GMT
From: burt@ici.net (Burt Lewis)
Subject: Re: some good perl-sites
Message-Id: <6611n7$2dn$1@bashir.ici.net>

Just fire up your favorite search engine (try www.metacrawler.com) and use 
keywords like perl, perl5, perl archives, perl sites, perl tutorials, etc...

You should get back a ton of hits.

Burt Lewis
www.eastonmass.com




In article <660mgh$l19@dos.canit.se>, sap1d@canit.se says...
>
>Hey..
>
>I'm learning perl and I'd like to know if there are any good
>tutorials and FAQ's etc..
>
>If you know any good sites.. Please mail me or post it in the
>group.
>
>
>/ sap1d
>
>-- -
>sap1d@xy.org    /             - perl -                    
>sap1d@canit.se / There's more than one way to do it
>                                               - --



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

Date: 2 Dec 1997 10:06:02 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: some good perl-sites
Message-Id: <66184q$1g1@panix.com>

In <660mgh$l19@dos.canit.se> sap1d@canit.se (Johan Dalstrom) writes:

>I'm learning perl and I'd like to know if there are any good
>tutorials and FAQ's etc..

>If you know any good sites.. Please mail me or post it in the
>group.

Would you believe: http://www.perl.com

-- 
Clay Irving <clay@panix.com>                   http://www.panix.com/~clay/


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

Date: Tue, 02 Dec 1997 15:41:47 +0100
From: "@lfa" <lynet@bigblue.no>
Subject: Srvinfo  WinNT Howto??
Message-Id: <34841E2B.5C87@bigblue.no>

Hello World

I am a Perl novice and i need som help with perl scripting for WINNT.

I run SRVINFO on several machines (WinNT)
and i want to extract the data about Diskspace in % ,Servername, Uptime
+ Current Date

I got three files named location1.zzz , location2.zzz and location3.zzz
these files contain the servers in one Domain/Site in this format.

        server1,server2,server3....

when u run SRVINFO this is the syntax

        srvinfo \\servernavn

output is :

        Server Name: servernavn
        Security: Users
        NT Type: NT Advanced Server
        Version: 4.0, Build = 1381, CSD = Service Pack 3 
        Domain: NETCOM
        PDC: \\NOSLPDC
        IP Address: 172.17.131.65
        CPU[0]: x86 Family 6 Model 1 Stepping 9
        CPU[1]: x86 Family 6 Model 1 Stepping 9
        Drive:  [FileSys]  [ Size ]  [ Free ]
          C$      NTFS        2048      1512
          D$      NTFS       41362     32544
        Services:
           [Running]    Alerter
           [Running]    BaseboardService
        ---(short version)---
           [Running]    Computer Browser
           [Stopped]    SMS Remote Control Agent
        Network Card [0]: 3Com Fast EtherLink XL Adapter (3C905)
        Protocol[0]: [NET0] WINS Client(TCP/IP) 4.0
        System Up Time: 339 Hr 24 Min 50 Sec
        
I wish to extract the data from each SRVINFO output into files
with the name location1.log , location2.log , location3.log
with the following data in the file.

        server: date: disksize: usedspace %: uptime:


I hope that someone out there could help me with this
 
Thanx

Alf Geskjxnli
Cinet FMC Norway


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

Date: Tue, 2 Dec 1997 15:59:39 +0100
From: "Hans Van Lint" <hvanlint@lodestar.be>
Subject: String to Integer
Message-Id: <6617i1$6gl$1@news2.xs4all.nl>

Is there a function in Perl to convert a string to an integer?

(I post several values and want to use them as integers.)





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

Date: Tue, 02 Dec 1997 15:27:12 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: String to Integer
Message-Id: <348828c0.1037175269@igate.hst.moc.com>

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

On Tue, 2 Dec 1997 15:59:39 +0100, "Hans Van Lint"
<hvanlint@lodestar.be> wrote:

>Is there a function in Perl to convert a string to an integer?
>
>(I post several values and want to use them as integers.)

Perl does not differentiate between the two.

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


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

Date: 2 Dec 1997 15:37:11 GMT
From: Zenin <zenin@best.com>
Subject: Re: String to Integer
Message-Id: <881077203.313219@thrush.omix.com>

Hans Van Lint <hvanlint@lodestar.be> wrote:
: Is there a function in Perl to convert a string to an integer?

	Yes, it's the =() function.  It's used like this:

	$integer = $string;

	Welcome to Perl! :-)

-- 
-Zenin
 zenin@best.com


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

Date: Tue, 02 Dec 1997 11:46:01 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: String to Integer
Message-Id: <comdog-ya02408000R0212971146010001@news.panix.com>

In article <6617i1$6gl$1@news2.xs4all.nl>, "Hans Van Lint" <hvanlint@lodestar.be> wrote:

>Is there a function in Perl to convert a string to an integer?
>
>(I post several values and want to use them as integers.)

just use them as integers.  Perl will figure it out :)

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Tue, 02 Dec 1997 14:28:53 +0000
From: Stuart Hughes <seh@pecc.co.uk>
Subject: switch stdout and stderr
Message-Id: <34841B25.7AE4@pecc.co.uk>

I'm trying to append to a crontab, and it may not exist, so I want to
capture the stderr.  The stdout on the other hand is always re-directed
to a temp file so I can use if for the append.

I have read the section 8 faq, so be kind.

my problem is I can't see an easy way of temporarily switching stdout
and stderr (that work in the backticks).

To illustrate what I want to do:

my $resp                = '';
my $tmpcron             = "mycronjobs.$$";
my $cron_cmd            = "$mins $hours $doms $months $days /bin/pwd";
$resp                  .= `crontab -l > $tmpcron`; ### I need stderr
if($resp && $resp =~ /can't open your crontab file/)
{
   $resp               .= "creating a crontab\n";
}
if( open(CRON, ">>$tmpcron")  )
{
    print CRON "#RV job\n$cron_cmd\n";
    close CRON;
    $resp              .= "adding cron command $cron_cmd\n";
    $resp              .= `crontab $tmpcron`;
    unlink $tmpcron;
}

In the line marked '### I need stderr' , I want the possible stderr
ouput to be fed into $resp.

Anyone got any simple ideas (I know about redirecting to a file and
then reading and checking, but this seemed a bit over the top)

If you can help, thanks, if not, thanks anyway for taking the time to
read this.

Stuart Hughes


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

Date: 2 Dec 1997 15:33:08 GMT
From: Zenin <zenin@best.com>
Subject: Re: switch stdout and stderr
Message-Id: <881076959.478310@thrush.omix.com>

[ posted & mailed ]
Stuart Hughes <seh@pecc.co.uk> wrote:
: I'm trying to append to a crontab, and it may not exist, so I want to
: capture the stderr.  The stdout on the other hand is always re-directed
: to a temp file so I can use if for the append.

	perldoc -f open | more
	And keyword search for "dupe".

	open ORI_STDERR, ">&STDERR";  ## Save it for later, if we care

	open STDERR, ">> my_cron_errors.log"
	    or die "Can't reopen stderr: $!, stopped";

	## Stderr goes to log file here

	open STDERR, ">&ORI_STDERR";  ## Put it back

	## Stderr goes to original stderr

	Since your file descriptors are inherited by any subprocesses,
	"stderr" from backticks and system() calls will be sent to
	the log file as well.

: I have read the section 8 faq, so be kind.

	Perl Problem solving order: man pages (and/or perldoc -f function
	name), FAQs, DejaNews, current threads, sleep on it, redo the last
	5 steps, ask in the news group. :-)

: my problem is I can't see an easy way of temporarily switching stdout
: and stderr (that work in the backticks).

	See above about subprocesses and inherited file descriptors.

: In the line marked '### I need stderr' , I want the possible stderr
: ouput to be fed into $resp.

	Hmm, well you have a couple options:

	1) Reopen stderr to a file and read it back later. -Easiest.
	2) Use a tied handle class to redirect data into a scalar. -Harder

	And others, I'm sure, that I can't remember at 7:30 am when I
	haven't gone home yet. :-)

	Has anyone got a standard class build for this yet?  Something like
	Tie::Handle::Scalar?  Enough people ask for this, we really should
	have one.  If I can get off my lazy butt I'll put one on CPAN if no
	one has something yet.

-- 
-Zenin
 zenin@best.com


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

Date: Tue, 02 Dec 1997 12:50:17 +0000
From: Stevie Kennedy <stevie@steviek.demon.co.uk>
Subject: Uploading binary files with Perl
Message-Id: <34840409.F7021389@steviek.demon.co.uk>

I'm having a problem uploading binary files (JPGs and GIFs) - text files
are fine, but when reading the binary, Perl finds an EOF (Ctr-Z) marker
well before the end of the file and uploads only part of it. Binmode
command should work, but doesn't seem to. It's Perl for Win32/NT -
anyone know of bugs or any issues regarding this? Failing that, anyone
got an upload script that works?

Stevie Kennedy



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

Date: 2 Dec 1997 15:13:41 GMT
From: Zenin <zenin@best.com>
Subject: Re: Uploading binary files with Perl
Message-Id: <881075793.444011@thrush.omix.com>

Stevie Kennedy <stevie@steviek.demon.co.uk> wrote:
: I'm having a problem uploading binary files (JPGs and GIFs) - text files
: are fine, but when reading the binary, Perl finds an EOF (Ctr-Z) marker
: well before the end of the file and uploads only part of it. Binmode
: command should work, but doesn't seem to. It's Perl for Win32/NT -
: anyone know of bugs or any issues regarding this? Failing that, anyone
: got an upload script that works?

	And again I ask, WHAT PROTOCAL???

-- 
-Zenin
 zenin@best.com


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

Date: Tue, 02 Dec 1997 15:25:39 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Uploading binary files with Perl
Message-Id: <34862817.1037006135@igate.hst.moc.com>

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

On Tue, 02 Dec 1997 12:50:17 +0000, Stevie Kennedy
<stevie@steviek.demon.co.uk> wrote:

>I'm having a problem uploading binary files (JPGs and GIFs) - text files
>are fine, but when reading the binary, Perl finds an EOF (Ctr-Z) marker
>well before the end of the file and uploads only part of it. Binmode
>command should work, but doesn't seem to. It's Perl for Win32/NT -
>anyone know of bugs or any issues regarding this? Failing that, anyone
>got an upload script that works?

I think you need to explain *exactly* what you're trying to do.

I've been able to use Net::FTP to create "upload" scripts a lot.

Perhaps you could post a section of your code for us to debug.

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


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

Date: Tue, 02 Dec 1997 14:50:36 +0100
From: Harald Joerg <Harald.Joerg@mch.sni.de>
To: avert@dial.pipex.com
Subject: Re: What's the problem with this regex?
Message-Id: <3484122C.1F7C@mch.sni.de>

[mailed and posted]

Andrew Collington wrote:
> I have a few lines in a program of mine that is meant to extract the
> META content tag in an HTML file.
> However, when I come to display this content it doesn't appear to have
> worked.  And I think the problem lies with it not extracting the content
> correctly.
> The code looks like:
> 
>     if (($line =~ /<[^>]*META[^>]+NAME\s*=[ "]*description[
> "]+CONTENT\s*=\s*"(([^>"])*)"[^>]*>/i) && ($use_metas==1)) {
>       $content{$FILE}=$1;
>       $line=$1;
>       }

Of course your regexp assumes that the "NAME" comes before the
"CONTENT", and if I exchange both attributes in your example:
  <meta http-equiv="Description" name="Description" content="This page shows the different names.">
$1 actually contains "This page shows the different names."
I hope you don't try to print to a file descriptor called FILE
with your line "       $content{$FILE}=$1" ??

   Anyway, you should be aware that your regexp contains quite
a lot of assumptions about META elements, so you should not
rely on it when used with web pages you pick from elsewhere:
1) A META element may span several lines.
2) More than one META element may be present in one line.
Both can be handled if you read all your text in one scalar
and then match in a while loop with the //gs modifier.
But then you should replace most of your greedy "*"s by
their non-greedy counterpart "*?", and totally drop the
first one. HTML does not allow stuff between "<" and "META".
3) The CONTENT needs not to be included in double quotes, but
   if it is, it should be exactly one on the left and right
   end of the content and not any mixture of quotes and
   blanks.
4) NAME does not necessarily appear before CONTENT.
To handle these two you could try to split the parsing into
several parts:
  ($meta) = ($line =~ /<META\s+([^>]*)>/gis);
  ($name)        = ($meta =~ /\bNAME\s*=\s*([^"]\S+|".*?")/is);
  ($description) = ($meta =~ /\bCONTENT\s*=\s*([^"]\S+|".*?")/is);
  $name          =~ s/(")(.*?)\1/$2/;    # kill quotation marks,
  $description   =~ s/(")(.*?)\1/$2/;    # if present
  if (lc $name eq 'description') {
      $content{$FILE} = $description;
      $line=$description;
  }
I don't dare to say this is a "complete" handling of the META
element. For a really *good* parsing I strongly recommend the
libwww-perl bundle, which I use for HTML parsing but which 
won't allow a one-liner.
--
Oook,
--haj--


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

Date: 2 Dec 1997 16:25:58 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: What's the problem with this regex?
Message-Id: <slrn688do4.175.abigail@betelgeuse.wayne.fnx.com>

Andrew Collington (andyc@dircon.co.uk) wrote on 1554 September 1993 in
<URL: news:3483F32C.342C@dircon.co.uk>:
++
++ If anyone could point out what I'm doing or suggest anything I'd
++ appreciate it. 

Use HTML::Parse. There might be a tag or two that matches your regex,
but many that should won't.


Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: 01 Dec 1997 11:34:50 -0700
From: lnewton@berio.phx.mcd.mot.com (Lynn D. Newton)
Subject: where is info-mode Perl documentation?
Message-Id: <cn13ekc29px.fsf@berio.phx.mcd.mot.com>


I have seen references in various places to Perl
documentation in texinfo format for reading in
info-mode with Emacs or XEmacs. But I have been unable
to locate it in this format. Can someone give me a
pointer? Thanks.

Email response appreciated. It's very hard to keep up
with this group.

=======================
Lynn D. Newton
Motorola Computer Group
Tempe, AZ
=======================


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

Date: Tue, 02 Dec 1997 16:35:42 +0100
From: Frederic GILLES <gilles@tls-cats.sps.mot.com>
To: Larry Wall <larry@wall.org>
Subject: Year 2000: -M -A -C operators
Message-Id: <34842ACD.7232E48B@tls-cats.sps.mot.com>

Are the Perl operators -M, -A and -C year 2000 compliant?

These operators are doing date calculations.
What happens if we test a file from the 20th century with -M after the
01/01/2000? Is the result correct?

The Perl FAQ talks only about gmtime and localtime, not about those
operators. It would be a good idea to add a few lines about it.

Frederic GILLES
--


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

Date: Tue, 02 Dec 1997 11:42:19 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Year 2000: -M -A -C operators
Message-Id: <comdog-ya02408000R0212971142190001@news.panix.com>

In article <34842ACD.7232E48B@tls-cats.sps.mot.com>, Frederic GILLES <gilles@tls-cats.sps.mot.com> wrote:

>Are the Perl operators -M, -A and -C year 2000 compliant?
>
>These operators are doing date calculations.

really?  my versions give the values as days since script startup, not
a date.

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

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

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