[7757] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1382 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 28 00:13:03 1997

Date: Thu, 27 Nov 97 21:00:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 27 Nov 1997     Volume: 8 Number: 1382

Today's topics:
     Re: $x.xx in PERL <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
     A Good Perl Site for syntax <mageos@hotmail.com>
     Re: A Good Perl Site for syntax <merlyn@stonehenge.com>
     Re: Can I do $! = 'string' ? (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Re: Changing Values in Registry from command line (Cameron Laird)
     Cookies and Perl 5 <keithlol@nospammindspring.com>
     Re: Cookies and Perl 5 <keithlol@nospammindspring.com>
     Re: deleting a line in an ascii file <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
     Re: For the pro's ? repost: Leaving HTML tags alone (Tad McClellan)
     Re: For the pro's ? repost: Leaving HTML tags alone (Patrick)
     Getting file timestamp from array (Robert)
     Re: How To Test if number is ODD or EVEN? <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
     Html - > Unix <modular@hkstar.com>
     Re: IS THERE A DB INTERFACE INTO MS SQL SERVER? <beans@bedford.net>
     Re: last element in an array? <bill@penumbra.co.uk>
     libwww - LWP::UserAgent <rv33100@glaxowellcome.co.uk>
     Microsoft RTF Decoder Wanted <john.clutterbuck@sbs.siemens.co.uk>
     Re: Newbie question.   Do you recommend moving from C? <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
     Re: Newbie question.   Do you recommend moving from C? (Tad McClellan)
     Re: pattern substituition operation question <alecto@pe.BogusstrinG.net>
     Re: PERL Hourly Rates (brian d foy)
     Re: PERL Hourly Rates <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
     Print out array! (Ryujiy)
     Re: read from end of file (by line) <robert.friberg@your_clothes.eductus-vast.com>
     Re: Readable Sources (Cameron Laird)
     Sendmail <ca5cru@isis.sund.ac.uk>
     SIG-signals (Johan Dalstrom)
     Re: truncating a string <r.goeggel@atos-group.de>
     Re: truncating a string <jwilson@ic.ac.uk>
     Re: truncating a string <beans@bedford.net>
     Two way Sockets using Perl 5 (Win32) <a.n.farrow@cranfield.ac.uk>
     undump <indy@mail.www-service.de>
     Re: undump <indy@mail.www-service.de>
     Updates on Win32::Eventlog <leberre@bandol.grenoble.hp.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 27 Nov 1997 07:21:03 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: $x.xx in PERL
Message-Id: <65k32f$sfh@mtinsc05.worldnet.att.net>


perrella andrew c wrote in message ...
>
>Hello,
>
> I have writte a script that is used for catalog orders.  It sums
>the items taken, figures out tax and shipping and then adds them all up.
>the problem is that I can't seem to truncate the total after 2 decimal
>places.
>
> It is not uncommon for tax to be 2.3456785 or something like that.
>I would like to be able to make that number 2.35 or if nothing else just
>cut it off at 2 places without rounding.
>
> I have tried a few methods but nothing seems to work well.
>
>
>Thanks for any help
>
>Andrew Perrella
>perrella@uiuc.edu
>
>

The canonical way to do this* is something like

$total = int(($total + .005) * 100) / 100;

You want to add that half cent to make sure the number rounds correctly. You
probably also want to use a formatted printing function like sprintf so you
don't end up printing $7.3 when you really mean $7.30.

--- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl

=======================================
* a fancy way of saying "This is how we used to do it in TRS-80 Basic" :D




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

Date: Wed, 26 Nov 1997 21:07:26 -0800
From: "Matt Osborne" <mageos@hotmail.com>
Subject: A Good Perl Site for syntax
Message-Id: <65iv6g$ceh@dfw-ixnews12.ix.netcom.com>

Does anyone know of a good site to find the syntax of certain methods?




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

Date: 27 Nov 1997 10:07:52 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: "Matt Osborne" <mageos@hotmail.com>
Subject: Re: A Good Perl Site for syntax
Message-Id: <8coh36e047.fsf@gadget.cscaper.com>

>>>>> "Matt" == Matt Osborne <mageos@hotmail.com> writes:

Matt> Does anyone know of a good site to find the syntax of certain methods?

It's probably easier to find the syntax of uncertain methods. :-)

In reality, when a module is installed, the docs for it get installed
nearby the module, so you should have the docs all sitting there right
on your disk.

Perhaps you could have been a little more vague about what you were
looking for.  Perhaps not. :-)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 277 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: Thu, 27 Nov 97 10:01:55 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: Can I do $! = 'string' ?
Message-Id: <347d8bad$1$ofn$mr2ice@speaker>

In <65hptr$o46@buffalo.HL.Siemens.DE>, on 11/26/97 at 07:31 PM,
   Marek.Rouchal@-nospam-hl.siemens.de (Marek Rouchal) said:
+-----
| The manual says that $! can take only numerical values; on the
| other hand, $! contains error messages when evaluated in a string context.
| Is it possible to assign error messages to $! somehow?
+--->8

$! is fundamentally numeric; in a string context, it looks up the error number
in a system error table.  You don't have access to the error table (it's part
of your system's C library, not part of Perl), so you can't add your message
to it.

-- 
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: 27 Nov 1997 09:57:19 -0600
From: claird@Starbase.NeoSoft.COM (Cameron Laird)
Subject: Re: Changing Values in Registry from command line
Message-Id: <65k58v$n8d$1@Starbase.NeoSoft.COM>

In article <347cc820.287255291@news.micron.net>,
Chris Lawson <lawsonc@micron.net> wrote:
>On Wed, 26 Nov 1997 17:06:45 -0600, "Paul D. Rodrigue"
><pdr@onramp.net> wrote:
>
>>Is there a way to modify the values for a specific key in the registry
>>from the command line? (something like using set to assign the value).
			.
			.
			.
>You can create a *.reg file.  It's just a text file.  You can double
>click on it in the explorer and it invokes regedt32, makes the changes
>and then quits regedit.  Or you can call regedt32 directly from a
>batch file and specify the *.reg file on the command line.  Pretty
			.
			.
			.
 ... and, if you can profit from more power in
your registry automation, Perl and Tcl offer
full programmatic control of the registry in
their Win32 releases.
-- 

Cameron Laird           http://starbase.neosoft.com/~claird/home.html
claird@NeoSoft.com      +1 713 996 8546 FAX


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

Date: 27 Nov 1997 15:44:56 GMT
From: "Keith" <keithlol@nospammindspring.com>
Subject: Cookies and Perl 5
Message-Id: <01bcfb4b$86a7e3c0$af2e56d1@keithlol.com>

Ok, I think I'm losing my mind. I have the following code in a perl CGI for
setting a cookie. It works fine in IExplorer (3.02), with no problems. But
in any version of Netscape (3.01 or 4.03), no cookie is sent, and the
printing of normal HTML after the set cookie line, prints as html source
code.
for example with   print "<head></head>\n"; Netscape will print the actual
HTML source to the document.
I'm running oreillys website ver 1.1 on Windows '95 (that shouldn't matter
I wouldn't think).
here's the code:
$expDate = "Wednesday, 09-Nov-99 00:00:00 GMT";
$domain = ".hello.com";
$path = "/";
$usersn = "ME";
$userpw = "doda";

print "Set-Cookie: $usersn=$userpw; expires=$expDate;
path=$path;domain=$domain; secure\n";
print "Content-type: text/html\n\n";                                     

Thanks in advance you any help.... Keith M.


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

Date: 27 Nov 1997 16:50:36 GMT
From: "Keith" <keithlol@nospammindspring.com>
Subject: Re: Cookies and Perl 5
Message-Id: <01bcfb54$b5a5d520$3c2d56d1@www.keithlol.com>

Oh ... Gee.. can't believe it. I found the problem.. sorry... DUH..
seems my server name is "http://hello.com", after I changed it to
"http://www.hello.com", it works in both browsers. So be forwarned!!! The
two period requirement in the domain name is a MUST for Netscape, but
IExplorer dosnt seem to care.

Thanks anyway... Hope everyone is haveing a Great ThanksGiving!! Keith M.

Keith <keithlol@nospammindspring.com> wrote in article
<01bcfb4b$86a7e3c0$af2e56d1@keithlol.com>...
> Ok, I think I'm losing my mind. I have the following code in a perl CGI
for
> setting a cookie. It works fine in IExplorer (3.02), with no problems.
But
> in any version of Netscape (3.01 or 4.03), no cookie is sent, and the
> printing of normal HTML after the set cookie line, prints as html source
> code.
> for example with   print "<head></head>\n"; Netscape will print the
actual
> HTML source to the document.
> I'm running oreillys website ver 1.1 on Windows '95 (that shouldn't
matter
> I wouldn't think).
> here's the code:
> $expDate = "Wednesday, 09-Nov-99 00:00:00 GMT";
> $domain = ".hello.com";
> $path = "/";
> $usersn = "ME";
> $userpw = "doda";
> 
> print "Set-Cookie: $usersn=$userpw; expires=$expDate;
> path=$path;domain=$domain; secure\n";
> print "Content-type: text/html\n\n";                                     
> 
> Thanks in advance you any help.... Keith M.
> 


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

Date: Thu, 27 Nov 1997 07:24:57 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: deleting a line in an ascii file
Message-Id: <65k39p$sv5@mtinsc05.worldnet.att.net>


Jan Pazdziora wrote in message ...
>Asmat Ullah <asmat@cad.strath.ac.uk> wrote:
>
>> I need to know how to delete a line from this flat file.
>>
>> example line:
>>
>> Joe:Bloggs:MR:332442:Joe@someplace.com:Room1111
>
>perl -i -pe 'print unless
> $_ eq "Joe:Bloggs:MR:332442:Joe@someplace.com:Room1111\n";'
> filename

>
>Untested. Also check the FAQ.

Or perhaps

perl -pi.bak -e"s/Joe:Bloggs:MR:332442:Joe@someplace.com:Room1111\\n//"
filename

Also untested.

--- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl





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

Date: Thu, 27 Nov 1997 08:50:03 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: For the pro's ? repost: Leaving HTML tags alone
Message-Id: <ra1k56.gl.ln@localhost>

: Patrick (Venice@euronet.nl) wrote:
: : Http is a cool protocol, more info at: <A
: : HREF="http://www.fictional.net>This http site</A>

: : I want to replace 'http' (NOT in the HTML-code) in the above with the
: : full name: Hyper Text Transfer Protocol without changing the http://
: : in the html tag...

: : Or with other words: Replacements without touching things between <>


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

$_ = 'Http is a cool protocol, more info at: <A HREF="http://www.fictional.net">
This http site</A>';

print "$_\n\n";

s/(<[^>]+>)|http/
   defined($1) ? $1 : "HyperText Transfer Protocol";
 /gie;

print "$_\n";
--------------------


Does that do it?


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 28 Nov 1997 00:35:42 GMT
From: Venice @ euronet.nl (Patrick)
Subject: Re: For the pro's ? repost: Leaving HTML tags alone
Message-Id: <65k44c$ohk$2@news.NL.net>

I found it... single line.

s/$search(?=(?:[^>])*(?:[<\n]))/$replace/ig;


Thanx for the tips you perl people !!

Patrick




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

Date: Thu, 27 Nov 1997 13:25:53 GMT
From: colte@hem.passagen.se (Robert)
Subject: Getting file timestamp from array
Message-Id: <347d711d.19902962@news.hogia.net>


I'm having a bit of trouble getting the timestamp from a list of
files. Here's what I've done.

# dir of files that I want the timestamp from
$dir = "../htdocs/noje/files";

opendir (CARDDIR, $dir);

@filearray = readdir(CARDDIR);

foreach $file (@filearray) {
$time = (stat($file))[9];
$ltime = localtime($time);
}

This works for the two first items in the @filearray e.g. "." and ".."
but for the actual files in directory, stat seems to return nothing.

Anyone got a clue ?

Thanks

Robert



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

Date: Thu, 27 Nov 1997 07:10:47 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: How To Test if number is ODD or EVEN?
Message-Id: <65k2f8$r95@mtinsc05.worldnet.att.net>


In article <65a0bb$7ma@dec.cuug.ab.ca>, branderr@cuug.ab.ca (Roy Brander)
wrote:

>It's now official.  I will never be a perl guru.  I've been
>staring at that one for a minute and still can't figure it.


Hey, there are those who might consider me a guru. I figure you're not one
until someone says you are. (I get paid to write Perl code, among other
things, but it's not quite the same.) But I occasionally have to sit and
look at a piece of code for a while before I figure out what it does.

It's *really* embarrassing when it's a piece of code I wrote.

It's even *more* embarrassing when it's a piece of code I *just* wrote . . .

--- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl





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

Date: Thu, 27 Nov 1997 22:27:28 +0800
From: "hkstar" <modular@hkstar.com>
Subject: Html - > Unix
Message-Id: <65jvn2$nrf1@lyra.hkstar.com>

Hello,
I am new to Perl!
Is there any way to send Unix commands to www server by means of html?

Any idea is welcom!
Thanks,
joeifox
;)




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

Date: 27 Nov 97 14:47:06 GMT
From: Tom <beans@bedford.net>
Subject: Re: IS THERE A DB INTERFACE INTO MS SQL SERVER?
Message-Id: <347d87ea.0@news3.paonline.com>

"csa@netcom.com" <csa@netcom.com> writes: > Does anybody know of a module that would allow me to interface
> into MS SQL SERVER on a Windows NT machine (besides the ODBC module)?
> 
> Thanks
> csa@netcom.com

A quick and dirty way (with apologies to the Hourly Rate thread) 
is to open a pipe to ISQL. This gives a batch type capability, but
is seems to run fast enough, and allows me to test the SQL in 
Enterprise Manager before running it from perl. I put the SQL in a
file, then open a pipe for reading to get the result of running it.

-Tom  


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

Date: 27 Nov 97 17:11:45 GMT
From: "Bill Parker" <bill@penumbra.co.uk>
Subject: Re: last element in an array?
Message-Id: <01bcfb4e$318bd600$5c053cc3@penumbra.powernet.co.uk>

Hmmm... why does that work then?

I prefer (believe it or not!) the much uglier

$matches[$#matches]


because, now I'm sort of perl-oriented, it feels more intuitive. OK, so I'm
a lost cause, I know....

Bill

Tom Phoenix <rootbeer@teleport.com> wrote in article
<Pine.GSO.3.96.971126092223.3023G-100000@usertest.teleport.com>...
> On Tue, 25 Nov 1997, it was written:
> 
> > how do I reference the last element of @matches? 
> 
> That would be $matches[-1]. Hope this helps!
> 
> -- 
> Tom Phoenix           http://www.teleport.com/~rootbeer/
> rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
> Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
>               Ask me about Perl trainings!
> 
> 


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

Date: Thu, 27 Nov 1997 16:15:18 +0100
From: "Reinhard E. Voglmaier" <rv33100@glaxowellcome.co.uk>
Subject: libwww - LWP::UserAgent
Message-Id: <347D8E85.5E7B4F47@glaxowellcome.co.uk>

Hi,

I'm using libwww version 5.16. Now I tried to simulate a HTML-Form with
the LWP::UserAgent. I send my request to the server, nearly everything
worked right, nearly !!! Filling the Request in
$request->content("Query") I don't succeed to get at the server the
Query_String.
I'm testing the application with an CGI program that dumps the variables
out.
Is there something I missed or is there a know problem on libwww ?

Thanx for any hint
Cheers
Reinhard



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

Date: Thu, 27 Nov 1997 15:07:20 +0000
From: John Clutterbuck <john.clutterbuck@sbs.siemens.co.uk>
Subject: Microsoft RTF Decoder Wanted
Message-Id: <347D8CA8.41C6@sbs.siemens.co.uk>

Hi,

I need some perl software to decode RTF format files such as those saved
by from Microsoft Word 6.0 etc. (if RTF is chosen)

I primarily need the plain text with all the control information
stripped out, but it would be useful to know about headers and tables
etc.

If anyone has some routines or knows where I can find them I would be
most grateful.

Thanks in anticipation

-- 
# John Clutterbuck
# Siemens Business Services
Never eat on an empty stomach


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

Date: Thu, 27 Nov 1997 06:56:20 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: Newbie question.   Do you recommend moving from C?
Message-Id: <65k1k5$pid@mtinsc05.worldnet.att.net>

I go the other direction. I come from a background of 24 years of computer
programming of one type or another (not continuous, but my first programs
were written in Basic and FORTRAN on an IBM 360/70 mainframe in 1973 -- ah,
for the days of punch cards and Teletypes). I learned a number of
programming languages, including several flavors of Basic, dBase, MSDOS's
batch file language and a bunch of others, but I always avoided C, except
for a brief flirtation with it seven or eight years ago that left me
thinking, "Life's too short for this" and sent me back to doing WordPerfect
macros.

I took up Perl about six months ago. I loved it immediately. Basic-like
simplicity but much more powerful, especially for the kind of work I
currently do (scripting complicated processes involving both Wintel and Mac
computers). Recently I've decided my total lack of C was a big gaping hole
in my resume, so I got a copy of Dan Gookin's
you-should-pardon-the-expression "C For Dummies" and found that now that I
have a handle on Perl, C is much more comprehensible. Sure, it still
combines the flexibility and power of assembly language with the readability
and ease of coding of assembly language, and pointers are still a pain in
the butt, but I can now write a simple C program that compiles properly and
does what I want (as long as my wants are modest -- I am, after all, still a
novice).

My recommendation would be to learn Perl, then C, and from there go to C++
and/or Java. I would not, however, "move from C to Perl". They're two
different languages for two different types of problems, and I'd learn them
both.

--- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl





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

Date: Thu, 27 Nov 1997 08:39:17 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Newbie question.   Do you recommend moving from C?
Message-Id: <lm0k56.gl.ln@localhost>

Patrick McGovern (pmcgovern@sherikon.com) wrote:
: This is a multi-part message in MIME format.
                               ^^^^^^^^^^^^^^

: Would you use a hammer to insert a screw? Use the right tool for the
                                                    ^^^^^^^^^^
: right job....


   LOL!


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 27 Nov 1997 17:09:35 GMT
From: alecto <alecto@pe.BogusstrinG.net>
Subject: Re: pattern substituition operation question
Message-Id: <65k9gf$aj2$1@nntp.pe.net>

jlee <jlee@mdsi.bc.ca> wrote:
>I want to delete all the white spaces from a string but do not want to
>delete the spaces that are between quotation marks. For example, if I
>have the following string:

>    test= "aaa aaa " bbb bbb "ccc ccc"   ddd  
Note:	           ^
Note:              ^ I am considering this space a typo
Note:	           ^ on the orginal poster's part

>and want the result to be:

>    test="aaa aaa"bbbbbb"ccc ccc"ddd

>Does anyone know how to do this with the pattern substitution operation?
>I know you can do this in sed since has pattern addressing.

one way is:

#! /usr/bin/perl -w
foreach (<>) {
if (/(test=\s"[^"]*")([^"]*)("[^"]*")(.*$)/) {
 $foo = $2; $bar = $4;
        foreach ($foo,$bar){
        s/\s+//g;
        }
 print "$1$foo$3$bar\n";
 }
}




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

Date: Wed, 26 Nov 1997 17:18:02 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: PERL Hourly Rates
Message-Id: <65i6pp$gsp@bgtnsc03.worldnet.att.net>

In article <347C5E08.2FD1E9A@olywa.net>, Steven May <stevenjm@olywa.net> wrote:


> I've noted posts where the posters seem to feel that the 'gurus' look
> down on newbies and their ignorance.  Careful reading of this tread
> shows that is not the case at all.  Ignorance is a condition we all
> suffer from, but treatment IS available.

well, we were all newbies at some point ;)

when i forget that, i just pull out the old FORTRAN code with which
i had to deal.  talk about ugly...

-- 
brian d foy                                 <http://computerdog.com>
#!/usr/bin/perl
$_=q|osyrNewkecnaYhe.mlorsePptMskurj|;s;[NY.PM]; ;g;local$\=
qq$\n$;@pm=split//;while($NY=pop @pm){$pm.=$NY;$ny.=pop @pm}
$pm=join'',reverse($ny,$pm);open(NY,'>&STDOUT');print NY $pm


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

Date: Thu, 27 Nov 1997 07:04:37 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: PERL Hourly Rates
Message-Id: <65k23l$qjv@mtinsc05.worldnet.att.net>


brian d foy wrote in message <65i6pp$gsp@bgtnsc03.worldnet.att.net>...
>
>well, we were all newbies at some point ;)
>
>when i forget that, i just pull out the old FORTRAN code with which
>i had to deal.  talk about ugly...
>


I think about the old FORTRAN code I used to write. I took one programming
class the first time through college -- Introductory FORTRAN, I believe it
was called -- and got a D+. Of course, there WAS this girl . . .

(Well, there still is this girl, but a different girl now -- several, in
fact, if you count daughters and granddaughters, and in the meantime Perl
was invented. :D)




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

Date: 27 Nov 1997 16:41:03 GMT
From: ryujiy@aol.com (Ryujiy)
Subject: Print out array!
Message-Id: <19971127164101.LAA24197@ladder01.news.aol.com>

Hello All ! 

This is a part of my program.    This program is supposed to print out even
number of element of the array(@starray[0,2,4, ...so on]), but it prints put
odd number of element of the array(@starray[1,3,5...so on]).  I don't
understand the reason.  Could someone explain me?

Thanks! 

Ryuji Yokoyama
ryujiy@aol.com


@files = qw( 
                   aug.txt
                   dec.txt	); 

string = "Hello World";
$count1 = 0;
$numfile = $#files;
while ($files[$count1]){
          $target = `grep -i $string $files[$count1]`;
           @starray = split (/:/,$target); #The result of grep is divided and
stored as an element of array	
           $numarray = $#starray;       #Get number of array element	
                 
                     if ($target ne '') {           
                                            for ($count2 = 0; $count2 <=
$numarray; $count2+=2) {
		                       print "The string is\n" ;
                                                    print
"$starray[$count2]\n\n";
                                                  }


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

Date: 27 Nov 1997 16:34:48 GMT
From: "Robert Friberg" <robert.friberg@your_clothes.eductus-vast.com>
Subject: Re: read from end of file (by line)
Message-Id: <01bcfb51$dfa53440$c82da8c0@akilles.ittek.org>

If your on a unix system you could use tail like this:
  
  @lines = `tail -n$count $file`;

but DON'T do this (unless your charging cpu time):

  #!/usr/bin/perl -w
  $count = 1;
  $file = '/var/lib/httpd/logs/access_log';
  $lcount = `wc -l $file`;
  do {
    ($line, @junk) = `tail -n$count $file`; 
    &process($line); 
    $count++;
  } while ($count <= $lcount);


The *right* way is probably rolling your own module
using seek and read unless you can settle for some
compromise using tail.

Here's a compromise, adjust count,chunk and ratio
to suit your needs:

#!/usr/bin/perl -w
   $chunk = 1000;
   $count = 1000;
   $ratio = 0.2;
   $file = '/var/lib/httpd/logs/access_log';
# if the length of each line is constant then
# $lcount should be calculated from the filesize
   $lcount = `wc -l $file`;
   $painlimit =$lcount * $ratio;
   do {
     @lines = (`tail -n$count $file`)[0..$chunk-1]; 
     @lines = reverse @lines; # you might not even need the reverse?
     &process(@lines); 
     $count+= $chunk;
   } while ($count < $painlimit);

-- 

Hope this helps,
robban
robert.friberg(a)eductus-vast.com

Scott Anthony Hamilton <sah@uow.edu.au> skrev i inldgg
<sah.880435607@wumpus>...
> I'm in the process of writing a small module for reading from
> the end of the file line by line to the beginning. Much like
> $scalar = <FH> but in reverse.
> 
> Before I go on, is there a perl trick which can accomplish this
> task with ease?
> 
> --
> Scott Hamilton / sah@uow edu au / KeyID C3107E75
> 87 FE 1D C3 DE 20 37 FB  6F 30 6A 8A D1 38 9A B5
> 


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

Date: 27 Nov 1997 09:45:06 -0600
From: claird@Starbase.NeoSoft.COM (Cameron Laird)
Subject: Re: Readable Sources
Message-Id: <65k4i2$m7u$1@Starbase.NeoSoft.COM>

In article <65h6ok$hef$2@srv38s4u.cas.org>,  <lvirden@cas.org> wrote:
			.
			.
			.
>Anyways, I think that Tcl developers need to make sure that there is
>an understanding that tools written in any interpreted language are going
>to be tough to 'harden' into a format that's non-readable yet still
>scripts...
			.
			.
			.
Those interested in the theme of "non-readable yet still
scripts" might want to investigate Python's .pyc byte-code
format, Python's "freeze" tool, which facilitates distri-
bution of stand-alone executables, Perl's Compiler, the
Bigloo compiler for Scheme, REXXC, ...
-- 

Cameron Laird           http://starbase.neosoft.com/~claird/home.html
claird@NeoSoft.com      +1 713 996 8546 FAX


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

Date: Thu, 27 Nov 1997 16:33:02 +0000
From: Chris Russell <ca5cru@isis.sund.ac.uk>
Subject: Sendmail
Message-Id: <347DA0BE.2049@isis.sund.ac.uk>

Hi,

  I`m new to the group so if this question has been asked before,
  then I apologise.

  I have a number of perl scripts from university that use sendmail
ala piping to sendmail xxx@xxx.co.uk ...

  These used to work fine, but now they dont .. they run fine under
linux but no longer at uni ..

  I have heard about some SUID patch which may have stopped this working
 .. scripts were on 705 with no SUID ..

  How do I get round this problem, as I can no longer send mail from any
of my scripts!!!


 Thanks in advance

Chris Russell
ca5cru@isis.sund.ac.uk


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

Date: 27 Nov 1997 14:26:34 GMT
From: sap1d@canit.se (Johan Dalstrom)
Subject: SIG-signals
Message-Id: <65jvuq$tbm@dos.canit.se>

Hey..

I'm writing a little password-protection-script in perl..

It's working fine with one exeption.. You can press ^Z to
put the program in the background and then kill it.

Is there a SIG-signal for ^Z so i can disable that function?


/ Johan
-- -
    Johan Dalstrom			sap1d@canit.se
						       - --


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

Date: Thu, 27 Nov 1997 15:03:45 +0100
From: "Ronald G\"oggel" <r.goeggel@atos-group.de>
Subject: Re: truncating a string
Message-Id: <65jukg$7kg$1@news.pop-stuttgart.de>


Bill Eberle wrote <65i7t1$8c0$1@news.inficad.com>...
>I have a problem with limiting the size of a string variable.  I want to
>take the first ten characters and delete the rest.  Does anyone know an
>easy way to do this, short of reading the first ten characters into an
>array?  Thanks.
>

you can cat a variable by
substr($string, 10) = '';

or assign it directly to an array

$array[0] = substr($string, 0, 10);

HTH
Ronald




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

Date: 27 Nov 1997 14:22:25 GMT
From: "Jeff Wilson" <jwilson@ic.ac.uk>
Subject: Re: truncating a string
Message-Id: <01bcfb3f$e184a7d0$d53ec69b@leicester>

$string = substr($string,0,10);  should do it.
-- 

                                Jeff Wilson
                                London - UK

Bill Eberle <wile@inficad.com> wrote in article
<65i7t1$8c0$1@news.inficad.com>...
> I have a problem with limiting the size of a string variable.  I want to 
> take the first ten characters and delete the rest.  Does anyone know an 
> easy way to do this, short of reading the first ten characters into an 
> array?  Thanks.
> 
> Please remove <nospam> from my address if responding via email.
> 


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

Date: 27 Nov 97 15:07:47 GMT
From: Tom <beans@bedford.net>
Subject: Re: truncating a string
Message-Id: <347d8cc3.0@news3.paonline.com>

"Ronald G\"oggel" <r.goeggel@atos-group.de> writes: > 
> Bill Eberle wrote <65i7t1$8c0$1@news.inficad.com>...
> >I have a problem with limiting the size of a string variable.  I want to
> >take the first ten characters and delete the rest.  Does anyone know an
> >easy way to do this, short of reading the first ten characters into an
> >array?  Thanks.
> >
 
How about:

$myvar =~ s/(.{0,10}).*/$1/;




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

Date: Thu, 27 Nov 1997 15:59:50 -0000
From: "A Farrow" <a.n.farrow@cranfield.ac.uk>
Subject: Two way Sockets using Perl 5 (Win32)
Message-Id: <347d98ff.0@news.cranfield.ac.uk>

Hi,

I've been using the win32 version of Perl5 for some time now and I am
having some great success with socket programming. However, I
fail to see how I can get two way commnication down one socket
using Perl. I am sure it must be possible but I only seem to be able to send
the one way.

For example, if I have a server listening which basically displays inputs
from connections thus  (code fragment, assume socket has already been set
up):

for ( ; $paddr = accept (CLIENT, SERVER); CLOSE (CLIENT))

{
while ($data = <SOCKET>)
    {
    print $data;
    }

}

and a client thus :

#use TCP
$proto = getprotobyname("tcp");
socket(SOCKET, $PF_INET, $SOCK_STREAM, $proto) || die "Can't create socket :
$!";
bind(SOCKET, $this_addr) || die "Can't bind: $!";
connect(SOCKET, $serv_addr) || die "Can't connect : $!";
print  SOCKET "Any Old Rubbish";
close (SOCKET);


So, how would I go about sending an acknowledgement back to the client so
it knows it has received it okay, or long term some complex data from the
server process?

Thanks in advance,


    Anthony Farrow


a.n.farrow@cranfield.ac.uk
Systems Programmer, Cranfield University




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

Date: 27 Nov 1997 15:28:35 GMT
From: "indy" <indy@mail.www-service.de>
Subject: undump
Message-Id: <01bcfb49$69b84680$19de34c3@martin.de>

Hi,

where can I get the sources of the undump program.

I've searched a lot and also downloaded the sources of teTeX-src-0.4 but
couldn't find it.

Who can help me in this.

Thank you,

Indy


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

Date: 27 Nov 1997 16:21:41 GMT
From: "indy" <indy@mail.www-service.de>
Subject: Re: undump
Message-Id: <01bcfb50$d3e09ec0$19de34c3@martin.de>

Excuse me,

but finally I've found it on my own.

Thanks.

Indy

indy <indy@mail.www-service.de> schrieb im Beitrag
<01bcfb49$69b84680$19de34c3@martin.de>...
> Hi,
> 
> where can I get the sources of the undump program.
> 
> I've searched a lot and also downloaded the sources of teTeX-src-0.4 but
> couldn't find it.
> 
> Who can help me in this.
> 
> Thank you,
> 
> Indy
> 


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

Date: Thu, 27 Nov 1997 11:05:08 +0100
From: Philippe Le Berre <leberre@bandol.grenoble.hp.com>
Subject: Updates on Win32::Eventlog
Message-Id: <347D45D4.AD891F4D@bandol.grenoble.hp.com>

Hi all,

For the one interested in the Win32::Eventlog, I ve updated the docs on
it. All the functions are now covered plus some new ones from my own.

<http://www.inforoute.cgs.fr/leberre1/>

Cheers,

-- 
Philippe Le Berre
SSG - CSBU R&D
Advance Technology Lab, Europe
----------------------------------------------------------------
Hewlett-Packard			<leberre@bandol.grenoble.hp.com>
5 av Raymond Chanas		http://www.inforoute.cgs.fr/leberre1/
38053 Grenoble Cedex 9,		Tel : 33 4 76 14 66 05
France				Fax : 33 4 76 14 14 65


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

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

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