[13140] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 550 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 16 01:07:13 1999

Date: Sun, 15 Aug 1999 22:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 15 Aug 1999     Volume: 9 Number: 550

Today's topics:
    Re: Creating hotlinks out of plain URLs in Perl. <sunfox@sunwerx.com>
        dbmopen(), doesn't save , (Vardhan Varma)
    Re: dbmopen(), doesn't save , <rick.delaney@home.com>
    Re: HARASSMENT -- Monthly Autoemail (J. Moreno)
    Re: Help Parsing a line (Abigail)
    Re: Help Parsing a line <uri@sysarch.com>
    Re: Help Parsing a line (William Herrera)
    Re: How to LOCK files with perl on Windows systems? (elephant)
    Re: Need help with search script (Ronald J Kimball)
    Re: New User Q:Tricky multiline Join (Ronald J Kimball)
    Re: Newbie needs help with explicit package name. Using (Ronald J Kimball)
    Re: Newbie question about $_ (Ronald J Kimball)
        Perl data type size (max and min values) (Anno Siegel)
    Re: Problem dynamically loading modules via eval (Abigail)
    Re: problem printing ("html") (elephant)
    Re: problem printing ("html") (Anno Siegel)
    Re: problem printing ("html") (elephant)
    Re: problem printing ("html") <rick.delaney@home.com>
    Re: problem printing ("html") (Anno Siegel)
    Re: regexp question - dealing w/ 2 strings (Abigail)
    Re: right (Abigail)
    Re: Rolling my own Newsreader (Abigail)
    Re: saving a hash (Abigail)
    Re: Why It's Cool To Make Fun Of Bad Code <monty@primenet.com>
    Re: Why It's Cool To Make Fun Of Bad Code <uri@sysarch.com>
    Re: Why use Perl when we've got Python?! <webmaster@chatbase.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Mon, 16 Aug 1999 03:50:13 GMT
From: "Sunfox" <sunfox@sunwerx.com>
Subject: Re: Creating hotlinks out of plain URLs in Perl.
Message-Id: <VTLt3.106061$U42.140154@news1.rdc1.bc.home.com>

Abigail wrote in message ...
>
>You would need to parse the HTML if you want to exclude URL in HREFs.
>(I guess you want to exclude them from <IMG>, <LINK>, <OBJECT> and
> everything else that can contain URLs as well.)
>
>As for a formatted version, no, not really. But here's the code that
>created the regex:


<SNIP>

Thanks for that; allows me to edit it. Unfortunately, I just noticed it only
HREFs the base domain - for instance, in the URL
http://www.microsoft.com/windows/index.html only http://www.microsoft.com/
would be a link, completely ignoring windows/index.html. Any ideas? Has no
one ever really encountered this problem before? :-P

- Sunfox




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

Date: 16 Aug 1999 03:11:34 GMT
From: Vardhan Varma@basant.cadence.com (Vardhan Varma)
Subject: dbmopen(), doesn't save ,
Message-Id: <a@bc>


My following snippet doesn't save ( the files .pag and .dir are of size zero )
while i am setting the 'StartTime' of the hash ......
Do i need to to anything special to 'save' ???

=======================================================================
my $dir = "$ENV{HOME}/.projects";

mkdir $dir,0770 unless ( -d $dir);

my $debug = 1;

##-----------------------------------------------------------------
## return $db, %ref
sub proj_open ($)
{
    my ($pro ) = @_;
    my (%ref);

   return [dbmopen ( %ref, "$dir/$pro", 0666 ),%ref];
}

sub proj_close ($%)
{
    my ($db,%ref) = @_;
    dbmclose %ref;
}
sub proj_start($) 
{
    my($proj) = @_;
    my ($p,%p) = proj_open($proj);
	my $starttime;

	$starttime = $p{'StartTime'};
	if ( !$starttime ) { # Not already working !!
		$p{'StartTime'} = time;
	}
    proj_close($p,%p);
}


proj_start "XYZ";
-- 
(defvar VardhanVarma '( ( mailto:vardhan phoneto:4123 webto:basant:8080 ))
  ( mailto:vardhan@bitsmart.com phoneto:+91-118-562842x4123 
    webto:members.tripod.com/~vardhan ) "A variable" )



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

Date: Mon, 16 Aug 1999 04:19:58 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: dbmopen(), doesn't save ,
Message-Id: <37B79144.518BEE4E@home.com>

[posted & mailed]

Vardhan Varma wrote:
> 
> sub proj_open ($)
> {
>     my ($pro ) = @_;
>     my (%ref);
> 
>    return [dbmopen ( %ref, "$dir/$pro", 0666 ),%ref];
> }
[snip]
>     my ($p,%p) = proj_open($proj);

You are only returning one scalar from proj_open, not a scalar and a
hash.  That scalar, 

    [dbmopen ( %ref, "$dir/$pro", 0666 ),%ref];

is a reference to an anonymous array that contains the result of
dbmopen, followed by all the key-value pairs of %ref.  I'm not sure if
%ref will be full in this bizarre expression or not, but regardless,
it's not what you want.

You should return a reference to a hash from a sub, especially when it
might contain millions of entries.

sub proj_open {
    #...
    dbmopen ( %ref, "$dir/$pro", 0666 )
        or die "dbmopen fail: $!";
    return \%ref;
}

my $hashref = proj_open($proj);

perldoc perlsub
perldoc perldata
perldoc perlref

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Mon, 16 Aug 1999 00:57:49 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <1dwlszo.1szg6le1mt7mo0N@roxboro0-0020.dyn.interpath.net>

Curly++ <nobody@wants.spam> wrote:

>  o  No software has been written that wraps properly.
>   I use both OE5 and NN4.61 and the autowrap in both is
>   badly flawed and unuseable.  I also use 3 other
>   newsreaders on occassion and they don't have autowrap.
>   I regularly use 7 different operating systems and
>   often have to work on 80 collumn screens.  Telling
>   everyone that things are better "on ng's where people
>   use more modern apps" is about like saying that things
>   would be better if we didn't allow foriegners in here.

This is in fact NOT the case -- Eudora's use of format=flowed works
quite well if you want the text to be both adjustable and appear good to
those using a 80 column display. It even works well with quoted
material.

And there are a bunch of newsreaders that will automatically softwrap in
the COMPOSITION window based upon the line length, so that the line
breaking that the user see's will match the line breaking that will be
sent.

By saying this you are spreading the myth that there isn't a better way
to handle text.  There is, it's just not currently being used by OE.

-- 
John Moreno


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

Date: 15 Aug 1999 22:05:29 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Help Parsing a line
Message-Id: <slrn7rf01n.8e5.abigail@alexandra.delanet.com>

akhtara@erols.com (akhtara@erols.com) wrote on MMCLXXVI September
MCMXCIII in <URL:news:7p7s3p$7kg$1@nnrp1.deja.com>:
 .. 
 .. I am trying to parse the following lines and need to save the  two name
 .. fields.  I am using Perl5.  Any ideas or suggestion would be helpful.
 .. 
 .. J.Jackson     (10) (20) 32    A.Sample  (10) (30) (14) 42WR
 .. A.Aaron       (25) 54WL       J.Jones   (46) 42WR
 .. 
 .. The problem is that the number of fields are not always the same between
 .. the two names.  I only need to extract and save the two names.  The
 .. second name always starts at column 40.


Assuming there are no spaces in the name fields:

    $first_name  =         $str      =~ /(\S+)/;
    $second_name = substr ($str, 40) =~ /(\S+)/;



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 15 Aug 1999 23:25:06 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Help Parsing a line
Message-Id: <x7n1vs2yr1.fsf@home.sysarch.com>

>>>>> "A" == Abigail  <abigail@delanet.com> writes:

  A> .. J.Jackson     (10) (20) 32    A.Sample  (10) (30) (14) 42WR
  A> .. A.Aaron       (25) 54WL       J.Jones   (46) 42WR

  A> Assuming there are no spaces in the name fields:

  A> $first_name  =         $str      =~ /(\S+)/;
  A> $second_name = substr ($str, 40) =~ /(\S+)/;

ma'am will you please pull over and show me your perl license? i saw you
swerving around the regex road and i think you are intoxicated. you will
have to take a perl test from one of those stupid on line certification
sites before i let you code in perl anymore.  if you insist on posting
untested code again, i will have to suspend your perl license for 6
months.

the problem you see, is you forgot to use list assignments in those
lines of code. so the two variables now contain the boolean value of
whether the match succeeded. knowing you have a modicum of perl
experience, i have to assume you are under the influence of some form of
mind altering chemicals. we can help you get into a detox center where
you will play with snake and coffee flavored languages until you wake up
in a cold sweat and be grateful that perl exists in the world. we don't
like people whose abuse our language this way.

the perl police.

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Mon, 16 Aug 1999 03:24:27 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: Help Parsing a line
Message-Id: <37b77c5b.43474296@news.rmi.net>

On Mon, 16 Aug 1999 02:13:19 GMT, akhtara@erols.com wrote:

>J.Jackson     (10) (20) 32    A.Sample  (10) (30) (14) 42WR
>A.Aaron       (25) 54WL       J.Jones   (46) 42WR
>
>The problem is that the number of fields are not always the same between
>the two names.  I only need to extract and save the two names.  The
>second name always starts at column 40.

The line above have the second name at line 30? Anyhow: look out for wordwrap
below. Read up on substr, though unpack is the other way.

====================

my(@lines, $name1, $name2, $s, $t);

push @lines, "J.Jackson     (10) (20) 32              A.Sample  (10) (30) (14)
42WR";
push @lines, "A.Aaron       (25) 54WL                 J.Jones   (46) 42WR";

foreach $s (@lines) {
  $t = substr($s, 0, 39);  
  ($name1, undef) = split /[^\sa-zA-Z\.]/, $t, 2;
  $t = substr($s, 39);
  ($name2, undef) = split /[^\sa-zA-Z\.]/, $t, 2;
  print("Name 1 is ", $name1, " and name 2 is ", $name2, "\n");
}


---
The above from: address is spamblocked. Use wherrera (at) lynxview (dot) com for the reply address.


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

Date: Mon, 16 Aug 1999 13:15:16 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: How to LOCK files with perl on Windows systems?
Message-Id: <MPG.12222d4b9f82eac4989c2b@news-server>

dunrobin52@hotmail.com writes ..
>On Sun, 1 Aug 1999 12:27:45 +1000, e-lephant@b-igpond.com (elephant)
>wrote:
>
>>Alexander Rühl writes ..
>>>I tested it under Win98 - but there isn't a 'flock'. It should run on a
>>>WinNT webserver later - is there a 'flock' or something similar?
>>>How can I realize the file locking on Windows based systems?
>>
>>assuming that you're using the ActiveState port of perl .. then all the 
>>information on flock's usage in Win9x and WinNT is provided for you in 
>>the FAQ
>>
>>  perlwin32faq5.html (Quirks)
>
>...where you'll discover that flock doesn't work on Win9x. End of
>story.

it's not enough that you respond to something that's a fortnight old in 
a newsgroup that receives over a thousand posts a week .. you also 
ignore the original poster's information that eventually the script will 
be run on a WindowsNT machine .. a fact which makes this not quite the 
end of the story

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sun, 15 Aug 1999 23:38:30 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Need help with search script
Message-Id: <1dwlp0z.1b42cos156qeioN@p133.tc1.state.ma.tiac.com>

Floyd Morrissette <Webdesigner@NewWebSite.com> wrote:

> In article <37b6da8b.0@news.advancenet.net>,
>   "twentyfour seven" <jeff@247sk8mag.com> wrote:
> 
> > $link .= qq(<a
> > href="search.pl?Q=$FORM{'Q'}&E=$FORM{'E'}&X=$FORM{'X'}&S=$next">Next
> > &gt;&gt;</a>\n) if ($next);
> >
> One thing that might help is to escape the & with a backslash. When perl
> sees the & it is probably looking for a subroutine. I don't know if that
> is it or not, but nobody else has tried.
> 

Not in a double-quotish string.  Posting untested guesses generally is
not very helpful.  :(

The problem is not the creation of the link, but the parsing of the
data, wherein plus signs are presumably being converted to spaces.  The
original poster needs to convert those spaces back to pluses where
appropriate.

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 15 Aug 1999 23:38:32 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: New User Q:Tricky multiline Join
Message-Id: <1dwlpa5.5o4llm1pbp4c0N@p133.tc1.state.ma.tiac.com>

Kevin Newman <knewman@mcs.com> wrote:

> How can I  join multilple lines with one line repeated?  This may be
> better explained in an example.   The pattern is as follows:
> 
> 123 string string string
> Keyword  -> 162 string string string
> 
> 124  string string string
>   Keyword -> 163  string string string
> <whitespace> 164  string string string
> <whitespace> 165 string string string
> 
> The pattern I would like to end up with is
> 
> 123 string string string  Keyword  -> 162 string string string
> 
> 124  string string string Keyword -> 163  string string string
> 124  string string string Keyword -> 164  string string string
> 124  string string string Keyword ->  165  string string string
> 

OWTDI:


#!perl

$/ = '';

while (<>) {
  chomp;
  ($pre, @lines) = split /\n/;
  for (@lines) {
    s/^\s*(?:Keyword\s+->\s+)?//;
    print "$pre Keyword -> $_\n";
  }
  print "\n";
}
__END__
123 string string string
Keyword  -> 162 string string string

124  string string string
  Keyword -> 163  string string string
             164  string string string
             165  string string string


-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 15 Aug 1999 23:38:33 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Newbie needs help with explicit package name. Using "strict"
Message-Id: <1dwlpkd.1yc96hn1v12dcvN@p133.tc1.state.ma.tiac.com>

Joe L <shtml@usa.net> wrote:

> I have written several scripts before now but I
> "discovered" the module strict about a week
> ago.
>  Now, needless to say I have about 5 million of
> these errors: "$output_data" requires explicit
> package name at ./myscript.pl." Of course each
> error uses a different named variable.
> Although my scripts run when I don't use strict, I
> would like to learn the correct way. I have
> spent several hours reading the FAQs and other
> docs on the subject. If I declare or define a
> variable with "my" or "local" the error from
> strict goes away. The way I understand to declare
> or define a variable is to do it just before I am
> going to use it. Is this correct? Does it seem to
> you that I have a fair understanding of declaring
> and defining variables? Just using my or local
> "seems too easy" to me. Is it that easy? Am I
> trying to make this too hard? I don't mean to
> waste anyone's time on this, it's just that it
> seems very important and I just can't get it
> though my thick head! Thanks for any and all help.

local() does not work for avoiding the 'use strict' error message.  You
need to do one of three things for each variable:


1. Include an explicit package name.
   $main::var;

2. Declare the variable as a lexical.
   my $var;

3. Declare the variable as a global.
   use vars qw($var);


(1) is useful for referring to a variable in another package.

(2) is for lexical variables - variables which are scoped to the lexical
block in which they appear.  Appropriate for variables in subroutines,
and for variables which should not be accessible outside the source
file.

(3) is for global variables - variables which may be referred to from
any scope or package.  For example, if you're using Exporter, @EXPORT
should be declared with 'use vars', so the Exporter module can access
it.

(2) and (3) are probably more commonly used than (1).


HTH!


-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 15 Aug 1999 23:38:34 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Newbie question about $_
Message-Id: <1dwlpts.4hbiudgodz6wN@p133.tc1.state.ma.tiac.com>

Elaine -HFB- Ashton <elaine@chaos.wustl.edu> wrote:

> Ronald J Kimball wrote:
> > >   A> Danger, Will Robinson, danger! Exterminate! Exterminate! Exterminate!
> > >
> > > lost in space; nomad the son of kirk space probe;
      ^^^^^^^^^^^^^

> > No, the Daleks in Dr. Who.
> 
> Don't forget Robby the Robot from Lost in Space. Unless the Daleks made
> a guest appearance to rid the show of Dr. Smith. :)

Uri already took care of that answer.


> > >   A> Fear is the path to the dark side. Fear leads to anger. Anger
> > >   A> leads to hate. Hate leads to suffering. I sense much fear in you.
> > 
> > SW: The Phantom Menace.
> 
> Close...but it was The Empire Strikes Back...Yoda speaking to Luke in
> the hut. 

Yoda says the same things in every movie.  :)  I remember the above
quote from the trailer to TPM, however.

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 16 Aug 1999 04:25:36 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Perl data type size (max and min values)
Message-Id: <7p83s0$ut$1@lublin.zrz.tu-berlin.de>

Steve  <steve@nomail.com> wrote in comp.lang.perl.misc:
>Hi all, got a pretty simple Perl question here.
>
>How can I determine the maximum and minimum value of a scalar value?

I'll assume you mean a numeric value.  Perl uses the native number
format(s) of your machine, switching from integer to float as
needed.  So there really is no pat answer to your question.  You'll
have to resort to the documentation of your system.

>Or, what is the size of a scalar.  I can’t seem to find this information
>in Larry Wall’s Programming Perl or the online perl.com documentation.

A Perl scalar is a rather complex data structure, containing all sorts
of info besides just the string (or number, or reference) that is
accessible to you.  Again, it's size depends on the native number
format of your machine, as well as (probably, I'm not looking it
up in the source) if the value was ever used as a string and other
factors.  Again the answer is, it depends.

Anno


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

Date: 15 Aug 1999 22:37:38 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Problem dynamically loading modules via eval
Message-Id: <slrn7rf1u1.8e5.abigail@alexandra.delanet.com>

Bruce Pennypacker (brucep@msn.com) wrote on MMCLXIX September MCMXCIII in
<URL:news:OHgsAEr4#GA.240@cpmsnbbsa02>:
\\ 
\\ Here's an example of what I'm doing:
\\ 
\\ In my main program:
\\ 
\\ sub loadmodule {
\\ my $self = @_;
\\ $self->{test} = "this is a test";
\\ print "self = $self\n";
\\ my $parserobject;
\\ my $module = "ps::ParseDSV";
\\ my $command = << CodeToEval;
\\ use $module;
\\ \$parserobject = new $module('$self');
\\ CodeToEval
\\ eval ($command);
\\ }

That's pretty horrible. No wonder Python enforces indentation.
Did you actually try running this code? It looks to be that Perl
will complain about "$self->{test}", as $self is a number (probably 1).
And why the hell are you using an eval? Without checking $@?

    sub loadmodule {
        require ps::ParseDSV;
        ps::ParseDSV -> import;  # Only needed if you are exporting.
        ps::ParseDSV -> new (shift);
    }



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Mon, 16 Aug 1999 13:31:17 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: problem printing ("html")
Message-Id: <MPG.1222310d773f0e3d989c2c@news-server>

Rick Delaney writes ..
>elephant wrote:
>> strange .. I didn't read anything in the poster's original that said
>> that it was working on the commandline
>
>Neither did I.

then I'm left wondering why you directed the poster to a perlfaq which 
assumes that the script does work on the commandline

"My CGI script runs from the command line but not the browser. (500
Server Error)"

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 16 Aug 1999 03:37:46 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: problem printing ("html")
Message-Id: <7p812a$ri$1@lublin.zrz.tu-berlin.de>

elephant <elephant@squirrelgroup.com> wrote in comp.lang.perl.misc:
>Rick Delaney writes ..
>>elephant wrote:
>>> strange .. I didn't read anything in the poster's original that said
>>> that it was working on the commandline
>>
>>Neither did I.
>
>then I'm left wondering why you directed the poster to a perlfaq which 
>assumes that the script does work on the commandline
>
>"My CGI script runs from the command line but not the browser. (500
>Server Error)"

Because it might alert the poster to the useful notion that a script
should first be tested from the command line?

Anno


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

Date: Mon, 16 Aug 1999 14:04:35 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: problem printing ("html")
Message-Id: <MPG.122238d93f90b0ab989c2d@news-server>

Anno Siegel writes ..
>elephant <elephant@squirrelgroup.com> wrote in comp.lang.perl.misc:
>>Rick Delaney writes ..
>>>elephant wrote:
>>>> strange .. I didn't read anything in the poster's original that said
>>>> that it was working on the commandline
>>>
>>>Neither did I.
>>
>>then I'm left wondering why you directed the poster to a perlfaq which 
>>assumes that the script does work on the commandline
>>
>>"My CGI script runs from the command line but not the browser. (500
>>Server Error)"
>
>Because it might alert the poster to the useful notion that a script
>should first be tested from the command line?

now you're just guessing .. it doesn't mention anything about "testing 
your script on the commandline first" in that FAQ .. if that was indeed 
Rick's intention then he perhaps should have just said "test your script 
on the commandline"

what that FAQ is about is the specific situation where a perl script 
works on the commandline .. but NOT via a web server .. this is an 
important distinction because it draws a fairly clear line between a 
Perl problem and a non-Perl problem

this distinction is useless (as is a direction to that FAQ answer) if 
the script does not work on the commandline because then the problem is 
quite likely to be a Perl problem .. and little will be gained by 
reading CGI documentation

in this case .. assuming that the originator posted the actual code .. 
the problem appears to be a broken shebang line (a relative path was 
used) which will mean that the code will not work on the commandline

so - with that in mind - directing the originator to a Perl FAQ that 
contains references to CGI/Web/HTTP FAQs and states that if your 
question was not answered by one of those FAQs then you should post to 
comp.infosystems.www.authoring.cgi would seem less than worthwhile 
advice

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Mon, 16 Aug 1999 04:37:39 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: problem printing ("html")
Message-Id: <37B7956E.C39C1F01@home.com>

[posted & mailed]

elephant wrote:
> 
> Anno Siegel writes ..
> >elephant <elephant@squirrelgroup.com> wrote in comp.lang.perl.misc:
> >>
> >>then I'm left wondering why you directed the poster to a perlfaq which
> >>assumes that the script does work on the commandline
> >>
> >>"My CGI script runs from the command line but not the browser. (500
> >>Server Error)"
> >
> >Because it might alert the poster to the useful notion that a script
> >should first be tested from the command line?
> 
> now you're just guessing .. it doesn't mention anything about "testing
> your script on the commandline first" in that FAQ .. if that was indeed
> Rick's intention then he perhaps should have just said "test your script
> on the commandline"

Close guess, though.

I have no way of knowing whether he tested from the command line or not,
since he didn't say.  So I won't tell him, "test your script on the
commandline".

I directed him to that FAQ because:

1) if he has tested from the command line and it works from there
   then it is relevant.

2) if he has tested from the command line and it doesn't work, then 
   I'd expect he'd have mentioned the error messages he got.

If he hasn't tested it from the command line, the implication to do so
is obvious.  Then he's back to either 1 or 2 and he knows what to do.

Plus I just thought someone new to Perl who wants to use it with CGI
might get some use out of the info in that FAQ.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 16 Aug 1999 04:55:54 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: problem printing ("html")
Message-Id: <7p85kq$108$1@lublin.zrz.tu-berlin.de>

elephant <elephant@squirrelgroup.com> wrote in comp.lang.perl.misc:
>Anno Siegel writes ..
>>elephant <elephant@squirrelgroup.com> wrote in comp.lang.perl.misc:
>>>Rick Delaney writes ..
>>>>elephant wrote:
>>>>> strange .. I didn't read anything in the poster's original that said
>>>>> that it was working on the commandline
>>>>
>>>>Neither did I.
>>>
>>>then I'm left wondering why you directed the poster to a perlfaq which 
>>>assumes that the script does work on the commandline
>>>
>>>"My CGI script runs from the command line but not the browser. (500
>>>Server Error)"
>>
>>Because it might alert the poster to the useful notion that a script
>>should first be tested from the command line?
>
>now you're just guessing .. it doesn't mention anything about "testing 
>your script on the commandline first" in that FAQ .. if that was indeed 
>Rick's intention then he perhaps should have just said "test your script 
>on the commandline"

If you mean I'm just guessing what Rick intended with his reply you
are correct, PSI::MindReading on the fritz and all that.  Otherwise,
I'm well aware what the answer to the FAQ says, and it's irrelevant
as to why I consider Rick's reply useful:  The mere fact that "My
CGI script runs from the command line but not the browser" is a
frequently encountered situation implies that it is easier to make
a script work from the command line, and that there are additional
factors involved to make it run on the server as intended.

If I were in the original poster's situation, my first thought would
have been, hey, does my script even work from the command line?
Which would have put me on the right track.

[rest snipped]

Anno


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

Date: 15 Aug 1999 22:49:22 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: regexp question - dealing w/ 2 strings
Message-Id: <slrn7rf2k1.8e5.abigail@alexandra.delanet.com>

Jennifer Bond (jbond@ilux.com) wrote on MMCLXXIII September MCMXCIII in
<URL:news:7ovvqk$45t$1@nnrp1.deja.com>:
() 
() I have 2 strings, say "ABC" and "EFG".  Is there any way I can have ONE
() regexp to match a line that has "ABC" but not "EFG" somewhere
() after "ABC"?


    /ABC(?!.*EFG)/


Abigail
-- 
perl -wlpe '}{$_=$.' file  # Count the number of lines.


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 15 Aug 1999 22:50:46 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: right
Message-Id: <slrn7rf2ml.8e5.abigail@alexandra.delanet.com>

Malcolm Ray (M.Ray@ulcc.ac.uk) wrote on MMCLXXV September MCMXCIII in
<URL:news:slrn7rd59p.kg2.M.Ray@carlova.ulcc.ac.uk>:
() On 15 Aug 1999 09:52:40 GMT, Gabriele Gallacci <info@gallacci.com> wrote:
() >thx, I think $ENV is sufficient for me, since I'm on a LAN
() 
() Maybe something's wrong with your newsreader: your article didn't contain
() a References: header, so it's not a followup to anything.  It'll mystify
() a lot of readers...


Including me. What is $ENV, and what has being on a LAN to do with it?



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 15 Aug 1999 22:55:46 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Rolling my own Newsreader
Message-Id: <slrn7rf300.8e5.abigail@alexandra.delanet.com>

Kirk Is (kisrael@andante.cs.tufts.edu) wrote on MMCLXXV September
MCMXCIII in <URL:news:7p7i2n$rju$1@news3.tufts.edu>:
^^ I'm wanting to roll my own newsreader, masochist that I am.
^^ At first, I want to make it as a supplement to tin: I want a program that
^^ I can easily see a list of all newgroups I'm subscribed to with a count of
^^ how many unread articles are there in threads I've been involved in. (I'm
^^ relying on subject lines, not threading proper, at least to start with.)
^^ 
^^ Two questions: 
^^ Is there a "trivial" way of parsing .newsrc file lines?  It records
^^ unread article #s in a descriptive format: 
^^ e.g. 1-103,105-110,112,115-200 , etc.
^^ I assume I want to map this to an array.  I know enough perl to do this
^^ using a counter, splitting on commas, and then using for loops and what
^^ not, but I was wondering there was an easier way of initializing the
^^ arrays than this. (And also, dumping the array back to this format.)

I've this module that I use to keep track of article numbers:


package Segments;

use overload '""' => \&stringify;


sub new {
    my $proto =   shift;
    my $class =   ref $proto || $proto;

    bless []  => $class;
}


sub insert {
    my $self = shift;
    my ($from, $to) = @_;
    $to = $from unless defined $to;

    my $i = 0;
    foreach (; $i < @$self; $i ++) {
        if ($self -> [$i] -> [1] + 1 == $from) {
            $from = $self -> [$i] -> [0];
            last;
        }
        last unless $self -> [$i] -> [1] < $from;
    }

    # Case 1, insert at the end.
    if ($i == @$self) {
        push @$self => [$from, $to];
        return;
    }

    # Case 2, $from lies in a segment.
    # Possibly extend segment.
    elsif ($self -> [$i] -> [0] <= $from) {
        if ($self -> [$i] -> [1] >= $to) {return;}
        $self -> [$i] -> [1] = $to;
    }

    # Case 3, $from lies between segments.
    # Insert new segment.
    else {
        splice @$self, $i, 0, [$from, $to];
    }

    # Now, we might need to do some deleting of segments.
    my $j = $i + 1;
    foreach (; $j < @$self; $j ++) {
        last if $self -> [$j] -> [0] > $to + 1;
        $to = $self -> [$j] -> [1] if $self -> [$j] -> [1] > $to;
    }

    splice @$self, $i, $j - $i, [$from, $to];
}


sub stringify {
    my $self = shift;

    join "," => map {$_ -> [0] == $_ -> [1] ? $_ -> [0]
                                            : join "-" => @$_} @$self;
}


"End of package Segments";

__END__



Abigail
-- 
perl -wlpe '}$_=$.;{' file  # Count the number of lines.


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 15 Aug 1999 22:57:28 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: saving a hash
Message-Id: <slrn7rf337.8e5.abigail@alexandra.delanet.com>

Marshall Dudley (mdudley@execonn.com) wrote on MMCLXXIII September
MCMXCIII in <URL:news:37B446B2.136F5A10@execonn.com>:
## 
## Does anyone know how I can read and write a hash from the hard drive so
## I don't encounter the overhead of having to recreate the hash on each
## invocation?


dbmfiles, which have come with Perl for eons now.



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 16 Aug 1999 04:32:33 GMT
From: Jim Monty <monty@primenet.com>
Subject: Re: Why It's Cool To Make Fun Of Bad Code
Message-Id: <7p8491$oc2$1@nnrp02.primenet.com>

Chris <chrisl@tourneyland.com> wrote:
>
> [snip]
>
> What's all that mean? Well, for starters, is was extremely helpful for
> me for someone to speak out against the bad code. (That also took some
> gumption, since the guy must have known he'd get slammed). Also, I
> think it's not really too keen that such crappy code got out there in
> the first place. When a guy goes to the trouble of Copyrighting his
> code etc, and posturing his code as some sort of polished solution,
> the least he can do is look it over. More people would understand this
> if we had any sort of artisan or craftsman ethic left (if this were
> the Middle Ages, some guys form the Guild would get together and get
> medival on the coder's ass), but of course all that stuff is as dead
> as the Plague.
>
> If you read code that sucks, CALL IT OUT!
> And if you WRITE code that sucks, DON'T RELEASE IT!
>
> Bitch all you want.
> Nuff said. 

Ever used Text::Wrap? It's part of the standard Perl distribution.
Both the Perl FAQ and the Perl Cookbook tell you to use it to
reformat text. Every inquiry to comp.lang.perl.m(?:isc|oderated)
that has anything to do with formatting text is responded to with
the instruction to use Text::Wrap. It's the first and only Perl
module I've used (besides strict) and my miserable experience with
it is almost enough to make me go back to programming entirely in
awk. What a piece of crap this module is! A bunch of gurus will
rush to its defense and explain to me why I'm such an idiot, but
who cares? The module is still garbage.

To make a long story short, I used it to wrap individual long lines
within OCR text, and it silently and spuriously turned spaces into
tabs. There were no tabs in the input text, nor should there have
been any tabs in the OCR text that I delivered to the client. But
there were, thanks to Text::Wrap. It also dies when a word is longer
than the line to be wrapped. (At least my version does, and my
version is NOT older than the ubiquitous advice to use Text::Wrap.)
I read the scant documentation and it did NOT say, "By the way,
this module will introduce thousands of tabs into your nice, clean
text."

Do not use Text::Wrap. Do not recommend to others that they use
Text::Wrap. Do not post a FAQ list telling people to use Text::Wrap.
Do not publish books stating that Text::Wrap is what you should
use to reformat text. Do not include harmful, broken modules with
the standard Perl distribution. Do not yell at Perl novices because
they only know the "middle two-thirds" of Perl and so cannot use
Perl for even the most trivial tasks because the "official" answer
to EVERY TBQQNZA "How do I..." question they might ask (but should
NOT ask because the answer is the FAQ) involves parts of the language
that aren't even touched upon in _Learning Perl_, like modules and
object-oriented programming and a bunch of other things I don't
have time to master before I need to wrap a simple line of text!
And fix Text::Wrap!

Whew! I feel better now.

-- 
Jim Monty
monty@primenet.com
Tempe, Arizona USA


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

Date: 16 Aug 1999 00:54:51 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Why It's Cool To Make Fun Of Bad Code
Message-Id: <x7g11k2ulg.fsf@home.sysarch.com>

>>>>> "JM" == Jim Monty <monty@primenet.com> writes:

  JM> To make a long story short, I used it to wrap individual long lines
  JM> within OCR text, and it silently and spuriously turned spaces into
  JM> tabs. There were no tabs in the input text, nor should there have
  JM> been any tabs in the OCR text that I delivered to the client. But
  JM> there were, thanks to Text::Wrap. It also dies when a word is longer
  JM> than the line to be wrapped. (At least my version does, and my
  JM> version is NOT older than the ubiquitous advice to use Text::Wrap.)
  JM> I read the scant documentation and it did NOT say, "By the way,
  JM> this module will introduce thousands of tabs into your nice, clean
  JM> text."

i have never used Text::Wrap but i can understand your frustration. a
quick glance at the code of the latest version shows that the die on
long word problem is fixed (it can be enabled/disabled). and the tabs
stuff is caused by the use of Text::Tabs(expand,unexpand). if your first
2 arguments to Text::Wrap (initial_tab, subsequent_tab) are '', you
should not get any tabs in your output. the code expands the tabs so it
can get the line length and then it unexpands them (possibly inserting
tabs) regardless of whether there were actual tabs in the those
args. this is not good fr you and i would write the authors and tell
them so. it would be easy to skip the actual unexpand if there wer no
tabs in the args.

  JM> Whew! I feel better now.

good. now provide a patch to Text::Wrap to make it work better for
yourself and the rest of us.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Sun, 15 Aug 1999 21:09:36 -0700
From: TRG Software: Tim Greer <webmaster@chatbase.com>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <37B78F00.A7F3D1A8@chatbase.com>

John Stevens wrote:
> 
> On 13 Aug 1999 14:26:17 -0700, Tom Christiansen <tchrist@mox.perl.com> wrote:
> >     [courtesy cc of this posting mailed to cited author]
> >
> >In comp.lang.perl.misc,
> >    "John W. Stevens" <jstevens@basho.fc.hp.com> writes:
> >:Due to this feature alone, Python programs are easier to read by
> >:non-authors than Perl programs are.
> >
> >Prove that.  Stop asserting it.  Prove it.
> 
> No matter what I post, you will not accept it as proof.  If you
> really are interested in proof, perform your own investigation.
> 
> Of course, if I am wrong, simply tell me what you will accept as
> proof.
> 
> >Here's your challenge.  Pick a Perl programmer with experience equivalent
> >to mine,
> 
> Now, just how many Perl programmers have your level of experience?
> 
> How much does it cost to become as good as you?
> 
> Can these people do other things, and still stay good at Perl?
> 
> >I say this for certain because I *do* read their code, and it's completely
> >easy to do so.
> 
> Yes?  There is a sig:
> 
> #!/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
> 
> So, tell me, in thirty seconds or less, and without refering to a
> reference manual, what this does?  If you
> wrote this, or have ever seen it before, this test is invalid.
> 
> You, of course, may well complain that this test is invalid or
> unfair because *YOU* would never write code like this.  But if
> you have problems with this, then why allow it?  If you have
> problems with this, everybody else will, too.
> 
> >If you're talking about someone who can't stop treating Perl like
> >BASIC or FORTRAN, and just doesn't `get' it, then sure, it's unnatural.
> >But that's hardly my fault that they don't know Perl, now is it?
> 
> It is indeed partially the fault of the author, if a programming
> language does not enforce at least a minimal set of good programming
> practices.
> 
> John S.

I think the last idiot that was here trying to make a point of how
difficult Perl is to understand, used a lot of the same justifications
as you, which failed for him as well, and he even used Russ Allbery's
sig as an example. No one's going to have to maintain code such as that,
no one would write that, not just Tom.

Why do you think it costs a lot to be as good as Tom? He's smart, you
can't buy that, either you are or you are not. He probably actually
spent some time learning how things work, rather then whining about how
things don't work, especially where it's a case of being his own victim
because he didn't bother to learn how it works. :-)

I can tell you (not in 30 seconds or less, but close enough) I
deciphered that code in his .sig when the last user brought it up as an
issue (Which only prints what you're looking at, btw), which was just as
ridiculous as the issues you bring up... You aren't him again under a
different name, are you? Further, I don't have any books near me and in
fact, I don't use books when I code or _try_ and "figure it out",
because most Perl programmers already know, hence; a "Perl programmer".
I have bought books, but more so to support Perl and just read them for
enjoyment, rather then a desperate need to try and find out how a
program's working because I didn't bother to study the language. Why did
you feel the need to resort to such ridiculous examples? "Partially the
fault of the programmer"? Are you high?
-- 
Regards,
Tim Greer   : webmaster@chatbase.com  | software@linkworm.com
The ChatBase: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software: http://www.linkworm.com | CGI scripts in Perl/C, & more.
Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
Freelance Programming & Consulting, Musician, Martial Arts, +Sciences.


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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


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