[9566] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3160 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 15 02:08:40 1998

Date: Tue, 14 Jul 98 23:00:35 -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           Tue, 14 Jul 1998     Volume: 8 Number: 3160

Today's topics:
        authentification problem (cookie_jar) ... and Windows95 <douglas@home.com>
    Re: compare arrays <uri@sysarch.com>
    Re: compare arrays (Larry Rosler)
    Re: error message with sysopen in script from perlfaq5 <tchrist@mox.perl.com>
    Re: explaining the whys of referencing... WAS Re: on th <dtbaker_@flash.net>
        Extracting URLs from a file (John)
    Re: Extracting URLs from a file (Craig Berry)
        Grand Chicago.pm MegaMeeting Celebrated! <scribble@pobox.com>
    Re: HTTP POST format Please Help me! (-)
        inconstant behavior of constants miko@idocs.com
    Re: inconstant behavior of constants <tchrist@mox.perl.com>
    Re: inconstant behavior of constants (Larry Rosler)
    Re: inconstant behavior of constants (Craig Berry)
    Re: inconstant behavior of constants (Craig Berry)
    Re: newbie question on pattern match <xuchu@iscs.nus.edu.sg>
    Re: Perl Beautifier Home Page <zenin@bawdycaste.org>
    Re: Perl Beautifier Home Page <zenin@bawdycaste.org>
    Re: Perl Beautifier Home Page (Craig Berry)
        Perl call from win32 <okaili@lsil.com>
    Re: qn on string substitution (Patrick Timmins)
    Re: Recommend me Perl! (Craig Berry)
    Re: Sendmail ? (-)
    Re: Sendmail ? <zenin@bawdycaste.org>
    Re: Sticking in NULL after split (David Alan Black)
    Re: Trouble with AOL (-)
        usernames deletion in passwd file <esor@mnl.sequel.net>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 15 Jul 1998 05:02:39 GMT
From: Douglas Galbraith <douglas@home.com>
Subject: authentification problem (cookie_jar) ... and Windows95
Message-Id: <35AC37E8.4689A199@home.com>

Hello, and thanks for the help;

I trying to pull a web page from a password protected site.  (The script
is at the end of this message.)

I've encountered 2 problems.

* PROBLEM #1:
This script runs of UNIX (perl version 5.003), but fails on Windows95
(perl version 5.004_69 built for MSWin32-x86).  It fails with this error
message:

Can't locate MIME/Base64.pm in @INC (@INC contains:
C:\PERL\5.00469\lib/MSWin32-x86 C:\PERL\5.00469\lib
C:\PERL\site\5.00469\lib/MSWin32-x86 C:\PERL\site\5.00469\lib
C:\PERL\site\lib .) at C:\PERL\site\5.00469\lib/HTTP/Headers.pm line
522.

I've searched my disk and can not locate "Base64.pm".
Any suggestions?


* PROBLEM #2:
On the UNIX machine, this script requires a 60 second pause before it
can access the site a second time.  I assume this delay is due to some
authentification software probably looking for a cookie.  I've tried
adding the line: "$ua->cookie_jar();" which is supposed to active
cookies, but perl says I've got some type of error in this line so I
can't get it to work.  Does anyone know how to get cookies to work?


thanks for any and all help (battling the learning curve;)
DGalbra862@aol.com

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

use LWP::UserAgent;

$myname = 'D046';
$mypass = 'D046';
@symbol_list = ("IBM");
 
while ()
{
 foreach $symbol (@symbol_list)
 {
  $myhttp = 'http://www.freerealtime.com:8000/quotes?symbol=' . $symbol
 . '&type=Extended';
 
  print "myhttp:" , $myhttp, "\n";

  $ua = LWP::UserAgent->new;
  $request = HTTP::Request->new(GET => $myhttp);

  $request->authorization_basic($myname,$mypass);

  $response = $ua->request($request);
  $content = $response->content();

# $ua->cookie_jar(); # whats wrong with this line?
 
  if ($response->is_success) {
   print $response->content;
  } else {
   print $response->content;
   print "croaked\n";
#  exit(0);
  #print $response->status_line, "\n";
  }
 
 sleep 60;
 }
 
 print "sleeping\n";
 sleep 1;
}


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

Date: 15 Jul 1998 01:02:19 -0400
From: Uri Guttman <uri@sysarch.com>
To: lr@hpl.hp.com (Larry Rosler)
Subject: Re: compare arrays
Message-Id: <x73ec3ogf8.fsf@sysarch.com>

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


  LR> there exist a character that is known not to appear in the data ("\0" 
  LR> comes to mind immediately):

  LR>     local $" = "\0";


  LR> FOOTNOTE TO PERL DEVELOPERS:  I found that adding the check of lengths of 
  LR> strings before using 'eq' speeded a_eq() significantly (>20%).  Should 
  LR> this optimization be built into 'eq/ne', or would it slow down the normal 
  LR> (short) case inordinately?  (In terms of a guess at the implementation, 
  LR> two strlen's followed by strncmp instead of simply strcmp?)

larry,

you should know that perl doesn't need strlen, as all scalars have a
known length. otherwise how could you put \0 into a string like you just
did!

anyway the optimization of comparing lengths might be useful in its own
right, it is just a comparison of 2 ints in the implementation. i don't
know if it is done but your benchmark implies it is not.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Tue, 14 Jul 1998 22:36:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: compare arrays
Message-Id: <MPG.1015dfb6ba2bc504989742@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <x73ec3ogf8.fsf@sysarch.com> on 15 Jul 1998 01:02:19 -0400, 
Uri Guttman <uri@sysarch.com> says...
> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
> 
> 
>   LR> there exist a character that is known not to appear in the data ("\0" 
>   LR> comes to mind immediately):
> 
>   LR>     local $" = "\0";
> 
> 
>   LR> FOOTNOTE TO PERL DEVELOPERS:  I found that adding the check of lengths of 
>   LR> strings before using 'eq' speeded a_eq() significantly (>20%).  Should 
>   LR> this optimization be built into 'eq/ne', or would it slow down the normal 
>   LR> (short) case inordinately?  (In terms of a guess at the implementation, 
>   LR> two strlen's followed by strncmp instead of simply strcmp?)
> 
> larry,
> 
> you should know that perl doesn't need strlen, as all scalars have a
> known length. otherwise how could you put \0 into a string like you just
> did!

I forgot for sure.  C mentality lasts forever.  It took me a while to 
grok that length($scalar) takes no more time than '+' for example, 
because of the dope vector [similarly for scalar(@array) and scalar(keys 
%hash), of course].

> anyway the optimization of comparing lengths might be useful in its own
> right, it is just a comparison of 2 ints in the implementation. i don't
> know if it is done but your benchmark implies it is not.

Those were my results on 5.004_03, which is the latest version I have 
convenient access to (I downloaded 5.004_04 but haven't gotten around to 
building it yet).  As you say, comparison of two ints is a trivial cost, 
so this may be no more than an oversight in the implementation.

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


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

Date: 15 Jul 1998 03:56:33 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: error message with sysopen in script from perlfaq5
Message-Id: <6oh99h$dcp$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, waz@interlog.com writes:
:sysopen(FH, "../numvisits.log", O_RDWR|O_CREAT, 0644) or die "can't open
:Argument "O_SVWST" isn't numeric in sysopen at /cgi-bin/countvisitors.cgi line

That's a hilariously intriguing error.  If you'd used strict you would
have caught it.  You'll have to add a "use Fcntl" up there.  What's
happening is that those are strings because you didn't get the right
include file, so you ended up bit-or'ing strings.  This is really funny,
but I have to admit that I recognize it because I've done it myself.
We only learn from mistakes. :-)

--tom
-- 
    Q. Why is this so clumsy?
    A. The trick is to use Perl's strengths rather than its weaknesses.
            --Larry Wall in <8225@jpl-devvax.JPL.NASA.GOV>


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

Date: Tue, 14 Jul 1998 21:55:45 -0500
From: Dan Baker <dtbaker_@flash.net>
Subject: Re: explaining the whys of referencing... WAS Re: on the fly subs with special tag markers
Message-Id: <35AC1A31.32D0@flash.net>

Larry Rosler wrote:
> 
> In article <vba7m1gjmfs.fsf@mozart.stat.wisc.edu> on 14 Jul 1998 13:51:19
> -0500, Kevin Buhr <buhr@stat.wisc.edu> says...
> > Dan Baker <dtbaker_@flash.net> writes:
> ...
> > I can think of three good reasons for using references in Perl.  Of
> > course, there are probably more.
> ...
> > The second reason is subroutine-call efficiency.  This is somewhat
> > less compelling, but the fact is that it's usually faster to pass big
> > structures by reference rather than by value, simply because down at
> > the lowest level, the pass-by-reference becomes a copy operation on a
> > very small data structure while the pass-by-value can become a copy
> > operation on a very big data structure.
> 
> More critical than efficiency is the ability to pass separate aggregates
> as sequential arguments without having them flattened into a single list.
---------------------
It's beginning to makes sense.... I just have to practice with the
basics for a while for it to really sink in I think... Thanls for your
time on this thread guys!
-- 
Thanx, Dan

# If you would like to reply-to directly, remove the _ from my username
* Use of my email address regulated by US Code Title 47,
Sec.227(a)(2)(B)  *




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

Date: Wed, 15 Jul 1998 04:05:48 GMT
From: jsaya@iname.com (John)
Subject: Extracting URLs from a file
Message-Id: <35ad2a91.2524514@news.earthlink.net>

Anyone know of a simple method (using Perl), to extract all URLs and
and anything that links to graphics and other sites from a text file?

For instance, read in a file, and extract:

http://server.com/background.jpg
http://www.server.com/picture.gif
http://www.server2.com/link.html


from:

<html><body background="http://server.com/background.jpg">
<img src="http://www.server.com/picture.gif">
<a href="http://www.server2.com/link.html">
</body></html>


Please send email to jsaya@iname.com

Thanks!

--
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content. You can SELF-APPROVE your first posting
by writing the word 'passme' on a line by itself.


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

Date: 15 Jul 1998 05:23:55 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Extracting URLs from a file
Message-Id: <6ohedb$p4b$4@marina.cinenet.net>

John (jsaya@iname.com) wrote:
: Anyone know of a simple method (using Perl), to extract all URLs and
: and anything that links to graphics and other sites from a text file?
: 
: For instance, read in a file, and extract:
: 
: http://server.com/background.jpg
: http://www.server.com/picture.gif
: http://www.server2.com/link.html
: 
: from:
: 
: <html><body background="http://server.com/background.jpg">
: <img src="http://www.server.com/picture.gif">
: <a href="http://www.server2.com/link.html">
: </body></html>

Very difficult to do in the general case, but for your limited example and
similar stuff this works fine.  I'm assuming you have the entire text of
the HTML document in a scalar named $text (using an undef-$/ <>)...

  @urls = $text =~ m!"(http://.*?)"!g

This is prone to a few false positives and negatives (involving such
things as commented-out code), but it's good as far as it goes, and has
the advantage of simplicity.

: Please send email to jsaya@iname.com

Sorry, private consulting costs a whole *lot* more. :-)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 14 Jul 1998 22:17:45 -0500
From: Tushar Samant <scribble@pobox.com>
Subject: Grand Chicago.pm MegaMeeting Celebrated!
Message-Id: <6oh70p$cn1@tekka.wwa.com>

The Chicago.pm meeting this month was attended by Supreme
Perl Gods Jim Allenspach, Dan Rench (Dan, I hope I got the
name right), and Dave Lorand, later joined by a somewhat
adequate coder "Tushar Samant" (a pseudonym). The venue
was "Pick Me Up" on Clark, chosen for its allusion to the
virtue of Laziness. The next two meetings will be planned
around Impatience and Hubris, after which the general theme
forever will be Beer. Pick Me up was decided upon as the
place to visit at least one more time, due to the free 
camel parking. Among the important things uncovered in
the meeting was the fact that vi users outnumbered emacs
users 3 to 1. A quick, well-organized rush would have
resulted in a decisive victory for vi; however, the
opportunity was lost due to Laziness. Conversation
drifted to various other topics until it was realized
that Perl should also get talked about. It was obvious
from the glassy looks on all other patrons' faces that
they were extremely impressed by the group's passionately
Lazy pursuit of Perl. Some went so far as to roll their
eyes. The group continued to Flaunt It unabashedly. At
this point the adequate coder "Tushar Samant" made one
of the biggest faux pas of his life by ordering Java.
Because of his use of vi, his sentence was commuted
and he got off after being made to sing in the style
of Wm Shatner. Inspired by the performance, a band
called "Three L Larry" was formed. After that, the talk
turned to the Asian economic crisis, the latest book by
David Foster Wallace, the direction the Supreme Court
seems to be taking, determinism vs free will, semiotic
analysis of Disney movies, whether 12 tone music will
survive, and whether the beta will be out tomorrow.
The meeting was adjourned late in the evening, after
the waitress brought the check with a three-line JAPH
scrawled on it. It appears to be solving the halting
problem.



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

Date: Wed, 15 Jul 1998 05:22:53 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: HTTP POST format Please Help me!
Message-Id: <35ac3b85.78781406@nntp.idsonline.com>

Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> Said this:

>Re: HTTP POST format Please Help me!, John
><jrenna@bellsouth.net> said:
>
>John> Hi, Does anyone know how to do an HTTP Post to a
>John> search engine using the HTTP protocol.  I know the
>John> format is something like this but I am missing
>John> something where $HTTPDEF is in the request string
>John> below: This is an example tme trying to submit an URL
>John> to excite, but of course the HTTPDEF needs
>John> information.  Can anyone help me please?
>
>perldoc LWP::UserAgent
>perldoc HTTP::Request
>

Or you can use Selena Sol's http-lib.pl

I've written my own little library that has subroutines for submitting
to the 5 "top" search engines, so I can just "require" the library
then call a subroutine like this:

$result = &Excite_Submit($url, $email);

in my scripts that need to submit a page.  I also rolled search
retrieval into it... so you can do this:

@urls = &Excite_Get($search_term);

and you'll get an array of the top 20 pages from Excite.  See where
that is going?  hehehe.... 





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

Date: Wed, 15 Jul 1998 04:04:39 GMT
From: miko@idocs.com
Subject: inconstant behavior of constants
Message-Id: <6oh9on$13o$1@nnrp1.dejanews.com>

I'm having a hard time understanding some of the details in using constants in
Perl.  The behavior that is most perplexing is when the constant is used as a
key in an asociative array.  In that situation the constant's name is used
instead of the constant's value.  Consider the following code:

--- start code snip --------------------------------------------------
#!/usr/bin/perl
use constant STARTYEAR        =>  -3;
use constant STARTMONTH       =>  -4;
use constant STARTDAY         =>  -5;

%myarr=();
$myarr{STARTYEAR} = "1984";

print "just constant: STARTYEAR= " . STARTYEAR . "\n";
print "constant in associative array: $myarr{STARTYEAR}\n";
print "associative array with hardcoded value: $myarr{-3}\n";
print "keys:\n";
foreach(keys %myarr)
	{print "\t$_ = $myarr{$_}\n";}
--- end code snip --------------------------------------------------

The output looks like this:

just constant: STARTYEAR= -3
constant in associative array: 1984
associative array with hardcoded value:
keys:
        STARTYEAR = 1984

As you can see, when used as the key in an associative array, the constant's
name (STARTYEAR) is used instead of the value (-3).  This is really messing me
up.. What am I missing here, and how can I use the constant's value in an
associative array?

-miko

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


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

Date: 15 Jul 1998 04:52:21 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: inconstant behavior of constants
Message-Id: <6ohci5$f5q$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, miko@idocs.com writes:
:use constant STARTYEAR        =>  -3;
:$myarr{STARTYEAR} = "1984";

You just wrote

    $myarr{"STARTYEAR"} = "1984";

Without knowing it.  Braces quote bareword strings, you know.

The -w flag would illicit

    Ambiguous use of {STARTYEAR} resolved to {"STARTYEAR"} at /tmp/a line 2.

if you used it.  That warnings goes away with 5.005, because we thought
people had figured this out already.  Hm....

--tom

-- 
If you consistently take an antagonistic approach, however, people are
going to start thinking you're from New York.   :-)
        --Larry Wall to Dan Bernstein in <10187@jpl-devvax.JPL.NASA.GOV>


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

Date: Tue, 14 Jul 1998 22:31:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: inconstant behavior of constants
Message-Id: <MPG.1015de7379382af989740@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <6oh9on$13o$1@nnrp1.dejanews.com> on Wed, 15 Jul 1998 04:04:39 

GMT, miko@idocs.com <miko@idocs.com> says...
,,,
> #!/usr/bin/perl
> use constant STARTYEAR        =>  -3;
> use constant STARTMONTH       =>  -4;
> use constant STARTDAY         =>  -5;
> 
> %myarr=();
> $myarr{STARTYEAR} = "1984";

Had you used the '-w' flag (WHY didn't you?), you would have found the 
problem immediately.  To do what you want, you must write either:

$myarr{(STARTYEAR)}

or

$myarr{STARTYEAR()}

or (one character shorter)

$myarr{+STARTYEAR}

because these constants are (inlined-for-efficiency) function calls, not 
strings!

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr


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

Date: 15 Jul 1998 05:36:43 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: inconstant behavior of constants
Message-Id: <6ohf5b$p4b$5@marina.cinenet.net>

Tom Christiansen (tchrist@mox.perl.com) wrote:
: In comp.lang.perl.misc, miko@idocs.com writes:
: :use constant STARTYEAR        =>  -3;
: :$myarr{STARTYEAR} = "1984";
: 
: You just wrote
:     $myarr{"STARTYEAR"} = "1984";
: Without knowing it.  Braces quote bareword strings, you know.
: 
: The -w flag would illicit

No, I think that's entirely above-board. :)

:     Ambiguous use of {STARTYEAR} resolved to {"STARTYEAR"} at /tmp/a line 2.

So would the correct (or a correct) way of writing such a bareword
constant being evaluated for its numeric value

  $myhash{+STARTYEAR} = 1984;

And how would one best make this work for a string constant?

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 15 Jul 1998 05:41:05 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: inconstant behavior of constants
Message-Id: <6ohfdh$p4b$6@marina.cinenet.net>

Craig Berry (cberry@cinenet.net) wrote:
: So would the correct (or a correct) way of writing such a bareword
: constant being evaluated for its numeric value
: 
:   $myhash{+STARTYEAR} = 1984;
: 
: And how would one best make this work for a string constant?

Never mind, Larry Rossler just posted the answer to this.  LSNED...

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 15 Jul 1998 02:59:32 GMT
From: wings <xuchu@iscs.nus.edu.sg>
Subject: Re: newbie question on pattern match
Message-Id: <6oh5uk$eb13@id4.nus.edu.sg>

thx for all replies. i am clear now:) yes, my original thought was
	s/(\d)(\d\d\d)(\D)*/$1,$2/; and s/(\d)(\d\d\d)(\D)+/$1,$2/;
but neither of them worked. i was confused at that time coz the output
ate the trail of my original string.

thx for all of u, i love PERL :) more than any other coz i find every
time i post a question here i get replies from u:) which is not the case
in other bbs.

thx again.

-- 
wings
------
World is a book, those dont travel read only one page.

Email: xwings@usa.net, xuchu@iscs.nus.edu.sg
ICQ UIN: 1440319
http://gump.iscs.nus.edu.sg


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

Date: 15 Jul 1998 04:28:32 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl Beautifier Home Page
Message-Id: <900477438.73058@thrush.omix.com>

Austin Schutz <spamsux-tex@habit.com> wrote:
	>snip<
: One thing I am a pretty staunch supporter of
: is using spaces rather than tabs to indent code.

	One thing I am a pretty staunch supporter of is user defined options
	for such things, or the "beautifier" is useless to all but the
	creator.

	And just to start the Holly War on a good foot, spaces suck hard
	IMHO.  Why? Simple, they needlessly make it harder to backup an
	expression as most editors need to hit back space for as many
	spaces as you use for the indent(s).  Thus, to change:


		{
		        foo();
		            bar();
		}
	To:
		{
		    foo();
		    bar();
		}

	Takes 12 backspaces, instead of 3. -With tabs stops set to 4
	spaces as they should be for coding, of course. :-)

	Use of tabs only vs spaces at all also makes it much easier/faster
	to change:

		$foo    = 10;
	To:
		$foobar	= 10;

	without needing to delete the then extra spaces ("$foobar    = 10;"
	to "$foobar = 10;").

: Even moderately complex
: programs will use up half your line with indents if you use tabs.

	Not if you set your tab stops correctly (4 spaces, for coding).

: My suggestion (of course, it's what I do) is to indent with two spaces.
: Code blocks are still easily recognizable but it is much more compact.

	You must be a sysadmin... :-)

	If you're in an 80x24 char screen, sure it's somewhat "easily
	recognizable".  But if you're in a larger screen (like you really,
	really should be if you're doing any real coding...) like the
	common 90x30, 120x50, etc char settings, 2 spaces might as well
	be nothing at all.

	If you're a sysadmin stuck in a version of vi that doesn't support
	split screens you'll likely have three or four xterms open all at
	80x24 char mode.  This makes sense for sysadmins (lowest common
	denominator environment available on any random box), but doesn't
	make *any* sense (IMHO, of course) for people doing mainly
	programming.

	If you're going to be doing any real amount of development, you
	really, really should take 10 minutes to setup a much, much
	better environment then piss-ant stock vi in 80x24 char mode
	screens.  If you like vi, fine, more power to you.  But at the
	*very* least get a decent version that supports split screens
	and such that the much less useful 80x24 settings not needed.
	You'll be much, much more productive if you can see more then
	a nano-second of code at any point in time...

	The Perl source uses mixed tab/space indents at 4 spaces with
	tab stops at 8 spaces.  IMHO this is a silly convention, but
	it's not that bad (at least it's the correct 4 spaces, and at
	most ever uses 4 spaces in any length indent (the rest are
	tabs).

	2 is too small, 3 is well...just plain lame, 5-7 is even worse,
	and 8 is too big.  That leaves 4, which is just perfect. :-)

	Let the code style games begin! <evil grin>

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: 15 Jul 1998 04:51:10 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl Beautifier Home Page
Message-Id: <900478796.12054@thrush.omix.com>

[posted & mailed]

Tim Maher <tim.maher@halcyon.com> wrote:
: I've got my Perl Beautifier running, with a reasonable set
: of default options, on
: http://www.consultix.wa.com/yumpy/cgi-pvt/pbeaut.cgi.

	Quite impressive.

	>snip<
: Please help me test it by whipping some of your code at
: it!  I'll be Emailed any syntax errors that my beautifier
: introduces, which could help me improve it, prior to making
: it more generally available.

	A few comments.

	If this is to be a generalized application, user defined
	settings (indent length, indent style (all tab vs all space vs
	mixed tabs and spaces (ala the perl source)), block style (same
	line vs next line vs indented), etc.  All my comments below
	might be such option settings for instance.

	Puts spaces before -> operators.  Most common Perl code has no
	whitespace here.  It also makes a distention between:
		$foo ->[list];
	and
		$foo -> $method (@args);

	The syntax @{ expression } becomes:
		@
			{
			expression
			}
	Funky yes, but I'm not even sure that would compile... :-)

	Changes $foo = {} to:
		$foo =
		{
		};

	Not everyone (myself included:-) likes zero space between functions
	and parens:
		foo(@args)
	vs
		foo (@args)
	or sometimes
		foo ( @args )

	The statement:
		if (scalar @{ $foo } != scalar @{ $bar }) {
	got changed to:
		if (scalar @
			{
			$foo
			}
			!= scalar @
			{
			$bar
			}
		)
		{
	Ack! :-)

	Hmm, what about an interactive command line version?  One that
	would show the line to be changed with what it wants to change
	it into, and asks the user yes, no, or insert new text?
-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: 15 Jul 1998 04:56:55 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl Beautifier Home Page
Message-Id: <6ohcqn$p4b$2@marina.cinenet.net>

Larry Rosler (lr@hpl.hp.com) wrote:
: In "standards-speak" 'deprecated' has a very specific meaning:  "May be 
: removed from the language in a future revision of the standard."  This 
: isn't a value judgment about the feature or its use, just a warning that 
: it may go away some day. 

Well, that's not *quite* the full story.  After all, were that and that
alone true, then every feature of every language would always be
deprecated.  After all, the relevant governing ISO and ANSI committees
*could* convene next year, put some hallucinogens in the punchbowl, and
ratify the syntax and semantics of RATFOR as the new C++ standard.  In
other words, any language feature "may go away some day."

In truth, deprecation conveys *intent*, that the governing body is
actively considering elimination of the feature in question.  So there is
indeed a value judgement of sorts involved ("we lean toward considering
this feature useless/redundant/superceded"), and that's what gives
deprecation its non-vacuous definition. 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Tue, 14 Jul 1998 09:59:47 -0700
From: Orson Ka'ili <okaili@lsil.com>
Subject: Perl call from win32
Message-Id: <35AB8E83.CA191CA@lsil.com>

Scenario:

I have a win32 perl script that gets triggered by an event. This in turn
should call a paging programming running on a unix system. The paging
program itself can be accessed via an http call (CGI) on a browser or
from the unix command line. What is the best way to make the call to the
paging program and how?

Thanks.



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

Date: Wed, 15 Jul 1998 03:57:44 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: qn on string substitution
Message-Id: <6oh9bo$vj$1@nnrp1.dejanews.com>

In article <6ogprj$an2$1@nnrp1.dejanews.com>,
  vibhu@fjst.com wrote:
> #!/usr/is/gnu/bin/perl -w
>
> $n1 = "q[0]"; # 1
> $n2 = "q[0]"; # 2
>
> $sign = "a b c $n1 d"; # 3
> print STDOUT "$sign\n"; # 4
> $n2 =~ s/\[/\\[/g; # 5
> $sign =~ s/$n2/DONE/; # 6
>
> print STDOUT "$sign\n"; # 7
> print STDOUT "-$n1-$n2-\n"; # 8
>
> -------------------
>
> $sign could have come from any other source. I want to substitute
> the q[0] with "DONE". The substitution statement in line 6 does not
> work, as is. Line 5 is also rewquired. Why? The "[" is being considered
> as a (array) range? How can I make the substitution work without having
> to do line 5? Can anyone explain/point me to the right resource to find out?
>
[snip]

Almost there! Put \Q ... \E in line 6 to quote regex metacharacters, and get
rid of line 5:

$n1 = "q[0]"; # 1
$n2 = "q[0]"; # 2

$sign = "a b c $n1 d"; # 3
print STDOUT "$sign\n"; # 4
$sign =~ s/\Q$n2\E/DONE/; # 6

print STDOUT "$sign\n"; # 7
print STDOUT "-$n1-$n2-\n"; # 8


See perldoc perlre for more details on \Q.

Patrick Timmins
U. Nebraska Medical Center

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


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

Date: 15 Jul 1998 05:07:36 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Recommend me Perl!
Message-Id: <6ohdeo$p4b$3@marina.cinenet.net>

Tom Christiansen (tchrist@mox.perl.com) wrote:
: It's quite simple, really: it's about giving credit where credit is due.
: If you gave your life and time and blood to something until it made you
: physically ill, I dare suspect that you too would prefer that it were
: proPERLy attributed. :-)

My god, I just started hearing "My Name is Richard Henry Lee" from the
musical _1776_ in my head...  :)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Wed, 15 Jul 1998 03:59:32 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Sendmail ?
Message-Id: <35ac27eb.73871765@nntp.idsonline.com>

"Sean" <info@shopsmart.com.au> Said this:

>Hello,
>
>I am new to perl and i am trying to get this perl script working to send
>mail, but i keep encountering this error when i click send.
>
>Internal Server Error
>The server encountered an internal error or misconfiguration and was unable
>to complete your request.
>Please contact the server administrator,and inform them of the time the
>error occurred, and anything you might have done that may have caused the
>error.
>
>I have included a copy of the script below, if someone could give me a clue
>as to what i am doing wrong that would be much apreciated.
>
>Thank you in advance for your answer
>
>Sean
>
>
>
>#!/usr/tools/bin/perl  -*-perl-*-


First of all, get rid of that crap at the end "  -*-perl-*-"  (I'm
showing an ascii character that may or may not produce a problem in
some interpreters.  Either way, it's a worthless thing that has no
purpose.


># Print this out no matter what
>print "Content-type: text/html\n\n";
># flush stdout buffer
>$| = 1;
>if ($ENV{'REQUEST_METHOD'} eq 'POST')
>{
>    # How many bytes are we supposed to receive?
>    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>    @pairs = split(/&/, $buffer);
>    foreach $pair (@pairs)
>    {
>      ($name, $value) = split(/=/, $pair);
>      $value =~ tr/+/ /;
>      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>      $contents{$name} = $value;
>    }
>}
>chop($date = `date`);
>###############################################
># CGI Output: As HTML and as an email message
>###############################################
># Create an HTML document on the fly. Yee-haw!
>print <<"HTML";
><HTML>
><HEAD><TITLE>A.S.S. Travel Form Entries</TITLE></HEAD>
><BODY>
><H1>Travel Request from $contents{'name'}</H1>
><P><HR><P>
><I>$date</I>
><UL>
><LI> Name = $contents{'name'}
><LI> Email = $contents{'email'}
><LI> Departure date = $contents{'ddate'}
><LI> Departure time range = $contents{'dtime'}
><LI> Return date = $contents{'rdate'}
><LI> Return time range = $contents{'rtime'}
>HTML
>
># check the airline section of the form data
>if($contents{'airline-ind'} eq 'indiffernt') { ; }
>else {
>    print "<LI> Airline (first choice) = $contents{'airline1'}\n";
>    if($contents{'airline2'} ne '') {
>  print "<LI> Airline (second choice) = $contents{'airline2'}\n";
>    }
>}
>print <<"HTML";
><LI> Destination City = $contents{'city'}
><LI> Destination State = $contents{'state'}
><LI> Smoking preference = $contents{'smoking'}
><LI> Reason for trip = $contents{'reasons'}
>HTML
>
>if($contents{'reasons'} ne '') {
>    print "<LI> Reasons = $contents{'reasons'}\n";
>}
>print <<"HTML";
></UL>
></BODY></HTML>
>HTML
>
># Now create an email message and mail it.
>$subject = "Travel Plans for " . $contents{'name'};
>$sendto = "info@shopsmart.com.au";

Your problem is right here....  info@shopsmart.com.au should be
changed to info\@shopsmart.com.au to escape the @.  had you attempted
to run this script at the command line, you would have gotten an error
message that tells you the line of the error and a rough guesstimate
of what the problem is.  Whenever you encounter an error, TELNET into
the server and try running it on the command line!!!

When you get an error, type "vi scriptname" and then once the file is
opened in the vi editor, hit : (colon) and then type the line number
and hit enter - that will take you right to that line.  If you don't
want to learn vi, just use it to find the line, then use your windows
based text editor to do the editing ;)




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

Date: 15 Jul 1998 04:59:54 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Sendmail ?
Message-Id: <900479320.416070@thrush.omix.com>

- <root.noharvest.\@not_even\here.com> wrote:
	>snip<
: >#!/usr/tools/bin/perl  -*-perl-*-
: First of all, get rid of that crap at the end "  -*-perl-*-"  (I'm
: showing an ascii character that may or may not produce a problem in
: some interpreters.  Either way, it's a worthless thing that has no
: purpose.

	You're right, the META-W char should not be there, but the
	-*-perl-*- is both valid (doesn't affect perl at all),
	worthwhile, and has a very useful purpose, at least to users
	of Emacs.  It tells Emacs to use "perl" mode, if it has such
	a mode available.  Emacs (very correctly) doesn't try to gage
	editor settings (autoindent, etc) by file suffix if it can
	help it.

	>big, big snip...<
: If you don't want to learn vi,

	And who in there right mind does. :-)

: just use it to find the line, then use your windows
: based text editor to do the editing ;)

	s/windows based/joe, emacs, vim, (anything but stock vi)/

	:-)

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: 14 Jul 1998 23:03:45 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Sticking in NULL after split
Message-Id: <6oh66h$na9$1@pilot.njin.net>

dblack@pilot.njin.net (David Alan Black) writes:

>Here's one way:

>my $string = "one:two:0:four::five";
>print join ',', map { $_ eq " && "NULL" || $_ } split ':', $string;

Whoops, make that:

print join ',', map { $_ eq "" && "NULL" || $_ } split ':', $string;



>David Black
>dblack@pilot.njin.net
>dblack@saturn.superlink.net  <-- slightly better for mail


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

Date: Wed, 15 Jul 1998 04:05:53 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Trouble with AOL
Message-Id: <35ac2968.74252803@nntp.idsonline.com>

"Kyle Taing" <Elohim23@email.msn.com> Said this:

>People who submit forms using an AOL browser (or I.E.-based aol) seem to
>experience errors all the time.  What is happening is that some form fields
>aren't being passed.  For example, I have a mail program which is written in
>PERL.  When some aol people try to submit through the form, it can't because
>the "@" in their email address isn't passed or recognized by the PERL
>program.
>

Are you sure it isn't your script that is the problem?  Are you
checking for the @?  I mean, are you attempting to do a "valid
address" check by keying into the @??  Because I've noticed that many
aol users just have no clue - they really think aol IS the internet,
so they don't understand the whole "@somewhere.com".  They think the
whole world is aol, so when they enter their email address in a form,
they never include @aol.com - EVEN when I put "INCLUDE '@aol.com' if
you are using AOL" - no shit!


But it wouldn't surprise me if ther was a problem with one of the many
various versions of AOL out there.  I've had problems with AOL users
on my shopping cart, with some urlencoded data in <href>'s, and so
many other problems it's not funny.  And yet I can never reproduce
these problems in my own AOL software.

if you do a lot of design, you really should get an account with aol,
so you can see how the trailer-park internet users see your site. ;)




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

Date: Wed, 15 Jul 1998 11:27:43 +0800
From: "Rosemarie P. San Juan" <esor@mnl.sequel.net>
Subject: usernames deletion in passwd file
Message-Id: <35AC21AF.E47E161E@mnl.sequel.net>

What is the functiion that I'm going to use , if I'm going to delete
several usernames in a passwd file , I have a file that contains the
selected usenames to be deleted.

Thank you very much in advance .



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

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

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