[19423] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1618 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 26 14:05:32 2001

Date: Sun, 26 Aug 2001 11:05:07 -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: <998849107-v10-i1618@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 26 Aug 2001     Volume: 10 Number: 1618

Today's topics:
    Re: $1 as subroutine parameter - problems <markus.laire@usa.net>
    Re: $1 as subroutine parameter - problems <markus.laire@usa.net>
    Re: $1 as subroutine parameter - problems (Randal L. Schwartz)
        Bug and Fix in Carp::Heavy.pm (Yves Orton)
        Error: "BEGIN not safe after errors" <news@N.O.--.S.P.A.M.andrew.dabsol.co.uk>
    Re: Error: "BEGIN not safe after errors" (Tad McClellan)
        expired Linux accounts check program in Perl <radiotito@yahoo.com>
        How to read from and write to binary file contains C st <eizners@lantic.co.za>
    Re: How to read from and write to binary file contains  <ilya@martynov.org>
    Re: Is element in array (Yves Orton)
    Re: need help with regexp... (Larry A Barowski)
    Re: Need Perl module or regexp to slurp specific XML re <dans@chiark.greenend.org.uk>
    Re: No HTML submitted via form (Randal L. Schwartz)
        perl2exe! exe2perl? (Andreas Schwarz)
    Re: perl2exe! exe2perl? <wsegrave@mindspring.com>
    Re: Problems with fixed-length random access databases. <dscarlett@optushome.com.au>
    Re: Problems with fixed-length random access databases. <pne-news-20010826@newton.digitalspace.net>
    Re: Sex or Perl?  Which is better? (Tad McClellan)
    Re: Sex or Perl?  Which is better? <kevin@vaildc.net>
    Re: simple question im sure <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Telnet front-end <agm@physics.berkeley.edu>
    Re: Telnet front-end <agm@physics.berkeley.edu>
    Re: Telnet front-end <Tassilo.Parseval@post.rwth-aachen.de>
    Re: warnings with cgi will crash Win32 perl core <jbc@west.net>
    Re: warnings with cgi will crash Win32 perl core (Yves Orton)
    Re: warnings with cgi will crash Win32 perl core <godzilla@stomp.stomp.tokyo>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 26 Aug 2001 14:17:28 GMT
From: Markus Laire <markus.laire@usa.net>
Subject: Re: $1 as subroutine parameter - problems
Message-Id: <Xns9109AFEFB827markuslaire@192.89.123.233>

Bart Lateur <bart.lateur@skynet.be> wrote in
news:l6fhot065nkk90ep6k511kdjb4u9n59go2@4ax.com: 

> Markus Laire wrote:
>>sub test($) {
>>  $_[0] =~ /(...)/;
>>  print "Begin: $1 of $_[0]\n"; }
> 
> That's not "optimised an tight". Even though you make no copy of the
> original argument, you do "calculate" the index of the argument (0),
> and get that element from the array, twice. A straight scalar likely is
> faster. A bit.
> 
> Yes, you do look like you're searching into micro-optimizations. As
> Abigail would say: if execution speed matters that much to you, you
> shouldn't be using Perl.
> 

Actually I don't mind about speed so much. I just like to write as tight 
(and optimized) code as I can, as far as it's still readable.

I thought that test(my $temp = $1) is too long to be nice perl so I was 
thinking a way to make it shorter. test("$1") is nice.


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

Date: Sun, 26 Aug 2001 14:22:31 GMT
From: Markus Laire <markus.laire@usa.net>
Subject: Re: $1 as subroutine parameter - problems
Message-Id: <Xns9109B0CAE981Fmarkuslaire@192.89.123.233>

Samneric <samneric@tigerriverOMIT-THIS.com> wrote in
news:MPG.15f22a059cb3a5c998969a@news.onemain.com: 

> And you're doing all this just to extract/print the first 3 characters
> of a string...

As I said, that example was only to illustrate the problem. Actual code is 
too large to post so I made small example which shows main points of the 
problem.


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

Date: 26 Aug 2001 07:25:32 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: $1 as subroutine parameter - problems
Message-Id: <m1ae0msxsz.fsf@halfdome.holdit.com>

>>>>> "Markus" == Markus Laire <markus.laire@usa.net> writes:

Markus>   $_[0] =~ /(...)/;
Markus>   print "Begin: $1 of $_[0]\n";

In addition to whatever anyone else has said in this thread, THIS CODE
IS DANGEROUS.  I'd flag this as "must fix" in a code review.

You do not know if the regex matched or not.  If it didn't match, the
$1 you're staring at is the $1 from the *previous* match.  This could
be a leak for a coding error, or worse, a potential security
violation.

Never use $1 unless you are sure *where it came from*.

print "Just another Perl hacker," # and professional code reviewer!

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 26 Aug 2001 10:16:58 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Bug and Fix in Carp::Heavy.pm
Message-Id: <74f348f7.0108260916.569497a9@posting.google.com>

Hello.

I have identified a minor bug in Carp::Heavy.pm.

If a class has overloaded the "" operator and it also uses Carp then
when calling carp/croak the object reference will be stringified by
carp.  This also can lead to deep recursion if the stringify routine
also calls cluck/confess.

Example:
#!perl
package TestCarp;
use Carp qw(carp cluck);
use strict;
use warnings;
use overload qw("" stringify);

sub stringify {
	carp "! In stringify !";
	#cluck "! In stringify !";
	${$_[0]};
}

sub new { my $c=shift; my $s=join("",@_); return bless \$s,$c};
1;
print "Testing Carp...\n";
my $t=__PACKAGE__->new("Testing!");
print $t;

__END__

Outputs when run:
D:\Development\Perl\Scratch>testcarp.pl
Testing Carp...
! In stringify ! at E:/Perl/lib/Carp/Heavy.pm line 90
! In stringify ! at D:\Development\Perl\Scratch\TestCarp.pl line 9
        TestCarp::stringify('Testing!', undef, '') called at
D:\Development\Perl\Scratch\TestCarp.pl line 20
Testing!
D:\Development\Perl\Scratch>

And if the carp line is commented out and the cluck line uncommented
you get:
D:\Development\Perl\Scratch>testcarp.pl
Testing Carp...
Deep recursion on subroutine "Carp::cluck" at
D:\Development\Perl\Scratch\TestCarp.pl line 10.
^C
D:\Development\Perl\Scratch>

Obviously the problem is in line 90 of Carp\Heavy.pm (Neither Carp.pm
or Carp\Heavy.pm have version numbers so thats all I can say) The code
and fix are as follows (line numbers added at left of | symbol):

16|# This package is heavily used. Be small. Be fast. Be good.
17|

89|			# force reference to string representation
90|			$_.="";

Should be changed to 

16|# This package is heavily used. Be small. Be fast. Be good.
17|use overload; # sorry, no choice 

89|			# force reference to string representation
90|			$_=overload::StrVal($_);

After these changes we get the predictable outputs:
D:\Development\Perl\Scratch>testcarp.pl
Testing Carp...
! In stringify ! at D:\Development\Perl\Scratch\TestCarp.pl line 9
        TestCarp::stringify('TestCarp=SCALAR(0x1abaeec)', undef, '')
called at D:\Development\Perl\Scratch\TestCarp.pl line 20
Testing!
D:\Development\Perl\Scratch>

and 
D:\Development\Perl\Scratch>testcarp.pl
Testing Carp...
! In stringify ! at D:\Development\Perl\Scratch\TestCarp.pl line 10
        TestCarp::stringify('TestCarp=SCALAR(0x1abaeec)', undef, '')
called at D:\Development\Perl\Scratch\TestCarp.pl line 20
Testing!
D:\Development\Perl\Scratch>


I understand the intention is to make Carp as light as possible but it
would seem overload::StrVal is essential to avoid this bug.  I dont
know if the perl community would agree but maybe the change should be
made to the standard distro.

As a second point, I have often wondered why there arent published
interfaces into Carp.pm so that we dont have to die/warn their
results, but perhaps use them in some other way. I suppose that
Carp::shortmess and Carp::longmess is ok, but I thought that perhaps
'chirp' and 'confide' might fit in with the 'c' word motif :-)
chirp/carp/croak confide/cluck/confess better.

Cheers all,
Yves


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

Date: Sun, 26 Aug 2001 16:26:01 +0100
From: "Andrew Smith" <news@N.O.--.S.P.A.M.andrew.dabsol.co.uk>
Subject: Error: "BEGIN not safe after errors"
Message-Id: <20010826153008.7964241A.NOFFLE@tau.andrewsmith.plus.com>

Hi

I have downloaded a perl script (source at end of message) although when I
try to execute it i get the following output:

Global symbol "$NAME" requires explicit package name at ./hc.pl line 23.
Global symbol "$VERSION" requires explicit package name at ./hc.pl line 23.
Global symbol "$COPYRIGHT" requires explicit package name at ./hc.pl line
23.
BEGIN not safe after errors--compilation aborted at ./hc.pl line 29.

Is this a configuration problem? How can I fix it?

Many Thanks,


Andrew Smith


------------------ First 50ish lines from hc.pl ----------------------
#!/usr/bin/perl

########################################################################
#      Happy Camper v0.6 Copyright 1999-2001 by Kyle Sallee            #
#      distributed under the terms of this GNU                         #
#      General Public License                                          #
########################################################################


BEGIN {
  use strict;
  use LWP;

  our($NAME, $VERSION, $COPYRIGHT);

  $NAME       = 'Happy Camper';
  $VERSION    = 0.6;
  $COPYRIGHT  = "Copyright (c) 1999-2001 by Kyle Sallee
<cromwell\@kublai.com>\n";
  $COPYRIGHT .= "distributed under the terms of the GNU GPL 2.0\n";
}


########################################################################
# Setting up the global variables                                      #
########################################################################

# Look for the config file happycamper.conf in ~/.hc and /etc and run it
# when found.
{
  package happycamper::conf;
  local @INC = map(glob, qw(~/.hc/ /etc/));

  my $conf_file = __PACKAGE__;
  $conf_file =~ s/::/./g;
  no strict 'vars';
  do(lc($conf_file));

  sub get_value($;$) {
    no strict 'refs';

    my($var_name, $default_value) = (@_, undef);
    $var_name = __PACKAGE__ . '::' . $var_name;

    return defined(${$var_name}) ? ${$var_name} : $default_value;
  }
}
my $get_conf_value = \&happycamper::conf::get_value;





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

Date: Sun, 26 Aug 2001 11:11:50 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Error: "BEGIN not safe after errors"
Message-Id: <slrn9oi4dm.lu5.tadmc@tadmc26.august.net>

Andrew Smith <news@N.O.--.S.P.A.M.andrew.dabsol.co.uk> wrote:

>I have downloaded a perl script (source at end of message) although when I
>try to execute it i get the following output:
>
>Global symbol "$NAME" requires explicit package name at ./hc.pl line 23.
>Global symbol "$VERSION" requires explicit package name at ./hc.pl line 23.
>Global symbol "$COPYRIGHT" requires explicit package name at ./hc.pl line
>23.

>Is this a configuration problem? 


No. It is a perl-version problem (I'd guess).


>How can I fix it?


our() was introduced in perl 5.6 you appear to have an earlier version
of perl. 

One way to fix it would be to upgrade your perl.

Another way would be to change our() to the "old way" of
declaring dynamic variables, "use vars".

   perldoc vars


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 26 Aug 2001 19:40:52 +0200
From: Valentin 30IR976 <radiotito@yahoo.com>
Subject: expired Linux accounts check program in Perl
Message-Id: <3B8934A4.4BAB2F80@yahoo.com>

I am writing a Perl program to check my Linux system with shadow
password installed. I think I must check the /etc/shadow file, with
something like:

($field1,$field2,...)=split(..) -->extract the different fields from
shadow file with ':' as separator.

But, I think I should make some calculus to check if an account has
expired, but...what calculus?

Thanks in advance

Valentin



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

Date: Sun, 26 Aug 2001 18:01:31 +0200
From: "Sergey Eizner" <eizners@lantic.co.za>
Subject: How to read from and write to binary file contains C structures in Perl.
Message-Id: <9mb6o2$jjp$1@ctb-nnrp2.saix.net>

Hello!
I need help.
How can I read from and write to binary file contains C structures.
Thank you!






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

Date: 26 Aug 2001 20:24:16 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: How to read from and write to binary file contains C structures in Perl.
Message-Id: <874rqupz67.fsf@abra.ru>

>>>>> On Sun, 26 Aug 2001 18:01:31 +0200, "Sergey Eizner" <eizners@lantic.co.za> said:

SE> Hello!
SE> I need help.
SE> How can I read from and write to binary file contains C structures.
SE> Thank you!

Use pack and unpack. See 'perldoc -tf pack' and 'perldoc -tf unpack'.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: 26 Aug 2001 07:50:36 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: Is element in array
Message-Id: <74f348f7.0108260650.607a6c3a@posting.google.com>

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message news:<3B830CFA.EF08323F@stomp.stomp.tokyo>...
> Guy wrote:
>  
> > How can test a scalar to see if it is an element in a given array?
> 
> (snipped)
> 
> 
> I am amused by responses to this article.

As am I by yours, Lizard.  Why are you still pimping this crap? 

The numbers speak for themselves:

For unordered data use a sequential scan if you cant use a hash.

Yves

#!perl
use strict;
use warnings;
use Benchmark 'cmpthese';

#The Array to search...
my @Array = qw (One Thirteen Twenty Two Eight Eleven Nineteen Three);

#Precalculated Hash of @Array
my %Hash;
map {
 	$Hash{$Array[$_]}->{count}++; #how many
  	$Hash{$Array[$_]}->{$_}++;    #and where
    } (0..$#Array);

#Precalculated stringification of @Array
$"=' '; #No element in @Array may have $" in it anywhere for index()
my $Cache=$"."@Array".$";


print "Searching \@Array['".join("', '",@Array)."']\n";
for (qw(One Two Three Four)) {
    print "for '$_':\n";
    Time(5_000_000,$_);
}

sub Time {
  my $count=shift;
  my $findstr=shift;


  cmpthese ($count,{
            'index' =>sub  {
		      	if (index ($"."@Array".$", $".$findstr.$") > -1)
			  { return $findstr }
			else
			  { return }
		     },
	    'cached'=>sub {
	    	        return $findstr
	    	           if index ($Cache, $".$findstr.$") > -1;
			return
			},
	    'scan ' =>sub{
		        $_ eq $findstr && return $_
				for (@Array);
			return
		     },
	    'hash ' =>sub{
	                return $findstr if exists($Hash{$findstr});
	                return
	              }
	} );
}

__END__
[Edited for readability]
Searching @Array['One', 'Thirteen', 'Twenty', 'Two', 'Eight',
'Eleven', 'Nineteen', 'Three']

for 'One':
Benchmark: timing 5000000 iterations of cached, hash , index, scan ...
    cached: 10 wallclock secs ( 8.87 CPU) @ 563507.27/s (n=5000000)
     hash :  4 wallclock secs ( 3.10 CPU) @ 1615508.89/s (n=5000000)
     index: 36 wallclock secs ( 35.12 CPU) @ 142364.97/s (n=5000000)
     scan :  9 wallclock secs ( 9.71 CPU) @ 514721.02/s (n=5000000)
            Rate  index  scan  cached  hash
index   142365/s     --   -72%   -75%   -91%
scan    514721/s   262%     --    -9%   -68%
cached  563507/s   296%     9%     --   -65%
hash   1615509/s  1035%   214%   187%     --

for 'Two':
Benchmark: timing 5000000 iterations of cached, hash , index, scan ...
    cached: 11 wallclock secs (10.55 CPU) @ 474113.41/s (n=5000000)
     hash :  2 wallclock secs ( 3.19 CPU) @ 1564945.23/s (n=5000000)
     index: 36 wallclock secs (36.54 CPU) @ 136825.11/s (n=5000000)
     scan : 19 wallclock secs (20.04 CPU) @ 249513.45/s (n=5000000)
            Rate  index  scan  cached  hash
index   136825/s     --   -45%   -71%   -91%
scan    249513/s    82%     --   -47%   -84%
cached  474113/s   247%    90%     --   -70%
hash   1564945/s  1044%   527%   230%     --

for 'Three':
Benchmark: timing 5000000 iterations of cached, hash , index, scan ...
    cached: 12 wallclock secs (12.42 CPU) @ 402641.33/s (n=5000000)
     hash :  4 wallclock secs ( 3.24 CPU) @ 1545595.05/s (n=5000000)
     index: 37 wallclock secs (38.19 CPU) @ 130910.61/s (n=5000000)
     scan : 34 wallclock secs (34.33 CPU) @ 145649.45/s (n=5000000)
            Rate  index  scan  cached  hash
index   130911/s     --   -10%   -67%   -92%
scan    145649/s    11%     --   -64%   -91%
cached  402641/s   208%   176%     --   -74%
hash   1545595/s  1081%   961%   284%     --

for 'Four':
Benchmark: timing 5000000 iterations of cached, hash , index, scan ...
    cached: 12 wallclock secs (11.13 CPU) @ 449438.20/s (n=5000000)
     hash :  3 wallclock secs ( 2.40 CPU) @ 2079866.89/s (n=5000000)
     index: 39 wallclock secs (39.47 CPU) @ 126688.12/s (n=5000000)
     scan : 41 wallclock secs (40.06 CPU) @ 124819.01/s (n=5000000)
            Rate  scan   index cached  hash
scan    124819/s     --    -1%   -72%   -94%
index   126688/s     1%     --   -72%   -94%
cached  449438/s   260%   255%     --   -78%
hash   2079867/s  1566%  1542%   363%     --


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

Date: 26 Aug 2001 11:03:27 -0700
From: larrybar@eng.auburn.edu (Larry A Barowski)
Subject: Re: need help with regexp...
Message-Id: <76e741cc.0108261003.2d37afc2@posting.google.com>

> 
> Thanks Larry, and thanks also for the very nice tool you created
> (Grasp).
> 
> Curiosly, altough the expression passes the test (OROMatcher), it does
> not work on Jgrasp (prefix adjusted to 1f).
> 

    Maybe there were some whitespace changes during cut-and-paste -
like tabs converted to spaces. jGRASP uses OROMatcher, so the
expression evaluation should be the same.

    Anyway, there is also a regular expression tester in jGRASP,
under the Control Panel "Tools" menu.


-Larry


> I ended up using successfuly:
>              1f-(?:.*IN LINE (\d+) OF (\S+|[A-Z]:[^:]+):.*)
> 
> John


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

Date: 26 Aug 2001 18:32:29 +0100 (BST)
From: Dan Sheppard <dans@chiark.greenend.org.uk>
Subject: Re: Need Perl module or regexp to slurp specific XML records
Message-Id: <H5i*RYK4o@news.chiark.greenend.org.uk>

M.L. <mel2000@hotmaildot.com> wrote:
>Given the following fixed XML records format:
>
><record id="0128">
>  <name>John Doe</name>
>  <address>123 Main St.</address>
>  <city>Lake Elsinore</city>
>  <state>CA</state>
>  <phone>(123) 456-7890</phone>
>  <zip>12345</zip>
>  <email>jd@domain.com</email>
></record>
>
>I don't want to slurp the entire database, just those records (and their
>child elements) where, for example, <state> = NY

This is /so/ XSLT. You can use XSLT to reduce the database to the
records you want and then do a slurp in with a simple perl program.

Is there some XSLT jiggery-pokery available for perl? (don't ask me,
I'm a C man whien it comes to XML). Do you actually want to leave the
XML/HTML domain with your script? If not it probably makes sense to do
your transform entirely within XSLT.

Frex, the following XSLT will create a mini-database containing only
New-Yorkers.

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="record" priority="-1"/>
  <xsl:template match="*[ancestor-or-self::record/state=&quot;NY&quot;]">
    <xsl:copy>
      <xsl:apply-templates select="*|@*"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

(Perhaps there's a better match in efficiency terms than a * with a
whacking great predicate, but I wouldn't trust myself to get it right
without trying the thing out).

It's becoming increasinly practical to do all your work on a projecti
n the XML domain. Whether it's a good idea in terms of efficiency is
another matter but, much as I hate to say it, for most companies
computers are cheaper than programmers. I'm looking for a job in this
field at the moment which pays about 8PCs a year, and I'm cheap. :)

Dan.
-- 
http://www.chiark.greenend.org.uk/ucgi/~dans/story


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

Date: 26 Aug 2001 06:45:57 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: No HTML submitted via form
Message-Id: <m1u1yvrl2i.fsf@halfdome.holdit.com>

>>>>> "Alexey" == Alexey Lysenkov <a_pop@my-deja.com> writes:

Alexey> Though it will be programmed with ColdFusion ;), the idea is
Alexey> cool. Thanks a lot!

Why did you ask about ColdFusion in a Perl group?  Loser.

*plonk*

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 26 Aug 2001 13:28:02 GMT
From: andreas-s@web.de (Andreas Schwarz)
Subject: perl2exe! exe2perl?
Message-Id: <Xns91099DF45B128andreasswebde@130.133.1.4>

Hello,

is there a possibility to convert exe-files made by perl2exe back to perl-
files?

THX
Andreas

-- 
www.mikrocontroller.net
AVR-Tutorial, Forum und Linkliste
Suchmaschine für 4800 Mikrocontrollerseiten


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

Date: Sun, 26 Aug 2001 12:44:34 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: perl2exe! exe2perl?
Message-Id: <9mbd66$e22$1@slb4.atl.mindspring.net>

"Andreas Schwarz" <andreas-s@web.de> wrote in message
news:Xns91099DF45B128andreasswebde@130.133.1.4...
> Hello,
>
> is there a possibility to convert exe-files made by perl2exe back to perl-
> files?
>
> THX
> Andreas
>
> --
> www.mikrocontroller.net
> AVR-Tutorial, Forum und Linkliste
> Suchmaschine für 4800 Mikrocontrollerseiten

Try support@indigostar.com or www.indigostar.com .

Bill Segraves
Auburn, AL




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

Date: Sun, 26 Aug 2001 13:08:54 GMT
From: "David Scarlett" <dscarlett@optushome.com.au>
Subject: Re: Problems with fixed-length random access databases.
Message-Id: <Gx6i7.23063$A5.70646@news1.eburwd1.vic.optushome.com.au>

"gnari" <gnarinn@hotmail.com> wrote in message
news:998828196.696412585210055.gnarinn@hotmail.com...
> In article <yo1i7.22829$A5.70124@news1.eburwd1.vic.optushome.com.au>,
> David Scarlett <dscarlett@optushome.com.au> wrote:
>
> >open(DB,"+>>ping.dat") || die "Error: Cannot open ping.dat. $!\n";
>
> you should read the docs for open again
> the mode '+>>' is not mentioned
> maybe you wanted '+<'

It's in the Llama 2ed, from page 173:
open(E,"+>>f"); # open or create file f with read/write access


--
David Scarlett
dscarlett@optushome.com.au
http://www.listen.to/artifice/
http://members.optushome.com.au/dscarlett/

"Damn it, Kif, where's the little umbrella? That's what makes it a scotch on
the rocks!"
        -Capt. Zapp Brannigann, Futurama




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

Date: Sun, 26 Aug 2001 15:26:31 +0200
From: Philip Newton <pne-news-20010826@newton.digitalspace.net>
Subject: Re: Problems with fixed-length random access databases.
Message-Id: <05uhotkev7ufm3kra3gi6q13r70lvjck9r@4ax.com>

On Sun, 26 Aug 2001 12:16:36 +0000, gnari <gnarinn@hotmail.com> wrote:

> In article <yo1i7.22829$A5.70124@news1.eburwd1.vic.optushome.com.au>,
> David Scarlett <dscarlett@optushome.com.au> wrote:
> 
> >open(DB,"+>>ping.dat") || die "Error: Cannot open ping.dat. $!\n";
> 
> you should read the docs for open again

Yep -- perlopentut has a whole lot about different open modes.

> the mode '+>>' is not mentioned
> maybe you wanted '+<'

He probably did, though for different reason. AIUI, +>> means "open for
reading and appending; create a file if it doesn't already exist but
don't overwrite an existing file". Note that with >>, all writes go to
the end of the file, as you noticed (and as is discussed in
perlopentut).

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Sun, 26 Aug 2001 08:59:03 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Sex or Perl?  Which is better?
Message-Id: <slrn9ohskn.lfd.tadmc@tadmc26.august.net>


[ piggybacked 'cause OP cannot be found ]


Brendon Caligari <bcaligari@fireforged.com> wrote:
>"None" <pohanl@aol.com> wrote in message
>news:12124e47.0108251948.44fc310f@posting.google.com...
>> In the beginning there was sex.  Then came Perl.
>> Which is better? 

>> Well, which is better?  Sex or Perl?


Always enable warnings and strictures in Perl.

Unprotected Perl is a dangerous gamble in today's world.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 26 Aug 2001 11:01:14 -0400
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: Sex or Perl?  Which is better?
Message-Id: <260820011101145764%kevin@vaildc.net>

In article <slrn9ohskn.lfd.tadmc@tadmc26.august.net>, Tad McClellan
<tadmc@augustmail.com> wrote:

> [ piggybacked 'cause OP cannot be found ]
> 
> 
> Brendon Caligari <bcaligari@fireforged.com> wrote:
> >"None" <pohanl@aol.com> wrote in message
> >news:12124e47.0108251948.44fc310f@posting.google.com...
> >> In the beginning there was sex.  Then came Perl.
> >> Which is better? 
> 
> >> Well, which is better?  Sex or Perl?
> 
> 
> Always enable warnings and strictures in Perl.
> 
> Unprotected Perl is a dangerous gamble in today's world.

No one else has pointed out that TMTOWTDI applies to both sex and Perl.

:-)

-- 
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net   | blazing high above your head.
 . . . . . . . . .  | But _in_ you is the presence that
 . . . . . . . . . | will be, when all the stars are dead.  (Rainer Maria Rilke)


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

Date: Sun, 26 Aug 2001 15:21:33 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: simple question im sure
Message-Id: <3B88F7DD.90800@post.rwth-aachen.de>

 .net.org.us.tv.cc wrote:

> woo hoo! i figured it out. the problem with
> the program takes place 2 lines AFTER
> the line specified in the error.. programming
> books always say too look in the code
> before the line specified in the error, so

Looking a few lines before the one an error allegedly occured makes 
sense in some cases, notably when Perl complains about some brackets 
missing. If you can't find an error in the line it indicated a missing 
semicolon on one of the previous lines is also a common goof.

Tassilo

-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Sun, 26 Aug 2001 09:58:02 -0700
From: Antonio <agm@physics.berkeley.edu>
Subject: Re: Telnet front-end
Message-Id: <3B892A9A.77B05CF9@physics.berkeley.edu>

Logan Shaw wrote:

> In article <3B88A198.1916B4BC@physics.berkeley.edu>,
> Antonio  <agm@physics.berkeley.edu> wrote:
> >I need to make a front-end to a program that, among other things,
> >invokes standard telnet after soliciting a login and password. The
> >program would prompt the user for various information, and then after
> >having a login session, would let telnet function from that point on.
>
> Wouldn't it be much easier just to not use telnet and instead use
> something that allows you to do a remote login without having to enter
> a username and password interactively?  The most likely candidate is
> Secure Shell.  See http://www.ssh.com/ and http://www.openssh.com/ .
>
>   - Logan
> --
> "Our grandkids love that we get Roadrunner and digital cable."
> (Advertisement for Time Warner cable TV and internet access, July 2001)

Yes it would be easier, but to my understanding of SSH, one needs to
configure the hosts file on the remote server, in order to have a
passwordless login. Otherwise, SSH prompts you interactively for a
password, just like telnet. In my situation, the remote server is likely
one I do not administer, hence I can do nothing about it. If that is
indeed the case (which I think it is), how does one handle interactive
processes with Perl?

Regards, Antonio.



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

Date: Sun, 26 Aug 2001 09:58:18 -0700
From: Antonio <agm@physics.berkeley.edu>
Subject: Re: Telnet front-end
Message-Id: <3B892AAA.51D0F6C3@physics.berkeley.edu>

Logan Shaw wrote:

> In article <3B88A198.1916B4BC@physics.berkeley.edu>,
> Antonio  <agm@physics.berkeley.edu> wrote:
> >I need to make a front-end to a program that, among other things,
> >invokes standard telnet after soliciting a login and password. The
> >program would prompt the user for various information, and then after
> >having a login session, would let telnet function from that point on.
>
> Wouldn't it be much easier just to not use telnet and instead use
> something that allows you to do a remote login without having to enter
> a username and password interactively?  The most likely candidate is
> Secure Shell.  See http://www.ssh.com/ and http://www.openssh.com/ .
>
>   - Logan
> --
> "Our grandkids love that we get Roadrunner and digital cable."
> (Advertisement for Time Warner cable TV and internet access, July 2001)



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

Date: Sun, 26 Aug 2001 19:19:19 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Telnet front-end
Message-Id: <3B892F97.2050100@post.rwth-aachen.de>

Logan Shaw wrote:

> Wouldn't it be much easier just to not use telnet and instead use
> something that allows you to do a remote login without having to enter
> a username and password interactively?  The most likely candidate is
> Secure Shell.  See http://www.ssh.com/ and http://www.openssh.com/ .

I think he could use Net::Telnet for that. With this module there would 
be absolutely no need for an interactive login. Given the remote host, 
username and password and some commands to be executed, a nice script 
could easily be written. The commands are put into an array over which 
is iterated (for (@commands) { @result = $telnet->cmd($_); ... }).

Tassilo
-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Sun, 26 Aug 2001 09:39:20 -0700
From: John Callender <jbc@west.net>
Subject: Re: warnings with cgi will crash Win32 perl core
Message-Id: <3B892638.673DF762@west.net>

"Godzilla!" wrote:
> 
> Today I discovered warnings provide false information
> about use of my declarations within sub-routines, this is,
> "...not be shared..." warning.

The information isn't "false"; you just don't understand what
it's trying to tell you. But it's important for you to figure it
out, since, as a Perl-using CGI programmer, you might eventually
want to run at least some of your scripts under Apache's
mod_perl. At that point you'll run into a whole lot more of this
particular warning, when your file-scoped my variables suddenly
find themselves running inside a subroutine.

> Warnings also cop an "unitialized" message when working
> with typical cgi environmental variables. This message,
> as with not shared my declarations, is erroneous.

Your implication is that the variable in question has been
initialized. That's almost certainly not true. Again, the warning
isn't "erroneous"; you just don't understand it, or at least have
determined, to the extent you are willing or capable of
investigating, that it isn't a problem for your particular
script.

That's fine; you're welcome to ignore the warnings, or not enable
them in the first place. That is, after all, how Perl runs by
default, which I believe to have been a good decision, since it
makes the language much more friendly for novices. I spent years,
literally, coding in Perl baby talk without enabling warnings or
the strict pragma, and I got a lot of useful work done during
that time.

Eventually, though, I moved beyond that, and you should too. With
larger coding projects, you will save far more time than you lose
if you enable warnings, and alter your code so it runs cleanly
under them. A 4000-line CGI script clearly falls into that
category.

I continue to find you fascinating, Kira. In a certain sense, you
are very much on the cutting edge. You're a poster child for
Perl's ability  to do amazing things even in the hands of those
who, by virtue of temperament and background, really have no
business messing around with programming. I don't mean to sound
snotty; that description could just as easily be applied to me as
to you, at least when I was starting out (and in some folks' eyes
it probably still could be today).

I'm pretty sure I was never quite the loon you are, with your
compulsion for viewing yourself as infallible and your penchant
for interpreting corrections of your bad advice as evidence of
some grand conspiracy against you. Even so, I identify with you.
And I think, at least on some level, that you are actually doing
a service to the larger Perl community, if only by forcing the
curmudgeonly types to recognize the extent to which that
community has expanded beyond the ranks of traditional
programmers. You've also helped, I think, in that your more
delusional ravings demonstrate quite dramatically the dangers of
the "flame them into silence" approach to policing newbie
behavior. Better to simply educate the newbies, or if that's too
much to ask, ignore them, until they rise to a level that allows
for productive interaction.

But the newbies will reach that stage sooner if they have
appropriate help, with "appropriate" being defined in terms of
the newbie's needs, rather than the curmudgeon's. I've seen a lot
of positive effort in that area lately (like some of the new
tutorials in the latest version of the Perl docs, and the mailing
lists at http://learn.perl.org), and I think that's a really good
thing. I hope that effort continues.

But in the meantime, Kira, you should cut Perl's warnings feature
some slack. Believe me: it's really not out to get you. It's just
trying to help.

-- 
John Callender
jbc@west.net


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

Date: 26 Aug 2001 09:40:27 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: warnings with cgi will crash Win32 perl core
Message-Id: <74f348f7.0108260840.59451348@posting.google.com>

Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> wrote in message news:<3B88E861.4020002@post.rwth-aachen.de>...
> Yves Orton wrote:
> 
> >>Most annoying, if warnings are enabled with -w for a
> >>complex and sizable cgi script, this hurls perl core
> >>into an infinite loop which can only be terminated
> >>with a kill process or a system shut down and restart.
> >>Fortunately, my system has seven-hundred-sixty-eight
> >>megabytes of RAM. Easy enough to recover, actually
> >>this infinite loop is not noticed on my machine save
> >>for no output from my cgi script under test.
> >>
> > 
> > This doesnt make much sense either.  Can you demonstrate this 'hurls
> > the perl core into an infinite loop'?  What code causes this to
> > happen?  Also if it is indeed an infinite loop why would 768MB make
> > any difference?  This sounds bogus to me.
> 
> Hehe, I remember having once written something like:
> 
> sub parts(@_) {
> 	eval { shift->parts(@_); }; #instead of SUPER::parts
> }
> 
> and wondered why all my memory filled up within half a second...only 
> chance to cleanly reboot was using the magic sysrequest stuff. I guess 
> it would have made no difference if I had had 768MB or even 40 TB of 
> RAM. The lock just would have come a second later.

:-)

Hmm.  On NT/2k you would have watched the box slow, the memory climb
and then killed the process. No reboot needed....  (Which happens
whenever I try to use the XS version of Data::Dumper on a _huge_
datastructure.  Very annoying...)
Thats also what happens if you override "", use carp and then call
cluck/confess inside the stringify routine. (I consider this frankly
to be a bug.  CTTOI Im going to post a bug/fix report on that right
now...)

Yves


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

Date: Sun, 26 Aug 2001 10:23:51 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: warnings with cgi will crash Win32 perl core
Message-Id: <3B8930A7.7D2708FF@stomp.stomp.tokyo>

John Callender wrote:

> Godzilla! wrote:

(snipped)


You are full of rancid crap, Bud.


Godzilla!


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.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 V10 Issue 1618
***************************************


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