[16846] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4258 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 8 09:05:27 2000

Date: Fri, 8 Sep 2000 06:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968418311-v9-i4258@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 8 Sep 2000     Volume: 9 Number: 4258

Today's topics:
    Re: CGI/perl    "open" (Ivan Lee)
        Changing ALL leading blanks to zero <EUSWMCL@am1.ericsson.se>
    Re: copying multidimensional arrays (Andrew J. Perrin)
        Date question?  Can't display English style? (Ivan Lee)
    Re: golf: remove .txt from filenames (Leo Schalkwyk)
    Re: golf: remove .txt from filenames <jeffp@crusoe.net>
    Re: how can I tell the internet speed of visitor nobull@mail.com
    Re: How to create a simple backup program? <indy@remove_this_indigostar.com>
    Re: How to delete line #1 <bcaligari@my-deja.com>
    Re: HTML::parse bug <T.Cockle@staffs.ac.uk>
    Re: HTML::parse bug <T.Cockle@staffs.ac.uk>
    Re: Is this a bug or a feature? <unicon@btconnect.com>
    Re: Last day of month <abe@ztreet.demon.nl>
    Re: last in a sub taking effect in caller <rick.delaney@home.com>
    Re: Perl & NT <bcaligari@my-deja.com>
    Re: The Heartbreak of Inscrutable Perl Code <mauldin@netstorm.net>
    Re: The Heartbreak of Inscrutable Perl Code alphazerozero@my-deja.com
    Re: use strict: why? <godzilla@stomp.stomp.tokyo>
    Re: use strict: why? mexicanmeatballs@my-deja.com
    Re: use strict: why? <bart.lateur@skynet.be>
    Re: using "|" as plain text in scripts (perl win) aqutiv@my-deja.com
        Variable not accepting value <dwb1@home.com>
        WGET equivalent (Chest Rockwell)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 08 Sep 2000 13:49:44 GMT
From: ginola@mailcity.com (Ivan Lee)
Subject: Re: CGI/perl    "open"
Message-Id: <39b8ee5f.1099087@news.alphalink.com.au>

sorry about that....this is first time I come here....
very sorry....I will read them now...

>ginola@mailcity.com (Ivan Lee) writes:
>
>> I have a line like below
>> open(GUESTBOOK_IN, "../view.html");
>> because the server of cgi is automatic link to the server only for
>> cgi, so is that possible to  do the
>> "http://hostname/~username/view.html"
>> instead of ../view.html
>
>Please see the last couple of dozen threads asking the question "Can I
>open a URL with open()?".  You shouldn't have to go back more than a
>week or two.
>
>Note: It is considered rude to come to a Usenet group and ask a
>question that has been dicussed recently.


**************************************
¯u ¸ô ®³ Ivan Lee
http://www.geocities.com/ginola79/
http://www.geocities.com/ivanlee79/


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

Date: Fri, 08 Sep 2000 08:51:30 -0400
From: William Cardwell <EUSWMCL@am1.ericsson.se>
Subject: Changing ALL leading blanks to zero
Message-Id: <39B8E0D2.3F042077@am1.ericsson.se>

What am I missing here?

$x='   ';
$x=~s/^ +/0/;
$y='  5';
$y=~s/^ +/0/;
print "$x, $y\n"; # I want: "000, 005". I'm getting "0, 05".

Thanks so much,

Will Cardwell


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

Date: 08 Sep 2000 08:49:52 -0400
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: copying multidimensional arrays
Message-Id: <ud7ifdp5b.fsf@demog.berkeley.edu>

Ralf Heydenreich <heydenreich@delta.de> writes:

> Hi,
> at first some code:
> 
> while($condition)
> {
> 	$index=0;
> 	@t=();
> 	push @t, $reftab, $schl;

Note that:
        @t = ($reftab, $schl);
would do just as well.

> 	push @{ $reftabs[$index++] }, @t;

Just so we're clear on what you're doing: @reftabs is an array of
references to arrays. You take the element of @reftabs pointed to by
$index + 1 (which is *always* 1, since $index is reset to 0 on each
iteration), then push ($reftab, $schl) onto that array.

Note, again, that:
	push @{ $reftabs[$index++] }, ($reftab, $schl);
would do just as well.

> }
> 
> Now I have the two-dimensional array $reftabs. 

No, from the code you show here, $reftabs is undefined. @reftabs is
defined though.

> But, for some reasons I
> have to pop the last element from reftabs and store it into another
> variable:
> 
> $e=pop(@reftabs);
> 

"Have to" meaning this is what you want to do.  Well, @reftabs is an
array of references to arrays, or more specifically, it's an array in
the form:
0  undef
1  [ $reftab,
     $schl,
	...
     $reftab,
     $schl
   ]

> The question now is: how can I get my elements from $e ? If I try
> something like print $e[0][0] I get an empty string.
> Could you explain why?
> 

So $e is $reftabs[1]. $e[0] is ... what? $e is a scalar, so $e[0] and
therefore $e[0][0] is undefined.  You either want to deref e by using
@$e or use arrow notation: $e->[0] will refer to the first $reftab; if
in fact that $reftab is a reference to an array, then $e->[0]->[0]
will refer to the first element of that array.

HTH.

> [RH]

-- 
----------------------------------------------------------------------
Andrew Perrin - Solaris-Linux-NT-Samba-Perl-Access-Postgres Consulting
       aperrin@igc.apc.org - http://demog.berkeley.edu/~aperrin
----------------------------------------------------------------------


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

Date: Fri, 08 Sep 2000 13:52:33 GMT
From: ginola@mailcity.com (Ivan Lee)
Subject: Date question?  Can't display English style?
Message-Id: <39b9eea1.1165503@news.alphalink.com.au>

I have the code like below

#!/usr/bin/perl
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime(time);
# $date =  $mon+1 . "/" . $mday . "/" . $year;
$date =  $mday . "/" . $mon+1 . "/" . $year;
print $date;       

the line start with # can display probably,
but when I exchange the date and month, it can't display 
the day, why is that?  moreover, in both case I display the 
year is "100" 
is that normal?

**************************************
¯u ¸ô ®³ Ivan Lee
http://www.geocities.com/ginola79/
http://www.geocities.com/ivanlee79/


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

Date: 8 Sep 2000 12:31:36 GMT
From: L.Schalkwyk@z138-234.iop.kcl.ac.uk (Leo Schalkwyk)
Subject: Re: golf: remove .txt from filenames
Message-Id: <slrn8rhn7k.3vu4s7n.L.Schalkwyk@leoschalkwyk.iop.kcl.ac.uk>

On 08 Sep 2000 01:04:36 GMT, Abigail <abigail@foad.org> wrote:
>Matthew Stoker (matt.stoker@motorola.com) wrote on MMDLXIV September
>MCMXCIII in <URL:news:39B81D87.C9C69276@motorola.com>:
>[] Larry Rosler wrote:
>[] > In article <39B6B137.8E8A5E7B@motorola.com> on Wed, 06 Sep 2000 14:03:51
>[] > -0700, Matthew Stoker <matt.stoker@motorola.com> says...
>[] > > Matthew Stoker wrote:
>[] > > > perl -e'/(.+)\.txt$/&&rename$_,$1for<*>' - Larry Rosler (syntax error)
>[] > Nonsense.  Of course it was tested (on both Unix and Windows NT -- with
>[] > double-quotes instead of single-quotes) and of course it works fine.
>
>No. "$1for" is wrong; there needs to be a space between $1 and for.

looks like it shouldn't, but it works for me!

bash-2.03$ perl -e'/(.+)\.txt$/&&rename$_,$1for<*>'
bash-2.03$ ls *txt
ls: *txt: No such file or directory
bash-2.03$ perl -v

This is perl, v5.6.0 built for cygwin-multi

-Leo




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

Date: Fri, 8 Sep 2000 08:53:07 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: golf: remove .txt from filenames
Message-Id: <Pine.GSO.4.21.0009080852000.23350-100000@crusoe.crusoe.net>

On Sep 8, Leo Schalkwyk said:

>On 08 Sep 2000 01:04:36 GMT, Abigail <abigail@foad.org> wrote:
>>Matthew Stoker (matt.stoker@motorola.com) wrote on MMDLXIV September
>>MCMXCIII in <URL:news:39B81D87.C9C69276@motorola.com>:
>>[] Larry Rosler wrote:
>>[] > In article <39B6B137.8E8A5E7B@motorola.com> on Wed, 06 Sep 2000 14:03:51
>>[] > -0700, Matthew Stoker <matt.stoker@motorola.com> says...
>>[] > > Matthew Stoker wrote:
>>[] > > > perl -e'/(.+)\.txt$/&&rename$_,$1for<*>' - Larry Rosler (syntax error)
>>[] > Nonsense.  Of course it was tested (on both Unix and Windows NT -- with
>>[] > double-quotes instead of single-quotes) and of course it works fine.
>>
>>No. "$1for" is wrong; there needs to be a space between $1 and for.
>
>looks like it shouldn't, but it works for me!

$1for does not follow the rules for a valid Perl variable, so Perl knows
it's "$1 for":

jeffp@friday [7:50am] ~ #162> perl -MO=Deparse
print$1for+split//;
- syntax OK
foreach $_ (split(//, $_, 0)) {
    print $1;
}

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/



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

Date: 08 Sep 2000 12:24:23 +0100
From: nobull@mail.com
Subject: Re: how can I tell the internet speed of visitor
Message-Id: <u9d7if2kk8.fsf@wcl-l.bham.ac.uk>

Denson Tang <nospam.tom@hotmail.com> writes:

> I want to know the internet speed connection of a website visitor, how 
> can I achieve that we PERL?

There are a few ways you could but discussion of their various merits
and flaws is unrelated to the choice of programming language.

Basically you either need to ask them the question directly or need to
send them a large file and time how long it takes.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 08 Sep 2000 12:57:53 GMT
From: "Indy Singh" <indy@remove_this_indigostar.com>
Subject: Re: How to create a simple backup program?
Message-Id: <ln5u5.15016$E_6.4291357@news3.rdc1.on.home.com>

Bart Lateur <bart.lateur@skynet.be> wrote in message
news:oe6frs4idd899ih8ukv4ktipghgnn88coq@4ax.com...
> monkfunk@my-deja.com wrote:
>
> >I really am forcing the perl thing I know.  I'm trying to learn it.  I
> >like it's string manipulation strengths.  I'm going to wrap the script
> >up with perl2exe.
>
> Do you need it to be in Perl? Otherwise, if on Unix, I'd try doing it
> with just tar. This program has interesting features, like backing up
> only files that have been changed since a certain date.
>
> Oops, that's right, "perl2exe" means that it's in Windows. So tar is
> out. Well, there's always Archive::Tar, that works on Windows too (it's
> even standard in the distribution on Windows). The disadvantage is that
> the whole decompressed archive needs to fit in memory all at once. But
> combining this module with File::Find, and you can pretty much do it.
> And, last but not least, this module, just like the tar program, has
> built-in gzip support.
>
> --
> Bart.

Actually, Perl2Exe supports Windows and Unix.  Perl2Exe can be found at
www.indigostar.com


--
Indy Singh
IndigoSTAR Software -- www.indigostar.com





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

Date: Fri, 08 Sep 2000 10:24:02 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: How to delete line #1
Message-Id: <8paenn$7tv$1@nnrp1.deja.com>

In article <39B8B5A3.DD2F206E@delta.de>,
  Ralf Heydenreich <heydenreich@delta.de> wrote:
> Mike Grimes schrieb:
> >
> > Howdy y'all,
> >
> > I would like to delete the first line of a log file. Is there an
expert who
> > could give me some advide on how I might accomplish this?
> >
> > I open a file for reading and writing, read each line and perform
some
> > operations then use seek to go back to the top of the file.
Truncate deletes
> > from the first line on. How can I then delete just the first line?
> >
> > Appreciate any help,
> > Mike
>
> perhaps you can try this:
>
> $firstflag=0;
> open(FILE, "< yourlogfile.log");
> open(NEWLOG, "> newlogfile.log");
> while(<FILE>)
> {
> 	next if( $firstflag++ == 0 );
> 	print NEWLOG $_;
> }
> close(NEWLOG);
> close(FILE);
>

for(<FILE>;<FILE>;) { print(NEWLOG); }
Brendon
++++


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


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

Date: Fri, 08 Sep 2000 11:48:07 +0100
From: Tim Cockle <T.Cockle@staffs.ac.uk>
To: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: HTML::parse bug
Message-Id: <39B8C3E6.A607B473@staffs.ac.uk>

I have tried it with out signals and the cash still occurs.

So I don't think it is signals, however when  I get back to my real program
I will try to remove the signals as you have suggested.

See code below:

use diagnostics;
use HTML::TokeParser;

my $token;
my $i = 1;

while  ($i < 5) {


   next if $pid = fork;
   die "fork: $!" unless defined $pid;

   my $fileName = "menu$i.html";
   my $p = HTML::TokeParser->new($fileName);
   while ($token = $p->get_tag("a")) {}

   print "done $fileName\n";


   exit();

} continue {

   $i++;

}


Thanks for your help

Tim

Bart Lateur wrote:

> Randal L. Schwartz wrote:
>
> >And further down in this thread, you post code that shows something in
> >a SIG handler other than $SIG{WHATEVER} = 'IGNORE'.
> >
> >You *will* experience crashes then.  Get used to it.  Signals
> >are not reliable, and this is the unreliablity. :)
> >
> >The bug is not in HTML::Parse.  Nothing to see here.  Move along. :)
>
> Randal is right. You need to find another approach, one that doesn't
> require the signals. If all else fails, double forking is what I would
> try. The parent launches a child, which in turn launches a grandchild,
> and exits. That doesn't take long, so the parent can just wait for it.
> And now everybody (parent and grandchild) can each safely go their own
> way.
>
> In some versions of perlfunc (not in my 5.6 distribution) the entry for
> fork() even contains a coding example:
>
>     <http://www.perl.com/pub/doc/manual/html/pod/perlfunc/fork.html>
>
> Here's what perlipc says:
>
>     On most Unix platforms, the `CHLD' (sometimes also known as `CLD')
>     signal has special behavior with respect to a value of `'IGNORE''.
>     Setting `$SIG{CHLD}' to `'IGNORE'' on such a platform has the effect
>     of not creating zombie processes when the parent process fails to
>     `wait()' on its child processes (i.e. child processes are
>     automatically reaped).
>     Calling `wait()' with `$SIG{CHLD}' set to `'IGNORE'' usually returns
>     `-1' on such platforms.
>
> So, if you're lucky, you needn't even bother.
>
> --
>         Bart.

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Mr. T. P. Cockle M.Sc. B.Sc. (hons) Pg.D.                 Ph.D.
Representative

Research (Distributed Computer Systems)
School of Computing,
Staffordshire University,
Stafford ST18 0DG.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





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

Date: Fri, 08 Sep 2000 12:11:00 +0100
From: Tim Cockle <T.Cockle@staffs.ac.uk>
Subject: Re: HTML::parse bug
Message-Id: <39B8C944.B72C5F3A@staffs.ac.uk>

Also I have noticed sometimes that when I slow it down (through debugging) it will
work.

I guess this may be a sharing  violation of some kind.

Tim





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

Date: Fri, 08 Sep 2000 13:59:07 +0100
From: john moylan <unicon@btconnect.com>
Subject: Re: Is this a bug or a feature?
Message-Id: <39B8E29B.5B5A1FEF@btconnect.com>

I can actually see where ellitfinlay@  is coming from..
I think he (like myself) is a beginner in Perl and is trial and erroring
his code and new code we learn.
I'm also a beginner to programming (Perl is my first language) and
getting your head around various concept which are now second nature to
you all are still hard to grasp at first.

Having troulbe with fathoming out   next; redo; last;  ,where to put
them and how to use them myself at the moment.

Any advice for a programming newbie would be gratefully received..
Still, enough from me...gonna go back to lurking now.

John Moylan

NYAPH  (not yet a)



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

Date: Fri, 08 Sep 2000 12:38:28 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Last day of month
Message-Id: <avehrs8bnj413so0c8jtp4feoi5sbmv6vb@4ax.com>

On Fri, 8 Sep 2000 01:49:19 -0500, "Andrew N. McGuire "
<anmcguire@ce.mediaone.net> wrote:

> On 8 Sep 2000, David Wall quoth:

 ...

> ~~ Here's one that Abe Timmerman (I think) posted some time ago.  Give it the 
> ~~ month and year and it returns the number of days in the month.

It actually returns the 'number' of the last day in the month. See
Andrew's objection.

> ~~ sub last_mday { #$month: 0..11; $year: CCYY
> ~~ 	my ($month, $year) = @_;
> ~~ 	( qw(31 0 31 30 31 30 31 31 30 31 30 31) )[$month] ||
> ~~ 		28 + (($year % 100 && !($year % 4))|| !($year % 400));
> ~~ }
> ~~ 
> ~~ Works for me.  
> 
> I am afraid this code is broken.
> 
> print &last_mday(8, 1752); # ;-)

Any solution based on timelocal() doesn't take that date to begin with.

-- 
Good luck,
Abe


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

Date: Fri, 08 Sep 2000 12:17:14 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: last in a sub taking effect in caller
Message-Id: <39B8DB49.7DF37CC9@home.com>

[posted & mailed]

Rajasankar wrote:
> 
> Hi,

Hi.
 
> The following code breaks the 'while' loop in the caller.
> Though the code is erroneous, the behavior looks odd.

Which is why it gives a warning.

> Can't perl handle it in a better way?

Like a compile-time error?

> Can't it just return from the function?
                ^^^^^^

That doesn't sound better.  If you want return, you know where to find
it.

[code snippage]

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Fri, 08 Sep 2000 10:29:27 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: Perl & NT
Message-Id: <8paf1r$87g$1@nnrp1.deja.com>

In article <39B88BD5.79F21814@pacific.net.hk>,
  Brian Leung <brianlk@pacific.net.hk> wrote:
> Hello all,
> Is it possible that someone can add user account by perl script in NT
4
> or win 2000?
> Thanks
>
> --
> Regards,
>
> Brian Leung
>
>

check the syntax for the NET command.

at the prompt try:
    c:\> net help user

you should be able to system() it.

Brendon



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


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

Date: Fri, 08 Sep 2000 11:20:14 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: The Heartbreak of Inscrutable Perl Code
Message-Id: <39B8CAC8.D0480C6A@netstorm.net>

Abe Timmerman wrote:
> 
> On 08 Sep 2000 00:32:06 GMT, abigail@foad.org (Abigail) wrote:
> 
> > Malcolm Dew-Jones (yf110@vtn1.victoria.tc.ca) wrote on MMDLXIV September
> > MCMXCIII in <URL:news:39b8168d@news.victoria.tc.ca>:
> > ""
> > "" Pasal programmers claim that I = I + 1 is clearer than I++;
> >
> > Really? A strange breed of Pascal programmers. I'd think they prefer
> >
> >     I = inc (I);
> 
> They might, but most compilers would disagree with them.
> 
>         I := inc(I);
> 

Nope.  inc() is a procedure, so just inc(I) does the trick.

-- Jim


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

Date: Fri, 08 Sep 2000 11:39:26 GMT
From: alphazerozero@my-deja.com
Subject: Re: The Heartbreak of Inscrutable Perl Code
Message-Id: <8paj5c$ch9$1@nnrp1.deja.com>

In article <slrn8rgcqc.vlt.abigail@alexandra.foad.org>,
  abigail@foad.org wrote:

> Really? A strange breed of Pascal programmers. I'd think they prefer
>
>     I = inc (I);

Forgive me for being pedantic, but in TP/Delphi anyway its simply

inc(i);

alphazerozero


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


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

Date: Fri, 08 Sep 2000 03:11:24 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: use strict: why?
Message-Id: <39B8BB4C.E3C24262@stomp.stomp.tokyo>

Ben Kennedy wrote:
 
> "Godzilla!" wrote:
> > Tim Hammerquist wrote:
> > > Ben Kennedy  wrote:
 
> > Globals are quicker because they are stashed into an array
> > which perl core can access easily. Not sure on 'local' style
> > variables. I suppose local variables might be slightly faster
> > than 'my' type variables. I would guess not enough to make
> > a real difference.
 
> You can only use local on global variables.

Really? Who would have ever guessed!

local my ($variable);

Heh heh hehhh..


> Variables that have been local()'ized are still global variables,

Nope! They are local variables. Global variables remain
the same. Local variables can be changed at whim and wish,
locally. Since when does local mean global?

Heh heh hehhh..


> ironically - 

Boy I'll say. All these slippery semantics
are ironically MULE MANURE!!!

Heh heh hehhh..


> perl temporarily stores the old value, and restores it when the block ends.

Are you sure this is what happens? Maybe a new variable
is created without any change to the global.

local = global
local = whatever you do to it
exit block .. local = gone!


> 'my' variables are faster because the are created from scratch
> and stored in a truly local space, and there is no overhead for
> saving and restoring another value.

MULE MANURE! Use of my declarations invokes all kinds
of added processing for perl core, especially in 
conjunction with strict. Globals sit up there like
a teacher's scribblings on a chalk board for all to
see. My declarations are students scribbling away
on their notebook paper, each and everyone, hopefully.
Lots of pencil pushing going on with my declarations.

 
> > Your tests are valid but only hint at a much bigger picture,
> > a rather different picture. Use of globals when possible,
> > leads to a much faster script than use of all my declarations.
> > This is good logic and, clearly substantiated by testing.
 
> The bigger picture isn't speed IMO, but a mix of speed, memory consumption,
> and maintainablity.  

Hmm... yeah.. my point is wise programmers will consider
what combination is best for a selected script. Around
here, 'bout all I read are Perl 5 Cargo Cultists wigging
out and screaming at everyone to ALWAYS use... whatever
mule manure they splattered at the moment. Pyschotic
ego masturbation it is, yes indeed.


> Code written with a generous use of globals is much
> easier to break and will have a bloated symbol table.

This is more than mule manure. This is MULE SHIT!

Saying globals are easier to break is like saying
guns kill people. Baloney! People kill people and
piss poor programmers break not only global variables
but break programs as well.

Bloated symbol table... * rolls eyes *

Do you rehearse this BS or make it up as you along?


> Code written with a generous amount of 'my's tends to be
> more self-contained, and is easier to integrate with 
> other programs.

More mule manure! My declarations are a pain. A programmer
has to be very careful when and where to use them. Use
of my declarations, incorrectly, can crash a program
quicker than you can flick a booger.

Easier to integrate? You are nuts! Go on. Declare your
routine output a my variable, then try to incorporate
this routine into another larger program and see what
happens! BLANK! Nothing happens. You have to back up
and change your enclosed routine output to local or
global or declare your output as a 'my global', then
curse like crazy cause pragma hints crap all over!


> > Use of pragma hints, use of strict, use of modules and use
> > of my declarations, all should be used wisely and not
> > proposed as an anal retentive must do absolute rule.
 
> A signifigant portion of questions in this group would not
> have been asked if the OP had been using strict or warnings.
> But a person posts broken code here, and they haven't tried
> it with strict or warnings, then they shouldn't be doing it.
> There is nothing wrong with encouraging new users to use all
> the diagnostic tools available to them.  I don't think it 
> should be an absolute rule for all programming, but it should
> be an absolute rule if you are seeking help from people on 
> this group.


Qualified, this does not apply to all but rather most:

Stereotypical Perl 5 Cargo Cultist Obsessive Techno-Geekster
Deep In Denial Mule Manure. I read this baloney way too much!
What's wrong with you boys you cannot simply be honest and
upfront? Every chance you get, warnings and strict are used
as an excuse to humiliate and harass others. Shirley you haven't
forgotten how you bozos yelled and screamed at me about pragma
hints, spewed insults, engaged in name calling, all kinds of
sociopathic cretin crap, for months on end until it finally
dawned upon you I ignore your idiotic rants, unless your rants
go way over the line. This is pure denial baloney. Archives 
reflect a completely different truth than these lies you
boys tell, with great impotency and ignorance.

Now this is ironic! You boys sit there and make up all
these AOL lame brain excuses, make up mule manure lies,
and never realize archived articles show you to be the
liars and cretins you are truly. Meanwhile, I give
people realistic honest advice so they can make
informed choices on what they want to do. I give
choices, not your petty dictator promulgation.

-w and use strict = a chance to spread hatred.


Godzilla!
-- 
Gypsy Wildrose Pawnee - Fortune Teller
  http://la.znet.com/~callgirl/fortune.cgi


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

Date: Fri, 08 Sep 2000 11:28:38 GMT
From: mexicanmeatballs@my-deja.com
Subject: Re: use strict: why?
Message-Id: <8paigp$bt1$1@nnrp1.deja.com>

In article <39B8BB4C.E3C24262@stomp.stomp.tokyo>,
  "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> Ben Kennedy wrote:
>

<snip>

> > 'my' variables are faster because the are created from scratch
> > and stored in a truly local space, and there is no overhead for
> > saving and restoring another value.
>
> MULE MANURE! Use of my declarations invokes all kinds
> of added processing for perl core, especially in
> conjunction with strict. Globals sit up there like
> a teacher's scribblings on a chalk board for all to
> see. My declarations are students scribbling away
> on their notebook paper, each and everyone, hopefully.
> Lots of pencil pushing going on with my declarations.

[jbarker@ninetyseven test]$ cat ./bench.pl
#!/usr/bin/perl -w
use Benchmark;
timethese(1000000,
          {
              'My' => sub {
                  my ($a, $b, $c, $d, $e);
                  $a++;
                  $b++;
                  $c++;
                  $d++;
                  $e++;
              },
              'Local' => sub {
                  local ($a, $b, $c, $d, $e);
                  $a++;
                  $b++;
                  $c++;
                  $d++;
                  $e++;
              }
          } );
exit;
[jbarker@ninetyseven test]$ ./bench.pl
Benchmark: timing 1000000 iterations of Local, My...
     Local:  7 wallclock secs ( 7.21 usr +  0.02 sys =  7.23 CPU)
        My:  6 wallclock secs ( 5.26 usr +  0.01 sys =  5.27 CPU)
[jbarker@ninetyseven test]$

Looks like my takes 72% of the time that local does. It probably
depends on what you do with your variables though, if you declare
them and increment them then local is slower.

--
Jon
perl -e 'print map {chr(ord($_)-3)} split //, "MrqEdunhuClqdph1frp";'


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


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

Date: Fri, 08 Sep 2000 12:25:25 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: use strict: why?
Message-Id: <efmhrs4mun8rf4bqbfp9m2r7s74v1tk36j@4ax.com>

Godzilla! wrote:

>> Variables that have been local()'ized are still global variables,
>
>Nope! They are local variables. Global variables remain
>the same. Local variables can be changed at whim and wish,
>locally. Since when does local mean global?

They are global. Only: the value adssigned to it is temporary. Once you
leave the block where the variable is localized, the old value is
restored.

	$x = "global";
	&test;
	{
	   local $x = "local";
	   &test;
	}
	&test;

	sub test {
	    print "The value of the variable \$x is \"$x\"\n";
	}
-->
	The value of the variable $x is "global"
	The value of the variable $x is "local"
	The value of the variable $x is "global"

In summary: it's the same variable. Therefore, it is a global variable.

-- 
	Bart.


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

Date: Fri, 08 Sep 2000 09:55:48 GMT
From: aqutiv@my-deja.com
Subject: Re: using "|" as plain text in scripts (perl win)
Message-Id: <8pad2v$66n$1@nnrp1.deja.com>

In article <39B8AE9F.31140C02@bmjgroup.com>,
  Kourosh A Mojar <kmojar@bmjgroup.com> wrote:
> dear all,
>
> im been trying to use "|" (pipe?) as pain text for creating flat
> database files. but does not allow my scripts to work properly. ive
> tried \| to try and cancel its command features but unsuccessful. i
> haven't found any examples in books and was hoping someone could give
me
> a quick fix. can any one advise me on what is the best way to do this.
>
> thanking you in advance and for your kind attention,
>
> kourosh a mojar
>

What was the exact line you used??
You need to paste that in such sitautations, you know...

@fields = split /\|/, $line; #works fine

in any case... The same char might be used inside the fields,
so parhaps you'll want to use something longer, such as ':x:'.


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


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

Date: Fri, 08 Sep 2000 10:07:40 GMT
From:  <dwb1@home.com>
Subject: Variable not accepting value
Message-Id: <Pine.LNX.4.20.0009080515290.12387-100000@ethyl.addictmud.org>



Hello,

I'm having problems occasionally with variables not accepting a value.

for example, in the function below, "$in{QUESTION_PATH}" will not accept
the blank value so that the string can be re-built.  As a result, the
variable is now twice as long instead of a couple characters smaller.

The values of $in{QUESTION_PATH} is a string of numbers, seperiated by
a ctrl-a character (for a web form).  The function is supposed to remove
the last value in the string, and return the value it removed.  I'm sure
this could be done a lot easier with a regular expression, but this is
what I have right now :)

sub RemoveLastQuestion
{
	my @path = split(/^A/, $in{QUESTION_PATH});
	$in{QUESTION_PATH} = '';

	for (my $i = 0; $i < $#path; $i++) {
		if (length($path[$i]) > 0) {
			$in{QUESTION_PATH} .= "^A" . $path[$i];
		}
	}
	return $path[$#path];
}


I rewrote the function like this, and it works, but my problem is, this
is not the first time I've seen this, in perl 5.005 as well as 5.6 btw,
and I'm afraid it's going to show up again, so I'm looking for the cause
or at least an explaination so that I can look for them before someone
reports another script that's not working right.  (when these scripts
were used in perl4 up until last year, I had never seen such a problem).

sub RemoveLastQuestion
{
	my @path = split(/^A/, $in{QUESTION_PATH});
	my $tmp = "";  # XXXXXXXXXXXX -- change

	for (my $i = 0; $i < $#path; $i++) {
		if (length($path[$i]) > 0) {
			$tmp .= "^A" . $path[$i];  # XXXXXXXXXXXX -- change
		}
	}
	$in{QUESTION_PATH} = $tmp;  # XXXXXXXXXXXX -- change
	return $path[$#path];
}

Any insight would be greatly appreciated.

Dan.




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

Date: Fri, 08 Sep 2000 13:01:49 GMT
From: haaaajo@removethis.dds.nl (Chest Rockwell)
Subject: WGET equivalent
Message-Id: <39b8e312.16354562@news.wirehub.nl>

Hi there,

Is there a perl mod that functions like the WGET command?

Cheers,

Chest


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


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


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