[11962] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5562 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 4 17:07:16 1999

Date: Tue, 4 May 99 14:00:16 -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, 4 May 1999     Volume: 8 Number: 5562

Today's topics:
        Always running <dnkhan@my-dejanews.com>
    Re: Generate more than one page with one script <jwarner@tivoli.com>
    Re: Generate more than one page with one script (Tad McClellan)
        how to compare standard arrays? bing-du@tamu.edu
        how to compare standard arrays? du_bing@my-dejanews.com
        Limit to number of if statements??? <info@modularcenter.com>
        Making executables from .pl files? <agjemmes@extremeonline.com>
    Re: Memory leak (Brian Peisley)
        Meta Search Engine <jeff@postmark.net>
    Re: Newsfeed and Local Weather (Kai Henningsen)
        Pattern Matching and parsing <bigbird@pol.com>
    Re: Perl 5: The Complete Reference, Martin Brown <uri@ibnets.com>
    Re: Perl 5: The Complete Reference, Martin Brown <tchrist@mox.perl.com>
    Re: Perl 5: The Complete Reference, Martin Brown <uri@ibnets.com>
        Please help me (nobody ever does :( <gerbenhd@nederlands.com>
    Re: Question: Updating an Array... <uri@ibnets.com>
    Re: Question: Updating an Array... (Steve Linberg)
    Re: Question] 'use' and 'require' trouble <skine@ark-works.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 04 May 1999 20:16:48 GMT
From: Khan <dnkhan@my-dejanews.com>
Subject: Always running
Message-Id: <7gnkjb$s3m$1@nnrp1.dejanews.com>

Hi,
   I have a perl script on a unix (solaris) box that is always checking if a
certain file exists in a directory or not. Besides this , there are other
things it does which might cause the script to terminate.

How do i ensure in Perl that when this process dies for whatever reason, it
always gets restarted ? ( somehow emulate the parent child forking concept )

thanks in advance for your help.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 04 May 1999 14:40:26 -0500
From: John Warner <jwarner@tivoli.com>
Subject: Re: Generate more than one page with one script
Message-Id: <372F4D2A.E32B7E3B@tivoli.com>

Check out http://www.wiley.com/compbooks/stein/source.html for examples of how
to do this.  In particular, look at the scripts from chapter 2.  Start with
the advice.pl and loan.pl examples and then work your way into the guestbook
script.

Hope this helps.

Edouard PAVIS wrote:

> Script's Goal:
> A user must be identified (login, passwd) in order to send a cookie to him
> with the second page.
>
> Script's summary :
> **********************************
> $page1=new CGI;
> $page1->form(...)....submit
> analysis of the submit information
> if it's ok, I put 1 in $Var
>
> if($Var=1)
> {
> $page2=new CGI;
> $page2->header(cookie(...));
> }
> ****************************
> The page2 is never create, perharps because the 1 is never delete...
> Thangs,
> Edouard
> <e.pavis@silicomp.fr>
>
> Steve Linberg wrote:
>
> > In article <372F273F.2841F0C1@silicomp.com>, e.pavis@silicomp.com wrote:
> >
> > > The second party never appear in my browser
> >
> > Of course not.  How is your browser supposed to handle this second page?
> > What happens to the first?
> >
> > You can't do what you're trying to do, at least as I understand your
> > post.  Maybe you can explain why you want to do this.
> >
> > --
> > Steve Linberg, Systems Programmer &c.
> > National Center on Adult Literacy, University of Pennsylvania
> > email: <linberg@literacy.upenn.edu>
> > WWW: <http://www.literacyonline.org>

--

John Warner                           Tivoli Systems Inc.
Sales Support Engineer           9442 Capital Of Texas Hwy North
Sales Infrastructure Group       Austin, TX 78759
john_warner@tivoli.com




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

Date: Tue, 4 May 1999 11:43:32 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Generate more than one page with one script
Message-Id: <4j4ng7.f24.ln@magna.metronet.com>

Edouard PAVIS (e.pavis@silicomp.com) wrote:

: if($Var=1)


   You should never run perl without enabling warnings.

   Really.

   Never.

   Wonder why?

   Try it on your program.

   See?

   It will find your mistakes for you, but you have to ask for the help.


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


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

Date: Tue, 04 May 1999 20:40:09 GMT
From: bing-du@tamu.edu
Subject: how to compare standard arrays?
Message-Id: <7gnlv8$t9l$1@nnrp1.dejanews.com>

Hello there,

Why does the following code snippet generate "same array"?
------------------------------------------------------------
#!/usr/local/bin/perl -w
use strict;

@test1 = ('one','two');
@test2 = ('two','three');

if (@test1 eq @test2)
{ print "same array\n";
} else { print "different array\n";}
--------------------------------------------------------------

Any ideas?  Thanks in advance,

Bing

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 04 May 1999 20:40:04 GMT
From: du_bing@my-dejanews.com
Subject: how to compare standard arrays?
Message-Id: <7gnlv3$t9h$1@nnrp1.dejanews.com>

Hello there,

Why does the following code snippet generate "same array"?
------------------------------------------------------------
#!/usr/local/bin/perl -w
use strict;

@test1 = ('one','two');
@test2 = ('two','three');

if (@test1 eq @test2)
{ print "same array\n";
} else { print "different array\n";}
--------------------------------------------------------------

Any ideas?  Thanks in advance,

Bing

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 4 May 1999 16:41:52 -0400
From: "MHCA" <info@modularcenter.com>
Subject: Limit to number of if statements???
Message-Id: <7gnm54$b12$1@autumn.news.rcn.net>

Hello,

Is there a limit to the length of an if, elsif, else block, or a limit to
the number of elsif statements?

The following code worked until I added this one more elsif statement:

elsif ($FORM{'Key4'} eq "Bronx") {
# Homeworks Modular Homes - builder_32
&builder_32;
}

#-----------------------------------
# CODE STARTS HERE
#-----------------------------------

if ($FORM{'Key4'} eq "Albany") {
# American Homes of Clifton Park - builder_05
&builder_05;
}

elsif ($FORM{'Key4'} eq "Allegany") {
# Owl Homes of Allegany - builder_46
&builder_46;
}

elsif ($FORM{'Key4'} eq "Bronx") {
# Homeworks Modular Homes - builder_32
&builder_32;
}

elsif ($FORM{'Key4'} eq "Broome") {
# Northstar Homes - builder_44
&builder_44;
}

elsif ($FORM{'Key4'} eq "Cattaraugus") {
# Owl Homes of Allegany - builder_46
&builder_46;
}

elsif ($FORM{'Key4'} eq "Cayuga") {
# Classic Homes - builder_11
&builder_11;
}

elsif ($FORM{'Key4'} eq "Chautauqua") {
# Owl Homes of Allegany - builder_46
&builder_46;
}

elsif ($FORM{'Key4'} eq "Chemung") {
# Owl Homes of Bath - builder_47
&builder_47;
}

elsif ($FORM{'Key4'} eq "Chenango") {
# Classic Homes - builder_11
&builder_11;
}

elsif ($FORM{'Key4'} eq "Clinton") {
# Plattsburgh Wholesale, Inc. - builder_49
&builder_49;
}

elsif ($FORM{'Key4'} eq "Columbia") {
# Northstar Homes - builder_44
&builder_44;
}

elsif ($FORM{'Key4'} eq "Cortland") {
# Classic Homes - builder_11
&builder_11;
}

elsif ($FORM{'Key4'} eq "Delaware") {
# Northstar Homes - builder_44
&builder_44;
}

elsif ($FORM{'Key4'} eq "Dutchess") {
# Trestle View Builders, LTD - builder_63
&builder_63;
}

elsif ($FORM{'Key4'} eq "Essex") {
# Plattsburgh Wholesale, Inc. - builder_49
&builder_49;
}

elsif ($FORM{'Key4'} eq "Franklin") {
# Plattsburgh Wholesale, Inc. - builder_49
&builder_49;
}

elsif ($FORM{'Key4'} eq "Fulton") {
# Northstar Homes - builder_44
&builder_44;
}

elsif ($FORM{'Key4'} eq "Genesee") {
# Whal Heikkila - builder_66
&builder_66;
# Northstar Homes - builder_44
&builder_44;
}

elsif ($FORM{'Key4'} eq "Greene") {
# Northstar Homes - builder_44
&builder_44;
}

elsif ($FORM{'Key4'} eq "Herkimer") {
# Northstar Homes - builder_44
&builder_44;
}

elsif ($FORM{'Key4'} eq "Jefferson") {
# Classic Homes - builder_11
&builder_11;
}

elsif ($FORM{'Key4'} eq "Lewis") {
# Classic Homes - builder_11
&builder_11;
}

elsif ($FORM{'Key4'} eq "Livingston") {
# Owl Homes of Bath - builder_47
&builder_47;
# Whal Heikkila - builder_66
&builder_66;
}

elsif ($FORM{'Key4'} eq "Madison") {
# Classic Homes - builder_11
&builder_11;
}

elsif ($FORM{'Key4'} eq "Mohawk") {
# Northstar Homes - builder_44
&builder_44;
}

elsif ($FORM{'Key4'} eq "Monroe") {
# Whal Heikkila - builder_66
&builder_66;
# Northstar Homes - builder_44
&builder_44;
}

elsif ($FORM{'Key4'} eq "Montgomery") {
# Superior Housing - builder_62
&builder_62;
}

elsif ($FORM{'Key4'} eq "Nassau") {
# Homeworks Modular Homes - builder_32
&builder_32;
}

elsif ($FORM{'Key4'} eq "Niagara") {
# Northstar Homes - builder_44
&builder_44;
}

elsif ($FORM{'Key4'} eq "Oneida") {
# Classic Homes - builder_11
&builder_11;
}

elsif ($FORM{'Key4'} eq "Onandaga") {
# Classic Homes - builder_11
&builder_11;
# Northstar Homes - builder_44
&builder_44;
}

elsif ($FORM{'Key4'} eq "Ontario") {
# Whal Heikkila - builder_66
&builder_66;
# Northstar Homes - builder_44
&builder_44;
}

elsif ($FORM{'Key4'} eq "Orange") {
# Trestle View Builders, LTD - builder_63
&builder_63;
# TKH Construction Management - builder_75
&builder_75;
}

elsif ($FORM{'Key4'} eq "Oswego") {
# Classic Homes - builder_11
&builder_11;
}

elsif ($FORM{'Key4'} eq "Otsego") {
# Superior Housing - builder_62
&builder_62;
}

elsif ($FORM{'Key4'} eq "Putnam") {
# Trestle View Builders, LTD - builder_63
&builder_63;
# TKH Construction Management - builder_75
&builder_75;
}

elsif ($FORM{'Key4'} eq "Queens") {
# Homeworks Modular Homes - builder_32
&builder_32;
}

elsif ($FORM{'Key4'} eq "Rensselaer") {
# American Homes of Clifton Park - builder_05
&builder_05;
}

elsif ($FORM{'Key4'} eq "Rockland") {
# Trestle View Builders, LTD - builder_63
&builder_63;
# TKH Construction Management - builder_75
&builder_75;
}

elsif ($FORM{'Key4'} eq "Saratoga") {
# American Homes of Clifton Park - builder_05
&builder_05;
}

elsif ($FORM{'Key4'} eq "Schenectady") {
# American Homes of Clifton Park - builder_05
&builder_05;
}

elsif ($FORM{'Key4'} eq "Schoharie") {
# Superior Housing - builder_62
&builder_62;
}

elsif ($FORM{'Key4'} eq "Schuyler") {
# Classic Homes - builder_11
&builder_11;
}

elsif ($FORM{'Key4'} eq "Seneca") {
# Classic Homes - builder_11
&builder_11;
}

elsif ($FORM{'Key4'} eq "St Lawrence") {
# Plattsburgh Wholesale, Inc. - builder_49
&builder_49;
# Classic Homes - builder_11
&builder_11;
}

elsif ($FORM{'Key4'} eq "Steuben") {
# Owl Homes of Bath - builder_47
&builder_47;
}

elsif ($FORM{'Key4'} eq "Suffolk") {
# Homeworks Modular Homes - builder_32
&builder_32;
}

elsif ($FORM{'Key4'} eq "Sullivan") {
# Trestle View Builders, LTD - builder_63
&builder_63;
}

elsif ($FORM{'Key4'} eq "Tioga") {
# Northstar Homes - builder_44
&builder_44;
}

elsif ($FORM{'Key4'} eq "Tompkins") {
# Classic Homes - builder_11
&builder_11;
}

elsif ($FORM{'Key4'} eq "Ulster") {
# Plattsburgh Wholesale, Inc. - builder_49
&builder_49;
# Trestle View Builders, LTD - builder_63
&builder_63;
}

elsif ($FORM{'Key4'} eq "Warren") {
# American Homes of Clifton Park - builder_05
&builder_05;
# Plattsburgh Wholesale, Inc. - builder_49
&builder_49;
}

elsif ($FORM{'Key4'} eq "Washington") {
# American Homes of Clifton Park - builder_05
&builder_05;
}

elsif ($FORM{'Key4'} eq "Wayne") {
# Classic Homes - builder_11
&builder_11;
# Whal Heikkila - builder_66
&builder_66;
# Northstar Homes - builder_44
&builder_44;
}

elsif ($FORM{'Key4'} eq "Westchester") {
# Shoreline Modular Homes - builder_74
&builder_74;
# TKH Construction Management - builder_75
&builder_75;
}

elsif ($FORM{'Key4'} eq "Wyoming") {
# Owl Homes of Allegany - builder_46
&builder_46;
}

elsif ($FORM{'Key4'} eq "Yates") {
# Owl Homes of Bath - builder_47
&builder_47;
# Whal Heikkila - builder_66
&builder_66;
}

else {
&unreferred;
}
==============================
Modular Home Center of America
------------------------------------------------------
The leading on-line directory and
resource for modular home information.
------------------------------------------------------
http://www.modularcenter.com
info@modularcenter.com
==============================




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

Date: Tue, 4 May 1999 23:01:51 +0200
From: "Asbjorn Gjemmestad" <agjemmes@extremeonline.com>
Subject: Making executables from .pl files?
Message-Id: <3dJX2.545$Co.2177@news1.online.no>

I am looking for a way to make executables from my .pl files to avoid
shipping my source code with my programs. I know perl2exe does just that,
but they charge $500 for a full package, so I thought I'd check in here
first.

I need to compile files for at least unix systems (as many variations as
possible), but hopefully also windows and solaris. Can anyone help me?

thnx

Asbjorn




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

Date: Tue, 04 May 1999 20:11:19 GMT
From: brian@helka.mutagenic.org (Brian Peisley)
Subject: Re: Memory leak
Message-Id: <slrn7iul6j.ef.brian@helka.mutagenic.org>

In comp.lang.perl.misc Aaron Shilts <ashilt01@sprintspectrum.com> writes:

>Is there a better way to exit a loop and call a subroutine directly?

I'm still learning Perl, but I don't think you need to use subroutines for
this, just a couple loops.  If I'm mistaken, I'm sure I'll be corrected
shorlty. :-)

>I have included a portion of the code and would appreciate any ideas:
>-------------------------------
>sub check_calls {
> $size = -s $call_info;
> if ($size == 0) {
>  sleep (1);
>  &check_file;
>  }
> elsif ($size == $size_sent) {
>  sleep (1);
>  &check_file;
>  }
> elsif ($size > $size_sent) {
>  print ("There is new data since the last transmission\n");
>   &send_calls;
>  }
> else {print ("There is a processing error!\n");}
>}
>-------------------------------

What you have going here is a recursive nightmare.  Here is what I came up
with:

------------------------------------------------------------------------
#!/usr/bin/perl -w
use strict;

my ( $call_info, $size_sent);

$call_info = "testfile";
$size_sent = -s $call_info;

SEND_CALL: for (;;) {
	
	for (;;) {
		my $size = -s $call_info;
		if ($size == $size_sent || $size == 0) {
			print $size, "\n";
			print "nothing new...\n";
			sleep 1;
			next;
		}
		if ($size > $size_sent) {
			$size_sent = $size;
			print $size, "\n";
			print "new stuff!\n";
			last;
		}
		print "processing error if you get this far\n";
		last SEND_CALL;
	}
	
	# Do stuff from &send_calls routine here.
	
	print "call sent!\n"
}
-------------------------------------------------------------------------

This should run until $size < $size_sent && $size != 0 which would be the
processing error.  Since a size of 0 is okay, I'm guessing that the file
may be replaced at some point and you don't want your program to fail when
that happens.  What happens if the file gets replaced and something gets
added to it before you check the size of the file again?  Unless you are
doing something in &send_calls it looks like it would fail.

I hope this helps you out.  It's not perfect but like I said, I'm still new.
It has to be better than infinite recursion though, (I hope). :-)

-- 
Brian Peisley
bdp@mutagenic.org


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

Date: Tue, 04 May 1999 22:00:07 +0200
From: Jeff Rus <jeff@postmark.net>
Subject: Meta Search Engine
Message-Id: <372F51C7.3066@postmark.net>

Hi,

I want to add a Meta Search Engine like MetaSearch
to my site. I would like to be able to add my
own banners to the search results (so not a service
like www.whatuseek.com)

Does anyone know of such a script? Or how hard is
it to create one?

Thanks,
Jeff Rus


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

Date: 04 May 1999 21:50:00 +0200
From: kaih=7GFzapqXw-B@khms.westfalen.de (Kai Henningsen)
Subject: Re: Newsfeed and Local Weather
Message-Id: <7GFzapqXw-B@khms.westfalen.de>

lr@hpl.hp.com (Larry Rosler)  wrote on 03.05.99 in <MPG.1197907919e642349899a4@nntp.hpl.hp.com>:

> In article <xkfwvyqkopl.fsf@valdemar.col.hp.com> on 03 May 1999 12:11:50
> -0600, Eric The Read <emschwar@rmi.net> says...
> > Tom Christiansen <tchrist@mox.perl.com> writes:
> > > ifyouwontputindoublespacestoseparatesentencesandyouwontputincapitals
> > > toindicatetheirstartitisquiteabithardertoparsethanwedeserve.
> >
> > itshouldbenotedforthebenefitoftheoverlypedanticthattheuseoftwospacesaftera
> > sentenceendingpunctuationmarkisentirelyamatterofhousestylethoughitdoesseem
> > tobemorecommonwhenusingmonospacedtypebutitshardlyuniversaleventhere.
>
> theadventofHTMLhasmadeitevenworsebecauseinordinarytextHTMLtreatstwospace
> sthesameasonesonooneseesthedistictionandnobodyuses&nbsp;&nbsp;toseparate
> sentencesinanycasebuttheyshould!

TwospacestoseparatesentencesisasillyEnglish-languageconceitanyway.Real
languagesdon'tneedthis.(Butleavingoutthespacesisbloodypainfuleventotype.
So can we please stop this nonsense?)

Kai
--
http://www.westfalen.de/private/khms/
"... by God I *KNOW* what this network is for, and you can't have it."
  - Russ Allbery (rra@stanford.edu)


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

Date: Tue, 4 May 1999 16:09:04 -0400
From: "Greg Waugh" <bigbird@pol.com>
Subject: Pattern Matching and parsing
Message-Id: <372f53bf@news.one.net>

Hi there!  I was hoping I could get a bit of help with some Perl code to fix
this little problem.  I have a text file that needs to be split by keywords.
For example:

Bob: data data, data data, data data,
data, data data, data
Steve: moredata, moredata
John: differentdata, differetdata, differentdata,
differentdata, differentdata

The names will remain contant, as in Bob (a unique name) will be in the file
most of the time, but it always referrs to the same person.  A list of
keywords in an array or a text file would be adequate.

The file will explicitly wrap and is then terminated with a unix \n.  So
line 2 (data, data..etc) is the beginning of a new line even though it
referrs to Bob: and should be part of his data.

Ideally, I'd like it to split by the list of all names ( @names = ("Bob",
"Steve", "Mark", "John") ) that might or might not appear in the file.  The
order will most likely remain constant.  So that the final data structure
would contain (I use an array as an illustration):

$output[0] eq "Bob: data data, data data, data data, data, data data, data"
$output[1] eq "Steve: moredata, moredata"
$output[2] eq "John: differentdata, differetdata, differentdata,
differentdata, differentdata"

I've tried slurping the file into one line (undef $/; and s/\n//g) but I
don't know a pattern matching statement to split it the way I need to.  I
don't want to have to resort to an iterative way of doing it unless I have
to.

Anyway, thanks in advance for any tips!

Greg Waugh
bigbird@pol.com







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

Date: 04 May 1999 16:08:25 -0400
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Perl 5: The Complete Reference, Martin Brown
Message-Id: <39n1zkbnt2.fsf@ibnets.com>

>>>>> "v" == vepxistqaosani  <vepxistqaosani@my-dejanews.com> writes:

  v> Some chapters from this book are available at
  v> http://www.books.mcgraw-hill.com/betabooks/brown/index.html

  v> It'll be in the bookstores in June; does anyone have any advance
  v> word about it?

  v> Randal, at the Boston tutorial last week, you said that you did
  v> technical reviews of new Perl books -- is this one of them?

i will provide a quicky tech review of the 3 published chapters. in the
first function in chapter 5, defined, there is already a bad error. it
says 

<STUPID BOOK>

On whole arrays or hashes it returns true only when an array is not
empty or when a hash contains any keys (but not necessarily
corresponding values).

</STUPID BOOK>

whereas perldoc -f says:

Currently, using defined() on an entire array or hash reports whether
memory for that aggregate has ever been allocated.  So an array you set
to the empty list appears undefined initially, and one that once was full
and that you then set to the empty list still appears defined.

which directly contradicts the book. strike 1!!

in general, defined on a aggregate is not useful.

the next part on undef is equally bewildering. it never mentions
assigning undef to a var, just using undef as a function call. those are 
very different animals and they should state that if they are going the
be "Perl: The Complete Reference" ha ha ha!!

ASIDE: the web page is moronized with stupid u$hit quote chars so don't
read it with a  unix netscape. they are already losing all of the
intelligent perl hackers on that stupidity alone. when they get to the
special vars $` and $', the result is ludicrous!

<STUPID BOOK>

The hex function only recognizes numbers in strict hexadecimal format, such as
"ff47ace3", which we can display the value of with:

print hex("ff47ace3");

</STUPID BOOK>


perldoc -f hex

    print hex '0xAf'; # prints '175'
    print hex 'aF';   # same


actually hex can take leading 0x just fine and doesn't require 'strict'
hex format. they say only oct can can correctly parse numeric strings
with leadin 0 or 0x. maybe they think there is a strict 'hex' pragma?
:-) which do you believe? Steeerriiikkee twoooo!!!!


2 mistakes in the first few functions. wanna place a bet on when i find
the next one? they also mention ** next to exp since this section is
about math functions (but ** is an op!). i haven't seen how they
actually organize all the ops and functions but this chapter is a mess.

oooh! oooh!! here is a good one!

<STUPID BOOK>

To print a hexadecimal or octal number use the printf or use sprintf to
print a formatted base number to a string:

printf ("%lo %lx", oct("0755"), oct("0x7f"));
</STUPID BOOK>

not a true mistake but why don't they mention printing leading 0 or 0x
here when they are converting those? and why the lo and lx? perl does
fine with just o and x printf formats.

minor bug: they don't mention 4 argument substr but that might have been 
released before the book went to print. but i bet the author still
doesn't know about it!

call that a foul ball.

ok, we have a winnah!! they say to use \1, \2, etc in the replacement
part of s///. technically it works but it is wrong. they should only be
used in the match part to refer to a previous match. it is very odd
since they mention $1, $2 just before this for use outside the
regex. well this author is a major perl luser!

<STUPID BOOK>

Each group is also recorded in the special variables $1, $2, $3 and so on, so the
above example could be rewritten as:

$time =~ m/(\d+):(\d+):(\d+)/;
my ($hours, $minutes, $seconds) = ($1, $2, $3);

In the case of substitution, each matched group is also available as a
replacement value using the \1, \2, \3 syntax. So, using the date string
example above:

$date = '03/26/1999';
$date =~ s#(\d+)/(\d+)/(\d+)#\3\1\2#;

</STUPID BOOK>

so it's one, two, three strikes you're out! at the old perl book game!

here's a good one i just spotted:

<STUPID BOOK>
The final metacharacter(s) are the [] parentheses.
</STUPID BOOK>

have you ever seen [] refered to as parens? brackets, square brackets,
but never parens!

<STUPID BOOK>
\b	Matches a word boundary. 

\b	Backspace
</STUPID BOOK>

those were in the same table of regex metachars. no notes on one being
used in the main regex (word boundary) and the other in char classes
(backspace).


here is a fun one about tr/// vs s/// delimiters:

<STUPID BOOK>
Unlike regular expressions the SEARCHLIST and REPLACEMENTLIST arguments
to the operator do not need to use the same delimiters. As long as the
SEARCHLIST is naturally paired delimiters such as parentheses or braces
the REPLACEMENTLIST can use it?s own pair. This makes the conversion of
forward slashes clearer than the traditional regular expression search:

$macdir = tr(/)/:/;

</STUPID BOOK>

this is one totally wrong. i use s[]{} with no problems. and the example 
above is more confusing than tr[/][:] ;

from perldoc perlop:

If the PATTERN is delimited by
bracketing quotes, the REPLACEMENT has its own pair
of quotes, which may or may not be bracketing
quotes, e.g., s(foo)(bar) or s<foo>/bar/.



in chapter 5 on "advanced perl programming" they make a common nebie
mistake on getting args from @_:

<STUPID BOOK>

sub add
{
$first_num = @_[0];
$second_num = @_[1];
</STUPID BOOK>

and again:

<STUPID BOOK>
sub square
{
@_[0] *= @_[0];
}
</STUPID BOOK>


this is getting tiring. this will be a horrible book by the looks of it.

the final insult is this one:

<STUPID BOOK>
Don?t use eval when you can use braces to expand information inline such as
variable names. You can use something like :

${$prefix . $var} = "String";
</STUPID BOOK>

he advocates symbolic refs over eval!! but no mention here of data
structures. 


"Perl: The ImComplete Reference"

guaranteed to teach bad perl or you pay us more money!

uri

-- 
Uri Guttman                             Hacking Perl for Ironbridge Networks
uri@sysarch.com				uri@ironbridgenetworks.com	


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

Date: 4 May 1999 14:26:09 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl 5: The Complete Reference, Martin Brown
Message-Id: <372f57e1@cs.colorado.edu>

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

In comp.lang.perl.misc, 
    Uri Guttman <uri@ibnets.com> writes:
:"Perl: The ImComplete Reference"
:guaranteed to teach bad perl or you pay us more money!

Thank you for your service.  The publisher should hear this, though.

--tom
-- 
MSDOS isn't dead.  It just smells like it.


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

Date: 04 May 1999 16:35:23 -0400
From: Uri Guttman <uri@ibnets.com>
To: tchrist@mox.perl.com (Tom Christiansen)
Subject: Re: Perl 5: The Complete Reference, Martin Brown
Message-Id: <39iua8bmk4.fsf@ibnets.com>

>>>>> "TC" == Tom Christiansen <tchrist@mox.perl.com> writes:

  TC>  [courtesy cc of this posting sent to cited author via email] In
  TC> comp.lang.perl.misc, Uri Guttman <uri@ibnets.com> writes: :"Perl:
  TC> The ImComplete Reference" :guaranteed to teach bad perl or you pay
  TC> us more money!

  TC> Thank you for your service.  The publisher should hear this,
  TC> though.

you're welcome. if they want to hear it, let them read this group. :-)
and i didn't even use a fine toothed comb. what pisses me off most are
the direct contradictions with the perl docs.

chapters 4,5 had an overviewish tone but claim to be reference. another
great piece of editing by osborne/mcgraw-hill. from some of the bad html 
stuff with quotes, i can't wait to see how bad it looks in print.

<STUPID BOOK>

I have yet to come across a program of reasonable length (i.e. not a
"print ?Hello World\n?;" program)

<STUPID BOOK>

how will those sets of quotes look in print? the ? are the moronic
redmondcodes for ". what about the outer "? fun for all typesetters.

BTW you will love this tom, much/most of chapter 16 is a copy of perldiag!!
is that a copyright problem?

we should all post reviews to amazon, etc and make this book sink like a 
stone as it deserves.

uri

-- 
Uri Guttman                             Hacking Perl for Ironbridge Networks
uri@sysarch.com				uri@ironbridgenetworks.com	


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

Date: Tue, 4 May 1999 22:19:46 +0200
From: "Genie" <gerbenhd@nederlands.com>
Subject: Please help me (nobody ever does :(
Message-Id: <7gnkj0$6ke$2@news.telekabel.nl>

Can somebody alter this script in a way that it doesnt display the FTP-URL
but
OPENS IT???

----

#!C:\PERL\BIN\PERL.EXE

use CGI param,header,p;

$user = param("Username");
$pass = param("Password");
print header();
print p("ftp://$user:$pass\@194.134.134.??");

----

THANX!

Genie





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

Date: 04 May 1999 16:11:53 -0400
From: Uri Guttman <uri@ibnets.com>
To: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Question: Updating an Array...
Message-Id: <39lnf4bnna.fsf@ibnets.com>

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

  LR> <39so9cbqvw.fsf@ibnets.com> on 04 May 1999 15:01:55 -0400, Uri
  LR> Guttman <uri@ibnets.com> says...

  >>  haven't you heard of slice either? it does exactly what the poster
  >> requested.

  LR> For the sake of sanity (mine, if no others' :-), I'll assume you
  LR> meant 'splice' in that sentence.  Let me introduce you to
  LR> 'agrep'...

you are insane anyway! pick on my typos will you!

and i'll have agrep and asort and abash and acut, etc.

uri

-- 
Uri Guttman                             Hacking Perl for Ironbridge Networks
uri@sysarch.com				uri@ironbridgenetworks.com	


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

Date: Tue, 04 May 1999 16:31:56 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Question: Updating an Array...
Message-Id: <linberg-0405991631560001@ltl1.literacy.upenn.edu>

In article <MPG.1198e601886666f09899b4@nntp.hpl.hp.com>, lr@hpl.hp.com
(Larry Rosler) wrote:

> > No.  Arrays are sequential.  You'll have to do some moving.
> 
> No, you don't have to.  You are *much* better off using splice.

My eyes popped out when I saw those results.  I had always assumed (my
old-school mentality is showing here) that it's faster in general to
construct a new list, rather than modify an existing one.

Does splice do some magic that makes it faster than slice in your
examples?  Or is it perhaps related to the overhead of creating Perl globs
when slicing?  I can't understand why splice is faster than concatenating
two slices - the only thing I can think is that it must be related to the
overhead of creating and allocating storage for the new slice.  If I were
doing this with a raw array of ints in C, say, my first instinct would be
to build a new list and then deallocate the first.

Thinking it over, I guess there actually isn't much sense to that;
shifting elements up or down isn't any faster than copying them
elsewhere.  I guess it's just an artifact of my general instinct to
preserve data and spawn new stuff rather than overwrite (and risk
breaking, in tough manual cases) existing data.

Hard to shake these old instincts.  I get grumpy when I have to work in C
now, it's so damn tedious.  Perl is really ruining me, in that sense.

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: 04 May 1999 20:04:22 GMT
From: skine <skine@ark-works.com>
Subject: Re: Question] 'use' and 'require' trouble
Message-Id: <19990505050422.100792101.1459008562@nn-tk003.ocn.ad.jp>

Hi, Andrew,

Andrew wrote:
>: I face an 'use' and 'require' related trouble.
>
>Actually, you're facing namespace troubles. Read all about it in
>perlmod...

Yes, I was confused with namespace.

>this is a little more tricky. Since help.pl is "first" required by
>Test1.pm, and require will only bring in a file once, $help here (in
>the context of the above scripts) refers to $Test1::help.

I understand! I carefully thought when and where namespace I am.
Thanks for your help, I will be able to get what I want to do, must
use $main::help.

Thanks for your advise!



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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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