[10163] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3756 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 19 02:07:10 1998

Date: Fri, 18 Sep 98 23:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 18 Sep 1998     Volume: 8 Number: 3756

Today's topics:
    Re: /etc/passwd file <mpersico@erols.com>
    Re: /etc/passwd file <mpersico@erols.com>
    Re: Can GD.pm make 200 dpi gifs? (Tom Mornini)
    Re: Can you speed up this logfile report??? (Larry Rosler)
    Re: Can you speed up this logfile report??? <rick.delaney@shaw.wave.ca>
    Re: Cookies? (Ronald J Kimball)
        Data difficulties (Jedediah D. Parsons)
    Re: Different way or not to use grep here? (Ronald J Kimball)
    Re: Display Client info in users browser? <samwang@freewwweb.com>
        ePerl Error in Here-Document String <bruceh@interaccess.com>
    Re: How large is a scalar? and related declaration ques (Matthew Bafford)
        LWP Treebuilder w/ Form support? xwang20@hotmail.com
    Re: Need help with a simple program (newbie). (Ronald J Kimball)
    Re: Perl & Java - differences and uses <borg@imaginary.com>
        Please Help <koh_cc@pacific.net.sg>
    Re: PLESE HELP ME!!! (Ronald J Kimball)
    Re: PLESE HELP ME!!! (Ronald J Kimball)
    Re: Problem with piping... (Ronald J Kimball)
    Re: Process checking <rick.delaney@shaw.wave.ca>
    Re: Q:ActiveState's win32release missing makemaker - he <BobN@interaccess.com>
    Re: Removing double entries from array (Tad McClellan)
    Re: Table of Contents Generator (Ronald J Kimball)
        What does the + in print statement do? <webmaster@hubeicorp.com>
    Re: What does the + in print statement do? <egwong@netcom.com>
    Re: what good is flock $LOCK_NB? <samwang@freewwweb.com>
    Re: what good is flock $LOCK_NB? (Michael Fuhr)
    Re: where is Date::Parse? (Matthew Bafford)
    Re: where is Date::Parse? <rra@stanford.edu>
    Re: Which modules needed for httpd POST FORM ? (Larry Hunter)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Fri, 18 Sep 1998 23:52:52 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: /etc/passwd file
Message-Id: <36032A94.D5E3DFB4@erols.com>



Abigail wrote:
> 
> ++ PS> Is there a way to remove users from Red Hat Linux?
> 
> fdisk /dev/hda
> 

Oh that's nasty. Pure nasty.

I like it!

But you better hope you don't get sued. <grin>

-- 
Get "The Perl Cookbook"
Christansen and Torkington. 
O'Reilly. ISBN 1-56592-243-3
FAQ on serious steriods!


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

Date: Fri, 18 Sep 1998 23:58:32 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: /etc/passwd file
Message-Id: <36032BE8.6D757714@erols.com>

You know, when I'm waiting for a process to finish and I have some time
on my hands, I find some of the best entertainment is to sort
comp.lang.perl.misc by sender and go straight to "Abigail". A dryier wit
I have not seen in a long time. For example:

Abigail wrote:
> 
> It's like going into an airport and saying "Could anyone help me?
> I have to fly that 747 to Chicago, and now I need someone to tell
> me what all those lights mean. And if someone is really generous,
> could you point me in the direction of the cockpit?"
> 
> ++ PS> Is there a way to remove users from Red Hat Linux?
> 
> fdisk /dev/hda
> 

-- 
Get "The Perl Cookbook"
Christansen and Torkington. 
O'Reilly. ISBN 1-56592-243-3
FAQ on serious steriods!


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

Date: Sat, 19 Sep 1998 04:33:38 GMT
From: tmornini@netcom.com (Tom Mornini)
Subject: Re: Can GD.pm make 200 dpi gifs?
Message-Id: <tmorniniEzIKo2.4pv@netcom.com>

N.A.F. McNelly (nmcnelly@bu.edu) wrote:

: I have written a script which uses GD to combine a number of pre-existing 
: gifs into a single image.  It works well, but now I need to create 200 dpi
: output gifs.

I don't believe that GIF's have resolution information stored inside.

I'm pretty sure they're just pixels, and that it is either standard, or
generally agreed upon, that they are 72 dpi.

-- Tom Mornini
-- InfoMania


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

Date: Fri, 18 Sep 1998 18:03:37 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Can you speed up this logfile report???
Message-Id: <MPG.106ca2c0d184f3ff9897b1@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <3602FFD0.25A69797@shaw.wave.ca> on Sat, 19 Sep 1998 00:43:55 
GMT, Rick Delaney <rick.delaney@shaw.wave.ca> says...
> Larry Rosler wrote:
 ...
> > If you're not going to sort them, use
> > 
> >   while ($key = each keys %tally) {
> > 
> > so you don't need them all in memory at once.
> 
> Oops, I think you mean
> 
>     while ($key = each %tally) {

Yes.  I said I didn't test it. :-)
 
> but -w will tell you to use something like
> 
>     while ( defined($key = each %tally) ) {
> 
> in case you have 0 or "" for a key.

No.  See how the keys were generated.  They are file names that cannot be 
0 or "".  In any case, '-w' will give no warning here, as there is 
nothing to warn about.  The warning you may have in mind is the 
'persnickety' one from:

       while ($line = <FILE>) {

and even that was only in perl 5.004.  The 'defined' has been hacked into 
this special case to eliminate the warning.  In all other circumstances, 
perl assumes that if you write an assignment in a boolean context, you 
know what you are doing.

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


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

Date: Sat, 19 Sep 1998 02:24:31 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Can you speed up this logfile report???
Message-Id: <3603175A.EFEC9909@shaw.wave.ca>

[posted & mailed]

Larry Rosler wrote:
> 
> [Posted to comp.lang.perl.misc and a copy mailed.]
> 
> In article <3602FFD0.25A69797@shaw.wave.ca> on Sat, 19 Sep 1998 
> 00:43:55 GMT, Rick Delaney <rick.delaney@shaw.wave.ca> says...
> > Larry Rosler wrote:
> ...
> > > If you're not going to sort them, use
> > >
> > >   while ($key = each keys %tally) {
> > >
> > > so you don't need them all in memory at once.
> >
> > Oops, I think you mean
> >
> >     while ($key = each %tally) {
> 
> Yes.  I said I didn't test it. :-)
> 
> > but -w will tell you to use something like
> >
> >     while ( defined($key = each %tally) ) {
> >
> > in case you have 0 or "" for a key.
> 
> No.  See how the keys were generated.  They are file names that cannot 
> be 0 or "". 

True, but -w doesn't know that.

> In any case, '-w' will give no warning here, as there is
> nothing to warn about.  The warning you may have in mind is the
> 'persnickety' one from:
> 
>        while ($line = <FILE>) {
> 
> and even that was only in perl 5.004.  The 'defined' has been hacked 
> into this special case to eliminate the warning.  In all other 
> circumstances, perl assumes that if you write an assignment in a 
> boolean context, you know what you are doing.

I don't have 5.005 yet, so I can't say what happens with it, but it
absolutely gives a warning under 5.004.

I *did* test my code.  :-)

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

%tally = (a => 1, b=> 2, c => 3);
while ($key = each %tally) { print "$key\n" }
__END__
Value of each() operator can be "0"; test with defined() at temp line
65535.
a         
b         
c

Excerpt from perldoc -f each:

    When called in a scalar context, returns the key for only the next
    element in the hash. (Note: Keys may be ``0'' or ``'', which are 
    logically false; you may wish to avoid constructs like 
    while ($k = each %foo) {} for this reason.) 
    ^^^^^^^^^^^^^^^^^^^^^^^^

# perl -v         
         
This is perl, version 5.004_04 built for i386-svr4

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Sat, 19 Sep 1998 01:18:02 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Cookies?
Message-Id: <1dfkk3m.1kymogxytcesqN@bay1-201.quincy.ziplink.net>

Plamen Petkov <plamendp@NOSPAM.techno-link.com> wrote:

> Hidden form fields provide another "secure" like behavior - the user can't
> see the parameters you are passing to your CGI script...

View Source.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 19 Sep 1998 02:18:10 GMT
From: jed@glug.hip.berkeley.edu (Jedediah D. Parsons)
Subject: Data difficulties
Message-Id: <slrn70656d.vu8.jed@glug.hip.berkeley.edu>

Greetings:

I'm trying to write a program that searches for text patterns in a
(potentially large) file, and which also interprets nested instructions
in that file.  The file contains mostly text below ascii 128, and some
instructions, all of which have the sign bit set.  The instructions tell
you things like ``this next string of x bytes contains the title,'' or
``increment line number counter,'' or ``set paragraph counter to y,''
etc.  Most of the instructions occupy the left nibble of a byte, with
the right nibble containing something else (e.g., a value, a further
instruction, nothing, etc.).

I'd be grateful to anyone who could give some advice on one (or all...)
of the following questions:

1) I'm told in the FAQ and in the books that getc() is not a very
efficient way of working.  What's the approved method of going byte by
byte through a file?  (So far, my rather slow version reads the file
into a string, and steps through that string incrementally with substr.)

2) Is this a stupid way to decode byte instructions?  I'm getting the
byte as a string using unpack, and, in lieu of a switch statement, have
opted simply to write a big ol' hash like this:
	%byte_instructions = (
	   "1000000" => sub { ... }, # increment line number
	   "1000001" => sub { ... }, # increment paragraph number
	   ...                       # and so on (there are some 40
	                             # instructions or so)
	)
and executing the appropriate command with
$byte_instructions($byte) -> ();  Does this make sense?  Is working with
the hash slower than a cascade of if/elsif statements?

3) The ultimate purpose of this program is to search for text patterns
in the file, and return the line(s) with the match(es), along with a few
lines before and after *and* the information (text name, chapter,
paragraph, line num, etc.) given with the byte codes.  This is a real
hassle, particularly because the people who formatted these files (HP,
actually) coded in hyphens at line end, stuck line number increment
bytes in the middle of words, etc.  Should I expect to have to deal with
this in two or more passes?  (One in which byte codes are resolved, one
in which intervening garbage is sifted out to facilitate pattern
matching, ...)  There's no way to make a regexp search ignore a set of
characters/bytes, is there?

4) Does any one know of a program out there that I could go to for
inspiration?

Thank you for your patience, because, Damn it, Jim, I'm a Classicist,
not just another Perl hacker!

 - Jed

-- 
Jed Parsons:                                ``Lingua balbus, hebes ingenio
Harpsichordist, Classicist, Homebrewer.        Viris doctis sermonem facio.''
mailto:jed@socrates.berkeley.edu                             -- Archipoeta
http://www.OCF.Berkeley.EDU/~jparsons/


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

Date: Sat, 19 Sep 1998 01:18:04 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Different way or not to use grep here?
Message-Id: <1dfkmac.a9hqueh2fti1N@bay1-201.quincy.ziplink.net>

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

> > @_ = grep(/$key/,@_);
> > foreach (reverse @_) {
> >     ($month, $day, $time, $host, $daemon, $key, $user) = split(/\s+/);
> >     printf "%3s  %2d  %10s     %-10s   \n",$month, $day, $time, $user;
> > } #end foreach loop
> 
>   foreach (reverse @_) {
>      $count++ if /$anon/o; # This is the first loop.  I added 'o' because
>                            # $anon seems to be constant.
>       next unless /$key/;  # This is the 'grep'.  $key is not constant.
>       ($month, $day, $time, $host, $daemon, $key, $user) = split(/\s+/);
>       printf "%3s  %2d  %10s     %-10s   \n",$month, $day, $time, $user;
>   } #end foreach loop

Note that to keep the semantics equivalent to the original program

next unless /$key/;

*should* have a /o on the regex.

In the original program, $key was constant for the duration of the

grep(/$key/, @_).

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Fri, 18 Sep 1998 22:05:53 -0500
From: Sam Wang <samwang@freewwweb.com>
Subject: Re: Display Client info in users browser?
Message-Id: <36031F90.A80698B5@freewwweb.com>

thru the use of the magical hash, %ENV

and yes, it's thru perl. and ie can run javascript (but not real good).

Oddball wrote:

> I just visited a site that displays this on part of the Index Page:
> Some System Stuff !!!
> The local date is :Friday, 18-Sep-98 11:53:04 PDT
> Your IP address is :24.3.XX.XXX
> You are currently being served by :http://XXXXXX.com
> You are using a Mozilla/4.0 (compatible; MSIE 4.0; Windows 95) compatible
> browser
>
> How is this done. I am sure there is some server side cgi/pearl involved.
> Anyone out there can explain it to me. I can't be Javascript beacuse I am
> using IE.
>                                                 Thanks
>
> --
>
> e-mail Virtual-Angst@"nospam"home.net Spam Sucks So Remove the "nospam"
> when e-mailing me.
> Virtual-Angst Home Page http://cc430388-a.srst1.fl.home.com
> The Land Rover Defender 110/130 Pickup Website
> http://members.home.net/virtual-angst/defendersite/
> The Jeep Dakar Website
> http://cc430388-a.srst1.fl.home.com/Dakar/dakar.htm
>



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

Date: Fri, 18 Sep 1998 23:32:31 -0500
From: Bruce Hodo <bruceh@interaccess.com>
To: rse@engelschall.com
Subject: ePerl Error in Here-Document String
Message-Id: <360325CF.479BCECB@interaccess.com>

I am trying to use ePerl. I have the following code in my cgi file at
line 171:

 my $SQL = <<"LOCATION_EOT";

 select
 distinct Location
 from Jamaica
 order by Location

     LOCATION_EOT

I ran the eperl preprocessor with the flags -wc and got an OK on the
syntax. But when I load the page I get the following error page on my
browser:

ERROR:
       Perl parsing error (interpreter rc=2)

       Contents of STDERR channel:
       Can't find string terminator "AREA_EOT" anywhere before EOF at
myfile.cgi line 171.

I must be doing something wrong, but I'm not seeing it. Does anybody
have a clue?
--
                 Bruce Hodo - Webmaster, GetAwayNetwork, Inc.
     ==Providing unique vacation information on the World Wide Web==
       For Villas, Resorts, Hotels, Air/Hotel Packages, Charter Airfares

                              And Now Offering Travel Auctions!
=============== Visit us at http://getawaynet.com ===============




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

Date: Fri, 18 Sep 1998 22:17:29 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: How large is a scalar? and related declaration question. (clarification)
Message-Id: <MPG.106cc40baf91bbc69896ab@news.south-carolina.net>

In article <MPG.106c8aa02fbfd7509897af@nntp.hpl.hp.com> on Fri, 
18 Sep 1998 16:20:34 -0700, Larry Rosler (lr@hpl.hp.com) pounded 
in the following text:
=> [Posted to comp.lang.perl.misc and a copy mailed.]
=> 
=> In article <MPG.106c66b1258087489896a3@news.south-carolina.net> on Fri, 
=> 18 Sep 1998 17:49:31 -0400, Matthew Bafford <dragons@scescape.net> 
=> says...
=> .> In article <36027AA1.3A48@DejahsPrivateIce.com> on Fri, 18 Sep 
=> .> 1998 10:22:11 -0500, Mary E Tyler (dejah@DejahsPrivateIce.com) 
=> .> pounded in the following text:
=> ...
=> .> => $Foo=&FooInt ($This, $That);
=> .> 
=> .> If predeclared, the & is not needed.
=> 
=> The & is not needed.
=> 
=> 

True.  I was thinking of the case when you want to call it 
without any arguments or parentheses.  (And run -w clean :).

Thanks for clearing it up!

--Matthew


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

Date: Sat, 19 Sep 1998 01:40:23 GMT
From: xwang20@hotmail.com
Subject: LWP Treebuilder w/ Form support?
Message-Id: <6tv228$8b9$1@nnrp1.dejanews.com>

As I am playing with LWP, I found that the TreeBuilder.pm does not support
Forms.

1. It does not recognize Form tags
2. It does not recognize Form related URLs

I wonder if others are seeing the same problem and how do they overcome this.

Thanks.

-- xwang

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Sat, 19 Sep 1998 01:18:07 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Need help with a simple program (newbie).
Message-Id: <1dfkto9.19yvumpaa5zonN@bay1-201.quincy.ziplink.net>

[posted and mailed]

Vince <vmp12@csufresno.edu> wrote:

> Attached is my current source code.  I appreciate anyone's help.

You never actually specified what was wrong with your source code or how
it wasn't working...


> #!/usr/bin/perl

You might want to tack -w onto that.

You should consider doing use strict; as well.  It will take some effort
to convert your script to be use strict compatible, but it will most
likely be worth the effort.

>   $jd_test = $jd;
>   ($z,$f)=split('.',$jd_test);

I don't think that's going to do what you want.  Unless, of course, you
want split to return a list of null strings...

The first argument to split is always interpreted as a regex. [1]  In
other words, split '.' is equivalent to split /./, so you're splitting
on every character.

Also, the temporary variable $jd_test serves no useful purpose.

Try this instead:

($z, $f) = split (/\./, $jd);


>   if ($z < 2299161)
>     {
>       $a = $z;
>     }
>   if ($z >= 2299161)
>     {
>       $alpha = int (($z - 1867216.25) / 36524.25);
>       $a = $z + 1 + $alpha - int (alpha / 4);
>     }

else and elsif are your friends.  Since $z cannot be less than 2299161
*and* greater than or equal to 2299161 [2], so you could simply write:

if ($z < 2299161) {
  # do one thing
} else {
  # do another thing
}

>   print "Phase time-----------------\n"; &convert_JD;
>   print "First quarter--------------\n"; &convert_JD;
>   print "Full moon------------------\n"; $convert_JD;
>   print "Last quarter---------------\n"; &convert_JD;

By putting & convert_JD on the same line as the print, it looks like
you're printing the result of &convert_JD.  If that's what you meant to
do, replace the first semi-colon with a comma.  If that's not what you
meant to do, put the &convert_JD on a separate line for clarity.

By the way, -w would have caught that typo in the third line.  use
strict would have, also.

You call &convert_JD four times in a row with no arguments.  What
determines which phase of the moon is being calculated?


You're using far too many global variables.  Did you really mean to
increase the Julian Day by 0.5 *every* time you convert it?

You also use many more temporary variables than you need to.  It makes
the code seem cluttered.

Your code needs comments.  What does each subroutine do?  What are the
arguments to each subroutine?  What is the purpose of each stage in the
algorithm?  These will make the code easier to understand and maintain.

Hope that helps!


[1] Except for the special case of ' ' and " ".

[2] Ignore the next footnote. [3]

[3] If $z were a tied variable, you could have the FETCH method return a
different value each time, so both conditionals could evaluate to true.
Abigail once posted an example of this.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 19 Sep 1998 03:49:33 GMT
From: George Reese <borg@imaginary.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <hRFM1.816$Ge.1893135@ptah.visi.com>

In comp.lang.java.programmer Larry Wall <larry@kiev.wall.org> wrote:
: In article <360026F0.136F6AD@min.net>, John Porter  <jdporter@min.net> wrote:
:>George Reese wrote:
:>> Perl is quite simply no where as OO as python.
:>
:>True; but you think that means Perl is no where near as *good* as a
:>consequence.  But that does not follow, because OO is not the be-all,
:>end-all you seem to think it is.

: Indeed.  This has been a rather entertaining discussion--it keeps
: reminding me of a saying I particularly like:

:     "It is amazing how complete is the delusion that beauty is goodness."
:                                                         -- Leo Tolstoy

It is not beauty that I am arguing is goodness--it is structure that
is goodness.  Certainly not any structure, but structure that enables
one to accomplish any functionality they wish without compromising the
structure of the whole.  Perl does not do that.  Python does.

-- 
George Reese (borg@imaginary.com)       http://www.imaginary.com/~borg
PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
   "Keep Ted Turner and his goddamned Crayolas away from my movie."
			    -Orson Welles


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

Date: Sat, 19 Sep 1998 11:27:42 -0700
From: Steven <koh_cc@pacific.net.sg>
Subject: Please Help
Message-Id: <3603F79E.50BAEB22@pacific.net.sg>

hi,

   Can any help to answer this question.

 I have a website with an Links form on a NT server. I just
 came accross a problem, when a user enters data and then 'submits' it,
an error
 occurs   which states 'http/1.0 501 not  supported'. Can anybody tell
me what this
 means? I'm checking  to see if it might be a server error. thanks in
advance

--


with regards
steven

Tel : 7711303

Have a nice day !!!

Bye




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

Date: Sat, 19 Sep 1998 01:18:14 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: PLESE HELP ME!!!
Message-Id: <1dfkvbu.1tougp814cm90zN@bay1-201.quincy.ziplink.net>

Craig Berry <cberry@cinenet.net> wrote:

>   ($blaa = $INPUT{update}) =~ s!</P>.*!!;
> 
> That is, copy the entire contents of $INPUT{update} to $blaa, then replace
> everything in $blaa from </P> onward with an empty string.

Add an s, in case $INPUT{update} contains a newline.

($blaa = $INPUT{update}) =~ s!</P>.*!!s;

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 19 Sep 1998 01:18:12 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: PLESE HELP ME!!!
Message-Id: <1dfkv67.becbjqmhz9h6N@bay1-201.quincy.ziplink.net>

Matthew Bafford <dragons@scescape.net> wrote:

> => >The code below will return the first 180 chars from $INPUT{'update'},
> => >but i need it to return all chars before this appears: </P>

> $_ = substr $Text, index($Text, "</P>");

Woops, that one doesn't quite work.  I think you meant:

$_ = substr $Text, 0, index($Text, "</P>");

But only if $Text actually contains "</P>".  :-)

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 19 Sep 1998 01:18:17 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Problem with piping...
Message-Id: <1dfkvi7.1bqpbvq9hf01kN@bay1-201.quincy.ziplink.net>

Bryan Pizzillo <sturm@cs.umd.edu> wrote:

>     open(GTARIN,"|gtar xipf -") or die "Could not open gtar for writing\n";

>   Now, the problem is that it has worked ok for every user I have
> done this with, but tonight I hit a user where I got the error of:
> Could not open gtar for writing
> 
>   The person's directory has nothing strange in it.  In fact it is
> perfectly normal.  For some reason though, the gtar cannot open.
                     ^^^^^^^^^^^^^^^^^^^^^^

This reason is probably in $!.  Print it.

open(GTARIN,"|gtar xipf -")
    or die "Could not open gtar for writing: $!\n";


Since you're using pipes, you should also check the return value when
you close the filehandles.  perlfaq8 and perlipc explain why.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 19 Sep 1998 01:27:08 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Process checking
Message-Id: <360309ED.DE13643B@shaw.wave.ca>

[posted & mailed]

Ian Lowe wrote:
> 
> I am fairly new to Perl, and am trying my hand at it by writing a
> program which will report the health of a daemon.  My problem is with
> the test for daemon health.  I am using the grep function, but its use
> seems to preclude the use of ( $? eq 1 ) as a test, since according to
> the Camel book, $? only returns status on backticks, system(), or 
> closed pipes (but not functions).  How then could I test for truth?
> 

By checking the return value of grep.  perldoc -f grep

 ... 
> foreach $proc (@st) {
>     print LOG "Checking process $proc:\t";
>     @greplist = grep { /$proc/ } @ps;
>         if ( $? eq 1 ) {

    if(@greplist = grep { /$proc/ } @ps) {


-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Sat, 19 Sep 1998 00:38:24 -0500
From: Bobn <BobN@interaccess.com>
Subject: Re: Q:ActiveState's win32release missing makemaker - help me
Message-Id: <36034350.519C@interaccess.com>

Josef Seknicka wrote:
> 
> I tried to get the DBI module from the Location, but it seem to me,
> that you have to buy the package Perl Resource Kit -- Win32 Edition
> for downloading this Module, is this correct.

I downloaded their free perlwin32 stuff and was then able to use their
ppm.pl to download other things (Tk-Multi, specifically).  You have to
buy the Resource Kit if you want the GUI package manager vpm.


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

Date: Fri, 18 Sep 1998 16:38:08 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Removing double entries from array
Message-Id: <0sjut6.qr1.ln@metronet.com>

Marc-A. Woog (mwoog@pobox.ch) wrote:

: I am quite new to Perl and I have a "How-to-do-better"-Question:

: I have tons of entries in @url_list, sometimes two or more times the
: same. I want to remove all redundant entries and this is the code I
: came up 'til now:

[snip code]

: Is there a more elegant and efficient (meaning faster) way to do the
: same (this looks more like basic than perl to me)?



Yours is a Frequently Asked Question.

Shame on you for asking it yet again.


Perl FAQ, part 4:

   "How can I extract just the unique elements of an array?"


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


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

Date: Sat, 19 Sep 1998 01:18:20 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Table of Contents Generator
Message-Id: <1dfkw3j.1028cgj1rwgch1N@bay1-201.quincy.ziplink.net>

Moshe Zadka <moshez@math.huji.ac.il> wrote:

> I wrote a small HTML table of contents generator, and I'd be happy
> to get some criticism on it.

Okee dokee!

> For an example of it's output, see
> http://www.ma.huji.ac.il/~moshez/anafazim/
> (Yes, that's something I wrote).

I looked.  There's nothing there that appears to be output from this
program.  In fact, I find it hard to believe that you even tested this
program...

> ----------- Cut Here ----------------
> #!/usr/bin/perl -w
> use strict;

Snaps for -w and use strict!

> my $curr_level=0;
> my $head_text;
> my $now=localtime;
> 
> print <<"EOHTML"
> <HTML>
> <HEAD>
>   <TITLE>Table of Contents</TITLE>
>   <META NAME="GENERATOR" 
>         CONTENT="TOC -- Automatic Table of Contents Generator">
> </HEAD>
> <BODY>
> <H1>Table of Contents</H1>
> EOHTML
> ;
> 
> while(<>) {
>   if(/<H([1-6])>(.*)<\/H\1>/) {

<H1>Uh oh, I'm not
sure this will work</H1>

>     print "<UL>\n" x ($1-$curr_level), "</UL>\n" x ($curr_level-$1);

Ah...  you started a whole bunch of unordered lists, and immediately
ended them all.  Why?

>     $curr_level=$1;
>     ($head_text = $2) =~ s/NAME="/HREF="$ARGV#/;

What is $ARGV supposed to be?  Looks to me like it's undefined.

>     print "<LI>", $head_text, "\n";

You know, you can interpolate variables into double quoted strings...

print "<LI>$head_text\n";

Is this <LI> even inside a list?

>   }
>   if(/<TITLE>(.*)<\/TITLE>/) {

<TITLE>Uh oh, I don't think
this will work either</TITLE>

>     print "</UL>\n" x $curr_level;

Ah...  You just ended a whole bunch of unordered lists that you never
started.  Why?

>     $curr_level=0;
>     print '<H2><A HREF="', $ARGV, '">', $1, '</A></H2>', "\n";

print qq{<H2><A HREF="$ARGV">$1</A></H2>\n};

There's that undefined $ARGV again...

Where exactly is that link supposed to go?

>   }
> }
> print "</UL>\n" x $curr_level;

You just ended a whole bunch more unordered lists that you never
started.  Why?

> print <<"EOHTML"
> <HR>
> Created by TOC, The Automatic Table Of Contents Generator<BR>
> At $now
> </BODY>
> </HTML>
> EOHTML
> ;

Looking at this program, I don't believe its output will you be what you
originally had in mind.

> ----------------- Cut Here --------------------------
> It assumes a header look like <Hn><A NAME="some_name">Some header</A></Hn>
> all on a single line, with n=1,..,6.

But none of my headers look like that...  ;-)

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Fri, 18 Sep 1998 23:16:41 -0500
From: MS <webmaster@hubeicorp.com>
Subject: What does the + in print statement do?
Message-Id: <36033029.2F0B1E6F@hubeicorp.com>

Can anyone tell me the difference in this

open (FILE ,"+>>file.txt");

and this

open (FILE ,">>file.txt");

That + sign is in already in some code I'm modifying -- it works, but

I can't find that + sign mentioned in any of the books I have,
I'm not saying it's not there, just that I can't find it,
and testing on my local system *seems* to produce no difference.

I'm reluctant to test on my server because I just made a file explode*
and I'm told two chances are all I get.

If it's in there and it works, without so much as producing a warning,
it DOES something.

It's what it does that's worrying me :)

Mike

*file explosion -- in case you are fortunate enough to have never
experienced this event, it's what happens when a file increases in
size exponentially until system adminstration is forced to delete it
to keep the whole server from going down :)

This happened from a single character -- much like that + sign.



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

Date: Sat, 19 Sep 1998 05:14:07 GMT
From: Eric Wong <egwong@netcom.com>
Subject: Re: What does the + in print statement do?
Message-Id: <egwongEzIMJJ.Gx6@netcom.com>

MS <webmaster@hubeicorp.com> wrote:
: Can anyone tell me the difference in this
: open (FILE ,"+>>file.txt");
: and this
: open (FILE ,">>file.txt");
[ cut ]

% perldoc -f open

In particular:

            ... You can put a `'+'' in front of
            the `'>'' or `'<'' to indicate that you want both read
            and write access to the file; thus `'+<'' is almost
            always preferred for read/write updates--the `'+>'' mode
            would clobber the file first. You can't usually use
            either read-write mode for updating textfiles, since
            they have variable length records. See the -i switch in
            the perlrun manpage for a better approach.  
 
HTH,
Eric   

[cc'd]


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

Date: Fri, 18 Sep 1998 22:12:29 -0500
From: Sam Wang <samwang@freewwweb.com>
Subject: Re: what good is flock $LOCK_NB?
Message-Id: <3603211D.9EDCF0D@freewwweb.com>

what good is just checking if it's locked or not? sound's kinda useless to me.

Matthew Bafford wrote:

> In article <35FC468D.30859AD@marlin.utmb.edu> on Sun, 13 Sep 1998
> 17:26:21 -0500, Mozilla/4.04 (szhou@marlin.utmb.edu) pounded in
> the following text:
> => correct me if i'm wrong, but when you lock-nb a file handle, then
> => immediately use while($temp = <FILE>) to read the contents line-by-line,
> => is it possible for another process to write to the file at that time,
> => too? but of course this problem would be solved with lock-ex. but what
> => good is lock-nb?
> =>
>
> Hey Mozilla/4.04!  (What a strange name...)
>
> You probably should read the flock documentation again...  All
> LOCK_NB does is check to see if the file is locked.  If LOCK_NB
> is not specified, the function waits until the file is unlocked,
> and then locks it and returns (more or less).
>
> Also, locking is voluntary.  You can have your script lock a
> file, but I can come along and write a program to write to that
> file without checking for a lock, and it will.
>
> Hope This Helps!
>
> --Matthew
>



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

Date: Sat, 19 Sep 1998 05:30:57 GMT
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: what good is flock $LOCK_NB?
Message-Id: <6tvfi3$bgb@flatland.dimensional.com>

Sam Wang <samwang@freewwweb.com> writes:

> what good is just checking if it's locked or not? sound's kinda useless to me.

Suppose you have a program that runs periodically.
Suppose the program needs exclusive access to its data.
Suppose it's okay to skip this run if the last one is still running.

You could handle this situation by using LOCK_EX | LOCK_NB to get the
lock if it's available, or to bail out if the last job is still running
and still has the lock.

This isn't hypothetical: one of my applications behaves exactly as I've
just described.

-- 
Michael Fuhr
http://www.fuhr.net/~mfuhr/


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

Date: Fri, 18 Sep 1998 22:17:25 -0400
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: where is Date::Parse?
Message-Id: <MPG.106cb0691ca252669896a6@news.south-carolina.net>

In article <6tuks6$onr$1@nnrp1.dejanews.com> on Fri, 18 Sep 1998 
21:55:18 GMT, nguyen.van@imvi.bls.com (nguyen.van@imvi.bls.com) 
pounded in the following text:
=> Hi guys,
=> 
=> 
=> I couldn't find Date::Parse. Do you know where it is located?
=> 

CPAN!  For a quick flight to the CPAN near you, just visit:

www.perl.com/CPAN/

Or, if you'd like to control your destination, visit:

www.perl.com/CPAN

It's as easy as that! :)

The addy you happen to want is:

http://www.perl.com/CPAN/modules/by-module/Date/

=> Thanks

Hope This Helps!

=> Van Nguyen

--Matthew


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

Date: 18 Sep 1998 22:12:41 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: where is Date::Parse?
Message-Id: <ylzpbwr8hi.fsf@windlord.stanford.edu>

That was a singularly unuseful set of responses to this question.  Good
grief.  It would be nice if people would try to be a little more helpful
even if something looks like a FAQ.

nguyen van <nguyen.van@imvi.bls.com> writes:

> I couldn't find Date::Parse. Do you know where it is located?

Yes... it's hard to find on CPAN, which is mildly annoying.  I usually end
up spending some time looking for it myself.  The answer is that it's part
of TimeDate (perhaps not the most intuitive place to look).

You can get TimeDate from the URL someone else gave, namely:
  <URL:http://www.perl.com/CPAN/modules/by-module/Date/>

(An aside to the person who recommended Date::Manip -- Date::Parse is
considerably better in my opinion for most applications because it's quite
a bit smaller.  Date::Manip is an incredibly resource hog.)

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 19 Sep 1998 03:14:47 GMT
From: lhunter@acm.org (Larry Hunter)
Subject: Re: Which modules needed for httpd POST FORM ?
Message-Id: <6tv7j7$jic$1@hiram.io.com>

In article 
<ptr4su5v1be.fsf@olkikukka.i-have-a-misconfigured-system-so-shoot-me>, 
jari.aalto@poboxes.com says...
>        I'd like to connect to HTTPD daemon and fill out a form and 
submit
>        it the WWW server. like I would if I used Netscape browser 
>        and filled it by hand.

All you need is in  CGI.pm . It is part of the Perl distribution.
------------------------------------------------------------------------
Larry Hunter         lhunter@acm.org         http://www.io.com/~lhunter/



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

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


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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