[16652] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4064 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 19 03:05:29 2000

Date: Sat, 19 Aug 2000 00:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <966668714-v9-i4064@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 19 Aug 2000     Volume: 9 Number: 4064

Today's topics:
    Re: $PREMATCH and $POSTMATCH <ren.maddox@tivoli.com>
    Re: Eval and Regexps Help (Martien Verbruggen)
    Re: Eval and Regexps Help bluearchtop@my-deja.com
    Re: Eval and Regexps Help (Martien Verbruggen)
        Forking sub{}'s and selective SIG{CHLD} responses <unixgod@jacksonville.net>
    Re: help foreach doesn't work <timewarp@shentel.net>
    Re: help foreach doesn't work j355@my-deja.com
    Re: help foreach doesn't work <lr@hpl.hp.com>
    Re: HELP: interpolation of patterns and the pos command j355@my-deja.com
    Re: How do I get statistics from Win NT processes?  (ie <pmudundi@gis.net>
    Re: How do I get statistics from Win NT processes? (ie  <amonotod@netscape.net>
    Re: Matching the e-mail header <timewarp@shentel.net>
    Re: Matching the e-mail header (David Efflandt)
    Re: Matching the e-mail header (Tony L. Svanstrom)
    Re: Matching the e-mail header (Tony L. Svanstrom)
    Re: Matching the e-mail header <timewarp@shentel.net>
    Re: Matching the e-mail header (Mike Stok)
    Re: Matching the e-mail header (Martien Verbruggen)
    Re: Modifying a text file (Eric Bohlman)
    Re: My script has some bugs (Gwyn Judd)
    Re: obfusicate routine to count max string len in hash (Abigail)
    Re: obfusicate routine to count max string len in hash (Logan Shaw)
    Re: obfusicate routine to count max string len in hash (Gwyn Judd)
    Re: obfusicate routine to count max string len in hash <lr@hpl.hp.com>
    Re: obfusicate routine to count max string len in hash <lr@hpl.hp.com>
    Re: OT: Anyone interested in selling their Perl 4 books <stevem@rt66.com>
        Passing argument to Perl script <lem@ocean.com.au>
    Re: Passing argument to Perl script <amonotod@netscape.net>
    Re: Perl guestbook hacking (with HTML enabled) <mauldin@netstorm.net>
    Re: porting send.pl to linux from a solaris system (David Efflandt)
    Re: try & catch (Abigail)
    Re: Use of uninitialized value, but it's not uninitiali (Decklin Foster)
        Using Win32::NetAdmin on remote machine (Homer Simpson)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 18 Aug 2000 18:29:08 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: $PREMATCH and $POSTMATCH
Message-Id: <m38ztu9mij.fsf@dhcp11-177.support.tivoli.com>

fgont@my-deja.com writes:

> I've FOUND that $PREMATCH an $POSTMATCH functions don't work in the
> same way as $` ans $'...
> I mean, if I use them, my code doesn't work, but if I use $` and $'
> instead, my code works OK... do you know why?

You need to:

use English;

to have access to those long variable names.

For more information, see:

perldoc English

or even:

perldoc perlvar

which has a sentence right at the beginning indication to "use English;".

-- 
Ren Maddox
ren@tivoli.com


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

Date: 19 Aug 2000 01:19:26 GMT
From: mgjv@martien.heliotrope.home (Martien Verbruggen)
Subject: Re: Eval and Regexps Help
Message-Id: <slrn8pro5q.n7v.mgjv@martien.heliotrope.home>

On Sat, 19 Aug 2000 00:15:35 GMT,
	bluearchtop@my-deja.com <bluearchtop@my-deja.com> wrote:
> 
> Thanks, but that didn't work for me. Example:
> 
> $str=<<_EOF_;

This will do double-quote interpolation of the string, which means that

> The current time is:
> <%
> $x=localtime(time);
> $x;

These two $x's will be expanded when the string is created.

You should consider using -w. It would have spit out some warnings.

Try

$str=<<'_EOF';
 ...

or 
$str = q(
);

or 

$/ = 0;
$str = <DATA>;
 ...
__DATA__
 ...

Read more about here docs in perldata:

# perldoc perldata

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd.   | again. Then quit; there's no use
NSW, Australia                  | being a damn fool about it.


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

Date: Sat, 19 Aug 2000 02:42:39 GMT
From: bluearchtop@my-deja.com
Subject: Re: Eval and Regexps Help
Message-Id: <8nks6s$fri$1@nnrp1.deja.com>



> You should consider using -w. It would have spit out some warnings.
>
> Try
>
> $str=<<'_EOF';
> ...

Thank you, Martien, that worked! It did bring up another problem
though. Example:
######################
$str=<<'_EOF';
The current time is:
<%
$x=localtime(time);
$x;
%>

Count to 10:

<%
for ($i=1;$i<11;$i++) {
  $i." ";
}
%>
_EOF
$str=~s/<%(.*?)%>/eval($1)/sge;
print $str;
########################


$ perl -w test.pl
Useless use of concatenation in void context at (eval 2) line 4.
The current time is:
Fri Aug 18 22:39:06 2000

Count to 10:

Why does it think $i is a void context?


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 19 Aug 2000 06:49:40 GMT
From: mgjv@martien.heliotrope.home (Martien Verbruggen)
Subject: Re: Eval and Regexps Help
Message-Id: <slrn8psb5h.n7v.mgjv@martien.heliotrope.home>

On Sat, 19 Aug 2000 02:42:39 GMT,
	bluearchtop@my-deja.com <bluearchtop@my-deja.com> wrote:
> $str=<<'_EOF';
[snip]
> <%
> for ($i=1;$i<11;$i++) {
>   $i." ";
> }
> %>
> _EOF
> $str=~s/<%(.*?)%>/eval($1)/sge;
> print $str;
> ########################
> 
> 
> $ perl -w test.pl
> Useless use of concatenation in void context at (eval 2) line 4.
> The current time is:
> Fri Aug 18 22:39:06 2000
> 
> Count to 10:
> 
> Why does it think $i is a void context?

because you don't assign the result of $i."" to anything. Did you mean
something like:

<%
$x = '';
for ($i = 1; $i < 11; $i++)
{
	$x .= "$i ";
}
$x;
%>

or 

<%
$x = '';
$x .= "$_ " for (1 .. 10);
$x;
%>

You will have to add the result of whatever you do in the loop to the
end of something if you want to use it. Using arrays interpolated in
strngs ceverly could help you here as well:

<%
@a = (1..10);
"@a";
%>

Or even directly, but forget that I showed you this again immediately:

<%
"@{[(1..10)]}"
%>

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Freudian slip: when you say one thing
Commercial Dynamics Pty. Ltd.   | but mean your mother.
NSW, Australia                  | 


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

Date: Sat, 19 Aug 2000 02:19:52 GMT
From: "Mark Neill" <unixgod@jacksonville.net>
Subject: Forking sub{}'s and selective SIG{CHLD} responses
Message-Id: <c9mn5.31202$56.137501@typhoon.jacksonville.mediaone.net>

Please respond in Email as well, I don't normally frequent this newsgroup -
mark@thisismyown.com

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

I'm having a problem with a program I'm writing that inconveniently happens
to be under a deadline.  It's a Perl/Tk GUI to monitor the status of a
number of tape drives.  The querying of the drives takes a long time,
though, so I have written the code to fork a child to do the actual
monitoring, leaving the GUI to respond to clicks and such.  The pseudocode
is at http://www.thisismyown.com/files/perl.html
 if you want to see, but basically, the Tk::MainWindow::repeat() method
calls a forking wrapper to sub A{} every so often.  On the exit of said
fork, I want to run sub B{}.  I can't install a blatant SIG{CHLD} handler,
because the various subs are making system calls and other execs that are
returning false CHLD's.

What do I need to do to _selectively_ trap and respond to SIG{CHLD}?





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

Date: Fri, 18 Aug 2000 21:19:54 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: help foreach doesn't work
Message-Id: <399DE0BA.AB8534B6@shentel.net>

Boy - this code looks really scrambled when it word wraps. On my PC I took
the liberty of stretching it out across my 4-21" monitors (quad monitor
desktop) so I could see what the heck you had here. Anyway - I don't see
where you are getting the contents for the array @week from. If you are not
loading this up first, then your code here will do nothing. Other than that
I cannot find fault with it.

Albert Dewey

cornelhughes@netscape.net wrote:

> I am new to perl and trying to figure out why the following code won't
> work? Why doesn't the following code print "Why Don't you work";
>
> # determine which week to display, creates var- schedweek
> $indx = 0;
> $schedweek = 0;
> foreach $week (@week)
>  {
>  print "Why don't you work";
>     if (index($datetxt[$indx],"MONDAY")>0)    # the week of Monmad are
> defined by monday
>   {
>        if (($gameyear[$indx] > $year) || (($gameyear[$indx] == $year) &&
> ($gamemonth[$indx] > $mon)) || (($gameyear[$indx] == $year) &&
> ($gamemonth[$indx] == $mon) && ($gameday[$indx] > $mday)) ||
> (($gameyear[$indx] == $year) && ($gamemonth[$indx] == $mon) &&
> ($gameday[$indx] ==$mday) && ($gamehour > $hour)))
>    {
>               $schedweek = $week;
>               last;
>            }
>    }
>
>  $indx +=1;
>  }
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.



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

Date: Sat, 19 Aug 2000 03:54:42 GMT
From: j355@my-deja.com
Subject: Re: help foreach doesn't work
Message-Id: <8nl0dr$kef$1@nnrp1.deja.com>

Not only is @week empty, but don't you need to assign the scaler,
$week, to a name other than the @week array?

In article <8nkjdr$6d1$1@nnrp1.deja.com>,
  cornelhughes@netscape.net wrote:
> I am new to perl and trying to figure out why the following code won't
> work? Why doesn't the following code print "Why Don't you work";
>
> # determine which week to display, creates var- schedweek
> $indx = 0;
> $schedweek = 0;
> foreach $week (@week) {
> print "Why don't you work";
>    if (index($datetxt[$indx],"MONDAY")>0) {    # the week of Monmad
are
> defined by monday
>       if (($gameyear[$indx] > $year) || (($gameyear[$indx] == $year)
&&
> ($gamemonth[$indx] > $mon)) || (($gameyear[$indx] == $year) &&
> ($gamemonth[$indx] == $mon) && ($gameday[$indx] > $mday)) ||
(($gameyear
> [$indx] == $year) && ($gamemonth[$indx] == $mon) && ($gameday[$indx]
==
> $mday) && ($gamehour > $hour))) {
>             $schedweek = $week;
>             last;
>          }
>
>       }
>
>    $indx +=1;
>    }
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 18 Aug 2000 23:17:02 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: help foreach doesn't work
Message-Id: <MPG.1407c636ea55120b98aca1@nntp.hpl.hp.com>

[Rearranged and snipped for logical coherence and relevance.]

In article <8nl0dr$kef$1@nnrp1.deja.com>, j355@my-deja.com says...
> In article <8nkjdr$6d1$1@nnrp1.deja.com>,
>   cornelhughes@netscape.net wrote:

 ...

> > foreach $week (@week) {

> Not only is @week empty, but don't you need to assign the scaler,
> $week, to a name other than the @week array?

No, it is OK, because $week has no relation whatever to @week.  But it 
isn't necessarily the best style.  I would name the array @weeks to 
emphasize its aggregate nature, while $week is a scalar.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sat, 19 Aug 2000 04:16:48 GMT
From: j355@my-deja.com
Subject: Re: HELP: interpolation of patterns and the pos command
Message-Id: <8nl1n4$lnu$1@nnrp1.deja.com>

See http://www.activestate.com/Products/ActivePerl/docs/index.htmlindex

index STR,SUBSTR,POSITION

index STR,SUBSTR

The index function searches for one string within another, but without
the wildcard-like behavior of a full regular-expression pattern match.
It returns the position of the first occurrence of SUBSTR in STR at or
after POSITION. If POSITION is omitted, starts searching from the
beginning of the string. The return value is based at 0 (or whatever
you've set the $[ variable to--but don't do that). If the substring is
not found, returns one less than the base, ordinarily -1.



In article <8nkir3$knj$1@quip.eecs.umich.edu>,
  radev@quip.eecs.umich.edu (Dragomir R. Radev) wrote:
> I am trying to see where in $long does a substring $short appear.
>
> ======================
> #!/bin/perl
>
> $long = <>;
> chop $long;
> $short = <>;
> chop $short;
>
> $long =~ m/$short/g;
> $pos = pos $long;
>
> print "$pos\n";
> ======================
>
> The code above works fine except in the cases where $short and $long
> contain special symbols.
>
> E.g., when $long is:
>
> The ticket wins $one million
> ____________________________
>
> and $short is:
>
> wins $one
> _________
>
> In such a case, the variable $one in $short gets interpolated and the
> result is not what I want. I have tried escaping some weird characters
> in $short: e.g. the dollar sign:
>
> $short =~ s/\$/\\\\$/g;
>
> but there are others that cause the same problem ("?","/", etc.). Is
> there an exhaustive list of such meta-characters that I could escape
> one by one or is there a routine or technique either for escaping the
> entire pattern ($short) or for running the pos command with no
> interpolation?
>
> Thanks.
>
> Drago
>
> --
> Dragomir R. Radev
radev@umich.edu
> Assistant Professor, School of Information         University of
Michigan
> Assistant Professor, Dept. of Electrical Engineering and Computer
Science
> Phone: 734-615-5225   Fax: 734-763-2285
http://www.si.umich.edu/~radev
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 18 Aug 2000 21:55:12 -0400
From: prasanth Mudundi <pmudundi@gis.net>
Subject: Re: How do I get statistics from Win NT processes?  (ie total memory  used by process)
Message-Id: <399DE900.85E42B8C@gis.net>

Gary Brown wrote:
> 
> I am trying to do a "ps aux" in Winnt.  I would like to track the memory
> used by a process.  I will have the process name, but I can't find any
> module that will give me stats, just ones that start and stop processes.
> Basically, I would like to get the information that taskmanager (processes
> tab) and Performance Monitor(prefmon.exe)  use.
> 
> Any help would be appreciated.


check out  www.generation.net/~aminer

use the Iproc module. One of the most useful after 
adminmisc in winnt world.

excellent documentation to go with it.

I had problems with CPU utilization but all other parameters
works.

Let me know if it works for you.

pmudundi@gis.net.XXX


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

Date: Sat, 19 Aug 2000 03:35:53 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: How do I get statistics from Win NT processes? (ie total memory used by process)
Message-Id: <8nkvao$j7h$1@nnrp1.deja.com>

In article <slrn8pqu2p.e0c.behrens@pc32.haulpak.com>,
  behrens@haulpak.com (Astrid Behrens) wrote:
> There were a couple scripts like that posted to the perl-ntadmin
> mailing list, about a month or two ago.
> You could try searching for them at
> http://www.topica.com/lists/perl-ntadmins/
>
> Astrid
>
That is great advice, but you should've refered him to:
Perl-Win32-Admin@listserv.ActiveState.com,
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin
since ActiveState actually hosts the list.

Ehh, that's IMHO, of course,
amonotod

--
    `\|||/                     amonotod@
      (@@)                     netscape.net
  ooO_(_)_Ooo________________________________
  _____|_____|_____|_____|_____|_____|_____|_____|


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 18 Aug 2000 21:07:19 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: Matching the e-mail header
Message-Id: <399DDDC7.7AE01942@shentel.net>

Fernando -

Try this snippet to match the spaces you are looking for which will put
them into a variable named $ cr -

$cr = chr(13).chr(10);

Not sure if this will be exactly what you are looking for but these chr
values are found in line returns in text area form elements (in pairs)
when the user hits a carriage return. You might get lucky and find that
they are also the same in the e-mail header location such as you are
looking for. The reason there are 2 involved is that there is a carriage
return character and a new line character to make for a single new line
combined. (weird but I didn't make up the rules, I just follow them) In
your case you would be looking for $cr =  chr(13).chr(10).chr(13).chr(10).
Again, not absolutely sure if this will take care of your problem but it
is how I remove line returns in text area form elements and convert them
into <br> tags for pages that have to display accurately in resulting web
pages what the user submitted to the server via a form.

Hope this hasn't been too confusing -

Albert Dewey

fgont@my-deja.com wrote:

> Hi!
>
> I've read that the header of an e-mail message is separated from the
> body by two "newlines" (\n\n).
>
> I saved to disk the whole header and body of an e-mail message, and
> found that this is true, as I found a 0dh 0ah 0dh 0ah between the last
> line of the header and the first line of the body.
>
> But if I make something like:
>
> $_=$message;
> if(/\n\n/){
>        print"I found the header!\n";
> }
>
> The header is never found (the regexp does not match).... do you know
> why?
>
> Kind regards,
>
> Fernando Ariel Gont
> e-mail: fgont@NOSPAM.softhome.net
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.



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

Date: Sat, 19 Aug 2000 01:18:57 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Matching the e-mail header
Message-Id: <slrn8pro42.3d5.efflandt@efflandt.xnet.com>

On Fri, 18 Aug 2000 23:18:03 GMT, fgont@my-deja.com <fgont@my-deja.com> wrote:
>Hi!
>
>I've read that the header of an e-mail message is separated from the
>body by two "newlines" (\n\n).

Apparently someone is misinformed.  Like the other reply said, the first
blank line marks the end of the headers.

>I saved to disk the whole header and body of an e-mail message, and
>found that this is true, as I found a 0dh 0ah 0dh 0ah between the last
>line of the header and the first line of the body.

Above you say you found 4 alternating characters, yet below you search for
2 of the same together, hmm, what is wrong with that picture?

>But if I make something like:
>
>$_=$message;
>if(/\n\n/){
>       print"I found the header!\n";
>}
>
>The header is never found (the regexp does not match).... do you know
>why?

I believe that mail generally ends header lines with carriage return,
linefeed pairs (\r\n), but it wouldn't hurt to consider all possible line
endings in your regex.  Also since you don't do anything with the header,
how would you tell if you found the end of the header or a blank line in
the message body?


-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Sat, 19 Aug 2000 03:27:58 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Matching the e-mail header
Message-Id: <1efldl8.1vxkjk9sss75sN%tony@svanstrom.com>

Albert Dewey <timewarp@shentel.net> wrote:

> The reason there are 2 involved is that there is a carriage return
> character and a new line character to make for a single new line combined.
> (weird but I didn't make up the rules, I just follow them)

Eh, no... \n is LF + NL, not CR + NL.


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
 DSS: 0x9363F1DB, Fp: 6EA2 618F 6D21 91D3 2D82  78A6 647F F247 9363 F1DB
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©1999  <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Sat, 19 Aug 2000 03:32:44 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Matching the e-mail header
Message-Id: <1efldr1.13tqbw5c94tk2N%tony@svanstrom.com>

David Efflandt <efflandt@xnet.com> wrote:

> On Fri, 18 Aug 2000 23:18:03 GMT, fgont@my-deja.com <fgont@my-deja.com> wrote:
> >Hi!
> >
> >I've read that the header of an e-mail message is separated from the
> >body by two "newlines" (\n\n).
> 
> Apparently someone is misinformed.  Like the other reply said, the first
> blank line marks the end of the headers.

And... it's better to search for it when reading the file line by line,
so that he doesn't have to take the whole, and maybe extremly long, body
into RAM.

   while (<SUMTHIN>) {
      if (/^$/) {print 'No more headers'}
   }

     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Fri, 18 Aug 2000 21:46:14 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: Matching the e-mail header
Message-Id: <399DE6E6.4DD623ED@shentel.net>



"Tony L. Svanstrom" wrote:

> Albert Dewey <timewarp@shentel.net> wrote:
>
> > The reason there are 2 involved is that there is a carriage return
> > character and a new line character to make for a single new line combined.
> > (weird but I didn't make up the rules, I just follow them)
>
> Eh, no... \n is LF + NL, not CR + NL.

I knew it was something like that - thanks for the straight poop.

Albert Dewey



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

Date: Sat, 19 Aug 2000 03:00:53 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Matching the e-mail header
Message-Id: <FLmn5.3901$C5.45496@typhoon.austin.rr.com>

In article <1efldl8.1vxkjk9sss75sN%tony@svanstrom.com>,
Tony L. Svanstrom <tony@svanstrom.com> wrote:
>Albert Dewey <timewarp@shentel.net> wrote:
>
>> The reason there are 2 involved is that there is a carriage return
>> character and a new line character to make for a single new line combined.
>> (weird but I didn't make up the rules, I just follow them)
>
>Eh, no... \n is LF + NL, not CR + NL.

Maybe you mean CR + LF, carriage return sends the print head to the left of 
the paper and lf advances the paper in a traditional output device.  If you're
on a unix-ish system

  man ascii

might include

       Oct   Dec   Hex   Char           Oct   Dec   Hex   Char
	   ------------------------------------------------------------
[...]
       012   10    0A    LF  '\n'       112   74    4A    J
[...]
       015   13    0D    CR  '\r'       115   77    4D    M
[...]

(as well as the long forgotten VT character...)

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |
GPG PGP Key 1024D/059913DA         | Fingerprint      0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work)      |                  75D2 9EC4 C1C0 0599 13DA


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

Date: 19 Aug 2000 06:49:42 GMT
From: mgjv@martien.heliotrope.home (Martien Verbruggen)
Subject: Re: Matching the e-mail header
Message-Id: <slrn8psbdj.n7v.mgjv@martien.heliotrope.home>

On Sat, 19 Aug 2000 03:27:58 +0200,
	Tony L. Svanstrom <tony@svanstrom.com> wrote:
> Albert Dewey <timewarp@shentel.net> wrote:
> 
> > The reason there are 2 involved is that there is a carriage return
> > character and a new line character to make for a single new line combined.
> > (weird but I didn't make up the rules, I just follow them)
> 
> Eh, no... \n is LF + NL, not CR + NL.

CR (carriage return) + LF (line feed), but not always.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd.   | reflects this.
NSW, Australia                  | 


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

Date: 19 Aug 2000 05:08:24 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Modifying a text file
Message-Id: <8nl4o8$tsr$3@slb6.atl.mindspring.net>

Lincoln Marr (lincolnmarr@nospam.europem01.nt.com) wrote:
: I have a database stored in text files which is interfaced to the web
: through a perl script. The script allows you to modify, add and delete
: customers from the database - but it's a bit more complex than having one
: database file to store all the information. Depending on the type of
: customer, the information is stored in a different file when adding the
: customer.
: I am writing the 'modify' part of the script and am having a few problems.

You should seriously consider using DBD::CSV or DBD::RAM, which will 
handle all the low-level mechanics of file maintenance for you; your code 
will reduce to writing a few simple SQL INSERT, UPDATE, and DELETE 
statements.  And if your database ever gets so big that you need to go to 
a full-fledged RDBMS, all you'll have to do is change one or two literal 
strings in your code and it will still work.
 


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

Date: Sat, 19 Aug 2000 01:10:36 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: My script has some bugs
Message-Id: <slrn8prnka.ea3.tjla@thislove.dyndns.org>

I was shocked! How could Gwyn Judd <tjla@guvfybir.qlaqaf.bet>
say such a terrible thing:
>I was shocked! How could Brent Schenk <brent.schenk@home.com>
>say such a terrible thing:
>>I have made sure that the headers are in there and everything.  I am trying
>>to figure it out because this is holding me back from my job.  I think I
>>will attach the script to this post for someone to look at.  It's just a

>11) Add the following line just below the "use CGI::Carp" line:
>
>print h();

I had a brain fart. That should of course be:

print header;

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Ever notice how fast Windows runs? Neither did I! (contributed by Frank
v Waveren)


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

Date: 19 Aug 2000 04:15:00 GMT
From: abigail@foad.org (Abigail)
Subject: Re: obfusicate routine to count max string len in hash
Message-Id: <slrn8ps2cu.tj3.abigail@alexandra.foad.org>

Larry Rosler (lr@hpl.hp.com) wrote on MMDXLIV September MCMXCIII in
<URL:news:MPG.14075d9118a393ab98ac9b@nntp.hpl.hp.com>:
)) 
)) The correct answer (as observed later):
)) 
))       $x=(sort{$b<=>$a}map length,keys%hash)[0];

One stroke less:

         $x=(sort{$b<=>$a}map y===c,keys%hash)[0];


Abigail
-- 
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;        
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";


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

Date: 19 Aug 2000 00:03:03 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: obfusicate routine to count max string len in hash
Message-Id: <8nl4e7$kmg$1@provolone.cs.utexas.edu>

In article <slrn8ps2cu.tj3.abigail@alexandra.foad.org>,
Abigail <abigail@foad.org> wrote:
>Larry Rosler (lr@hpl.hp.com) wrote on MMDXLIV September MCMXCIII in
><URL:news:MPG.14075d9118a393ab98ac9b@nntp.hpl.hp.com>:
>)) 
>)) The correct answer (as observed later):
>)) 
>))       $x=(sort{$b<=>$a}map length,keys%hash)[0];
>
>One stroke less:
>
>         $x=(sort{$b<=>$a}map y===c,keys%hash)[0];

O.K., combining that with the idea of looking at the last element of
the list, we get this:

	$x=(sort map(y===c,keys%hash)[-1];

Which I believe is the shortest yet.  As long as we're being confusing,
though, why not do this?

	$x=(sort map(y)))c,keys%hash)[-1];

Now, I want to see emacs's (or any other editor's) perl mode highlight
*that* syntax correctly.

  - Logan


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

Date: Sat, 19 Aug 2000 05:28:27 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: obfusicate routine to count max string len in hash
Message-Id: <slrn8ps6no.g5i.tjla@thislove.dyndns.org>

I was shocked! How could Logan Shaw <logan@cs.utexas.edu>
say such a terrible thing:

>O.K., combining that with the idea of looking at the last element of
>the list, we get this:
>
>	$x=(sort map(y===c,keys%hash)[-1];

ITYM:

$x=(sort map y===c,keys%hash)[-1];

though

>Which I believe is the shortest yet.  As long as we're being confusing,
>though, why not do this?
>
>	$x=(sort map(y)))c,keys%hash)[-1];

similarly:

$x=(sort map y)))c,keys%hash)[-1];

>Now, I want to see emacs's (or any other editor's) perl mode highlight
>*that* syntax correctly.

That's just gross, people like you should be shot :)

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
A woman can look both moral and exciting -- if she also looks as if it
were quite a struggle.
		-- Edna Ferber


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

Date: Fri, 18 Aug 2000 22:57:05 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: obfusicate routine to count max string len in hash
Message-Id: <MPG.1407c18ee18ed9f398ac9f@nntp.hpl.hp.com>

In article <8nl4e7$kmg$1@provolone.cs.utexas.edu>, logan@cs.utexas.edu 
says...
+ In article <slrn8ps2cu.tj3.abigail@alexandra.foad.org>,
+ Abigail <abigail@foad.org> wrote:
+ >Larry Rosler (lr@hpl.hp.com) wrote on MMDXLIV September MCMXCIII in
+ ><URL:news:MPG.14075d9118a393ab98ac9b@nntp.hpl.hp.com>:
+ >)) 
+ >)) The correct answer (as observed later):
+ >)) 
+ >))       $x=(sort{$b<=>$a}map length,keys%hash)[0];
+ >
+ >One stroke less:
+ >
+ >         $x=(sort{$b<=>$a}map y===c,keys%hash)[0];
+ 
+ O.K., combining that with the idea of looking at the last element of
+ the list, we get this:
+ 
+ 	$x=(sort map(y===c,keys%hash)[-1];
+ 
+ Which I believe is the shortest yet.

But even if the syntax error is fixed, it is quite wrong, as it sorts on 

the lexicographic values of the lengths, not on their numerical values 
(i.e., 1, 10, 2, ...).  Don't you think that testing what you post is a 
good idea?

+                                     As long as we're being confusing,
+ though, why not do this?
+ 
+ 	$x=(sort map(y)))c,keys%hash)[-1];
+ 
+ Now, I want to see emacs's (or any other editor's) perl mode highlight
+ *that* syntax correctly.

At first glance, '===' looks like a brand-new operator.  I won't say 
what ')))' looks like.  :-)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 18 Aug 2000 23:08:20 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: obfusicate routine to count max string len in hash
Message-Id: <MPG.1407c4349311950598aca0@nntp.hpl.hp.com>

In article <8nkkm0$k87$1@provolone.cs.utexas.edu>, logan@cs.utexas.edu 
says...

 ...

> How about this:
> 
> 	$mlen=(sort map(s/.//g,keys%hash))[-1];
> 
> Or (shorter variable names):
> 
> 	$l=(sort map(s/.//g,keys%h))[-1];

Wrong also, because of lexicographically sorting of the lengths.  Also 
errs if "\n" is in the keys.  But at least it compiles.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 18 Aug 2000 22:42:43 -0600
From: Steve Martin <stevem@rt66.com>
To: mja@ieee.org
Subject: Re: OT: Anyone interested in selling their Perl 4 books that they  haven't thrown out yet?
Message-Id: <399E1043.4057E3FF@rt66.com>

"Quick Reference Guide - Programming Perl", 1991,
   Johan Vromans, No ISBN                                   $1
"Learning Perl", Randal L. Schwartz, Aug 1994,
   1-56592-042-2                                            $1
"Programming Perl", Larry Wall and Randal L. Schwartz,
   Mar 1992, 0-937175-64-1                                  $1

You pay the shipping.

newdebugger@my-deja.com wrote:

> If you do, please email me at mjaNOSPAM@ieNOSPAMee.org with:
>
> In order of importance:
> 1) Year book was published and ISBN
> 2) author and title
>
> along with price
>
> Thanks, MJ
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

--
-------
Steve Martin, NR7P
stevem@rt66.com




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

Date: Sat, 19 Aug 2000 11:51:43 +1000
From: "Minh Le" <lem@ocean.com.au>
Subject: Passing argument to Perl script
Message-Id: <8nkoq3$hb3$1@perki.connect.com.au>

Hi,
I'm trying to pass 3 different arguments to my simple perl script without
any success.  I did try GetOption ... but they are all failed.
What I need is during execute my script, I need to pass 3 different
arguments to the program and depend on which argument has been provided, a
particular sub-routine or task will be called.
Example:  myperl -a x  -b x -c x
where x can be 0 or 1.  if there is no option or argument provided, it will
print out a help message, say " Please run myperl -help"

Please help

Regards





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

Date: Sat, 19 Aug 2000 03:20:35 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: Passing argument to Perl script
Message-Id: <8nkudn$i9f$1@nnrp1.deja.com>

In article <8nkoq3$hb3$1@perki.connect.com.au>,
  "Minh Le" <lem@ocean.com.au> wrote:
> Hi,
> I'm trying to pass 3 different arguments to my simple perl script
> without any success.  I did try GetOption ... but they are all failed.
> What I need is during execute my script, I need to pass 3 different
> arguments to the program and depend on which argument has been
> provided, a particular sub-routine or task will be called.
> Example:  myperl -a x  -b x -c x
> where x can be 0 or 1.  if there is no option or argument provided,
> it will print out a help message, say " Please run myperl -help"
>
> Please help
>
> Regards
>
>
There is a great example of GetOpts in Dave Roths' Win32::Daemon
package, available at www.roth.net/perl/daemon.

HTH,
amonotod

--
    `\|||/                     amonotod@
      (@@)                     netscape.net
  ooO_(_)_Ooo________________________________
  _____|_____|_____|_____|_____|_____|_____|_____|


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 19 Aug 2000 01:23:12 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Perl guestbook hacking (with HTML enabled)
Message-Id: <399DE0D0.C68753C7@netstorm.net>

Sandra wrote:
> 
> We have a simple Perl guestbook based on Matt W.'s guestbook,
> we have HTML enabled. Server is redhat 6.1
> 
> Question:
> 
> 1. I read somewhere it's easy to hack servers using
> HTML-enabled perl guestbooks.  Is this true?  which procedure?
> 
> 2. How to protect an HTML-enabled guestbook?
> I have a function to strip <script></script> <object>, etc, etc
> but I don't know if this is enough protection.
> 

Somewhat OT for clpm but a worthy topic nonetheless. See Lincoln Stein's
excellent CGI security FAQ at http://www.w3.org/Security/Faq/.  Well
worth the effort.

-- Jim


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

Date: Sat, 19 Aug 2000 02:34:17 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: porting send.pl to linux from a solaris system
Message-Id: <slrn8prsha.3d5.efflandt@efflandt.xnet.com>

On Thu, 17 Aug 2000, computertech@my-deja.com <computertech@my-deja.com> wrote:
>
>I have run into a problem trying to get my webmail to work for my linux
>system. The original scripts were written for a solaris system. My
>problem is with the send.pl script. For some reason I get an error that
>says "Failed to open a socket for the connection to the SMTP
>server $host". Does anyone know how to fix this?
>
>Below is a snippet of the code where the problem may be.
>
>Thanks you for any help you can give me,
>
>computertech.

It would be much easier if your sub returned 0 upon success and an error
message if not.  Then you could simply do || return "error message"; if a
statement fails instead of awkward separate statements with message and
return 0.

But your main problem is apparently that your socket code is too OS
specific.  Instead use the genaric built-in Socket methods.

>sub sendmail
>{
>        local($server,$from,$rcpt,$body) = @_;
>#        local($packing_template) = "S n a4 x8";	# delete line
>#        local($protocol) = "tcp";	# delete line
>        local($port) = 25; #SMTP
>#        local($thishost, $problem, $junk);	# ?
>#        local($sockname);	# ?
>

        $iaddr = inet_aton($server);
        unless ($iaddr) {	# for awkward return method
            $smtp_error = "no host: $remote";
            return 0;
        }
        $paddr = sockaddr_in($port, $iaddr);
        $proto = getprotobyname('tcp');

        unless ((socket(SOCKET, PF_INET, SOCK_STREAM, $proto))) {
            $smtp_error = "Failed to open a socket for the connection ".
            "to the SMTP server $host\\n[$!]";
            return 0;
        }


-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: 19 Aug 2000 04:17:01 GMT
From: abigail@foad.org (Abigail)
Subject: Re: try & catch
Message-Id: <slrn8ps2gn.tj3.abigail@alexandra.foad.org>

GI812 (mail@mail.com) wrote on MMDXLIV September MCMXCIII in
<URL:news:399D4D51.97593664@mail.com>:
\\ 
\\ Hello my brilliant friends!  I've got a little bit of a c/java
\\ background and have used tries and catches before.  Just wondering if
\\ there is something of the sort for perl.  I've looked through my books,
\\ but haven't found anything (so far).  What I want to do is check to see
\\ if a file is currently able to be written to or wait a period of time
\\ and then try again.  Kind of a multiuser problem.  If anyone follows my
\\ jibberish or has any insight I'd be happy to see what you have to say!


Well, you could use eval and check $@ for some form of tries and catches.
But for your problem, why don't you just use flock?



Abigail
-- 
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");


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

Date: Sat, 19 Aug 2000 05:04:45 GMT
From: decklin+usenet@red-bean.com (Decklin Foster)
Subject: Re: Use of uninitialized value, but it's not uninitialized.
Message-Id: <Nzon5.1609$CW2.13083@news1.rdc1.ct.home.com>

Larry Rosler <lr@hpl.hp.com> writes:

> On many (most?) machines, that will give you a choice among a set of 
> 2**15 (32768) numbers, not 10**10 numbers.

Interesting. On my machine the limit seems to be 2**31 (IOW, at most 9
decimal digits), hence the comment on 32-bit ints.  perldoc -f rand
suggests that this may depend on how your Perl was compiled as well as
your system. But yes, you should always check.

-- 
There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)


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

Date: 19 Aug 2000 05:33:13 GMT
From: homer.simpson@springfield.nul (Homer Simpson)
Subject: Using Win32::NetAdmin on remote machine
Message-Id: <8nl66p$r2e$0@216.39.130.27>



Greetings.  I'm experimenting with NetAdmin, specifically the function
UserGetAttributes.

Using the example from Learning Perl on Win32 Systems I've been able to get 
data into:



UserGetAttributes("", $userName, $password, $passwordAge, $privilege, 
$homeDir, $comment, $flags, $scriptPath)


and print it out to the screen.

The docs tell me that the first item ("" in the example code from the Gecko 
book) is optional and the machine running the script will be used if it's not 
supplied...
That's certainly true if I put the machine name in a variable or if I leave 
the first part blank I get data from the machine I'm running the script on...

If I put in another machinename I get errors indicating that my print 
statements have uninit'ed variables in them...

I've tried replacing "" with $server and setting $server to:
"\\\\SERVERNAME"
"\\SERVERNAME"          (wrong I know but I was getting frustrated)
"SERVERNAME"
"servername"
"domainname\\servername"

If I put in the name of the server the script is running on it works fine.

I'm a Domain Admin so it's not a rights issue (is it?).

Can someone point me to the sentance or paragraph I've overlooked?

thanks


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


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


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