[19944] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2139 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 15 14:05:54 2001

Date: Thu, 15 Nov 2001 11:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005851109-v10-i2139@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 15 Nov 2001     Volume: 10 Number: 2139

Today's topics:
    Re: (Solved) Need help with strange performance problem <nospam-abuse@ilyaz.org>
    Re: Declare Database Handle in Main or Module <caughran@chem.uga.edu>
    Re: Declare Database Handle in Main or Module (Anno Siegel)
        How to remove non alpha-numeric characters from a strin <paulb567@yahoo.co.uk>
    Re: How to remove non alpha-numeric characters from a s (Logan Shaw)
    Re: How to remove non alpha-numeric characters from a s <pilsl_@goldfisch.at>
    Re: How to remove non alpha-numeric characters from a s <Tassilo.Parseval@post.rwth-aachen.de>
    Re: How to remove non alpha-numeric characters from a s <Tassilo.Parseval@post.rwth-aachen.de>
    Re: How to remove non alpha-numeric characters from a s <wuerz@yahoo.com>
    Re: Learning Perl Book Example problem <tatkins@aug.com>
    Re: Match a pattern plus the next 3 lines... (rab)
    Re: Match a pattern plus the next 3 lines... <godzilla@stomp.stomp.tokyo>
    Re: ranged arrays <tsee@gmx.net>
    Re: ranged arrays <tsee@gmx.net>
        reading messages through Net::FTP and/or Net::Cmd (Tom Pinkl)
    Re: Regular Expression Madness (Malcolm Dew-Jones)
    Re: socket can't be opend, filerights? <michael.stuttgart@gmx.de>
    Re: Sorting of arrays by an element of each <godzilla@stomp.stomp.tokyo>
    Re: Sorting of arrays by an element of each <uri@stemsystems.com>
    Re: Sorting of arrays by an element of each <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Sorting of arrays by an element of each <godzilla@stomp.stomp.tokyo>
    Re: Sorting of arrays by an element of each <mikecook@cigarpool.com>
    Re: Sorting of arrays by an element of each <mikecook@cigarpool.com>
    Re: specific array items, loop iterator <peb@bms.umist.ac.uk>
    Re: Trees, Memory mgt and GC in perl 5.005_3 <temp133@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 15 Nov 2001 17:41:35 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: (Solved) Need help with strange performance problem processing large files
Message-Id: <9t0uof$jbs$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Tim Moose
<wtmoose@yahoo.com>], who wrote in article <48a86175.0111150655.75501494@posting.google.com>:
> I have some ideas, but I would be very interested to hear a technical
> explanation of why the memory management algorithms were getting
> bogged down.

Recompile with Perl's malloc.

Ilya


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

Date: Thu, 15 Nov 2001 11:41:26 -0500
From: Joel Caughran <caughran@chem.uga.edu>
Subject: Re: Declare Database Handle in Main or Module
Message-Id: <3BF3F036.67165B9B@chem.uga.edu>

Actually I did run the program and it did work.  So why would it work
with the 'wq' type and the my statement?

I've now fixed the typo and replaced the my with our and it continues to
work.

Joel
-- 
Joel A Caughran                 caughran@chem.uga.edu
Chemistry Learning Center       caughran@uga.edu
Department of Chemistry
University of Georgia           (706) 542-1906 voice
Athens, Georgia 30602-2556      (706) 542-9454 fax


Anno Siegel wrote:
> 
> According to Joel Caughran  <caughran@chem.uga.edu>:
> > I have been writing a few scripts that interact with a very simple
> > database.  After some reading, I thought it would be a good idea to
> > create the database handle in a module and export it so that it would be
> > available to the scirpt.  For example:
> >
> >       package myDB;
> >
> >       require Exporter;
> >       @ISA = qw(Exporter);
> >
> >       @EXPORT = wq( $dbh );
>                   ^^
> >
> >       use DBI;
> >
> >       my $dbh = DBI->connect( "dbi:ODBC:Computer_Info" )
>         ^^
> >               or die "Can't connect to 'Computer_Info':$DBI::errstr\n";
> >
> > Then in the main script I would have:
> >
> >       #!perl
> >
> >       use strict;
> >       use warnings;
> >
> >       use myDB;
> >
> >       $sth = $dbh->prepare( "SELECT * FROM table" )
> >               or die "Can't retrieve records:$DBI::errstr\n";
> >
> > The obvious advantage is that if I make some change to the database all
> > I really need to change is the myDB.pm.  What are the disadvantages to
> > this plan?
> 
> It won't work.  You didn't even try to run your code before submitting
> it, did you?
> 
> You can't export a lexical variable, as you try to do with $dbh.  It
> must be a package variable.  Also, you have "wq" where you want "qw".
> 
> Anno


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

Date: 15 Nov 2001 17:14:19 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Declare Database Handle in Main or Module
Message-Id: <9t0t5b$5tb$1@mamenchi.zrz.TU-Berlin.DE>

According to Joel Caughran  <caughran@chem.uga.edu>:

[Please place your reply *below* the quoted text. I moved it there]

> Anno Siegel wrote:
> > 
> > According to Joel Caughran  <caughran@chem.uga.edu>:
> > > I have been writing a few scripts that interact with a very simple
> > > database.  After some reading, I thought it would be a good idea to
> > > create the database handle in a module and export it so that it would be
> > > available to the scirpt.  For example:
> > >
> > >       package myDB;
> > >
> > >       require Exporter;
> > >       @ISA = qw(Exporter);
> > >
> > >       @EXPORT = wq( $dbh );
> >                   ^^
> > >
> > >       use DBI;
> > >
> > >       my $dbh = DBI->connect( "dbi:ODBC:Computer_Info" )
> >         ^^
> > >               or die "Can't connect to 'Computer_Info':$DBI::errstr\n";
> > >
> > > Then in the main script I would have:
> > >
> > >       #!perl
> > >
> > >       use strict;
> > >       use warnings;
> > >
> > >       use myDB;
> > >
> > >       $sth = $dbh->prepare( "SELECT * FROM table" )
> > >               or die "Can't retrieve records:$DBI::errstr\n";
> > >
> > > The obvious advantage is that if I make some change to the database all
> > > I really need to change is the myDB.pm.  What are the disadvantages to
> > > this plan?
> > 
> > It won't work.  You didn't even try to run your code before submitting
> > it, did you?
> > 
> > You can't export a lexical variable, as you try to do with $dbh.  It
> > must be a package variable.  Also, you have "wq" where you want "qw".
> >
> Actually I did run the program and it did work.  So why would it work
> with the 'wq' type and the my statement?
> 
> I've now fixed the typo and replaced the my with our and it continues to
> work.

The "wq" statement gives you this error:

   Undefined subroutine &myDB::wq called at myDB.pm line 6.

Trying to export a lexical variable is not an error, but what
is exported is the package variable $myDB::dbh.  Since it isn't
initialized, its value will be undef, not what you assigned to
the lexical $dbh.

Anno


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

Date: Thu, 15 Nov 2001 16:39:41 -0000
From: "Paul Bye" <paulb567@yahoo.co.uk>
Subject: How to remove non alpha-numeric characters from a string.
Message-Id: <9t0r47$f38$1@news5.svr.pol.co.uk>

Hi,

I'm trying to achieve this using a line such as

$_ = s/[^a-z]//g;

or

$_ = s/\W//g;

Its not working.

Anyone able to help.  A simple thing I know, but I'm very new to this
language.

Thanks.




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

Date: 15 Nov 2001 10:48:51 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: How to remove non alpha-numeric characters from a string.
Message-Id: <9t0rlj$p10$1@charity.cs.utexas.edu>

In article <9t0r47$f38$1@news5.svr.pol.co.uk>,
Paul Bye <paulb567@yahoo.co.uk> wrote:
>Hi,
>
>I'm trying to achieve this using a line such as
>
>$_ = s/[^a-z]//g;
>
>or
>
>$_ = s/\W//g;

You want "=~", not "=".

"=" is an assignment operator.  It says to execute the expression
"s/\W//g" and assign the expression's value to the variable "$_".  The
value of such an expression is the number of substitutions made.

"=~" is a binding operator.  It says that the substitution operation
should be performed on the variable "$_".

Basically, the s/// operator does its substitution as a side effect,
and the value of the expression is not a string but a number.  So
usually you don't want the value of the expression and instead you want
its side effects to affect a variable.

So, you could type

    $_ =~ s/\W//g;

Actually, if you don't use "=~", then the default variable is "$_", so
it would be more concise (and more Perlish) to type just

    s/\W//g;

Hope that helps.

  - Logan
-- 
"In order to be prepared to hope in what does not deceive,
 we must first lose hope in everything that deceives."

                                          Georges Bernanos


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

Date: Thu, 15 Nov 2001 17:51:20 +0100
From: peter pilsl <pilsl_@goldfisch.at>
Subject: Re: How to remove non alpha-numeric characters from a string.
Message-Id: <3bf3f297$1@e-post.inode.at>

Paul Bye wrote:

> Hi,
> 
> I'm trying to achieve this using a line such as
> 
> $_ = s/[^a-z]//g;
> 
> or
> 
> $_ = s/\W//g;
> 
> Its not working.
> 

The mainproblem is that you misspell the operation.

$_=~/\W//g;

This will actually change the content of $_.
You call in scalar context, which might return the number of items that 
would have been replaced in $_. (not sure, check man perlop)

but note that underscore is imho not replaced by doing this.

you could also use the tr-operator with the c- and the d-option to perform 
such an operation. The following would also remove the underscore:

$_=~tr/A-Za-z0-9//cd;

the following would definitely count the number of non-alphnum elements in 
$_ and assign to $_, wich can be misunderstoodable:
$_=tr/A-Za-z0-9//cd;

so better write:
$a=tr/A-Za-z0-9//cd;

which assigns the number of non-alphnum elements in $_ to $a. $_ is the 
defaultvariable and used when no variable is used for the tr-operator.


hope this helps,
peter


-- 
peter pilsl
pilsl_@goldfisch.at
http://www.goldfisch.at



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

Date: Thu, 15 Nov 2001 17:55:58 +0100
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: How to remove non alpha-numeric characters from a string.
Message-Id: <9t0s2u$9cl$03$1@news.t-online.com>

On Thu, 15 Nov 2001 16:39:41 -0000, Paul Bye wrote:
> Hi,
> 
> I'm trying to achieve this using a line such as
> 
> $_ = s/[^a-z]//g;
     ^

Wrong operator: Use =~ instead.

And for such a case, you wouldn't need a regex at all. Use tr///
instead:

$_ =~ tr/[A-Za-z0-9]//dc;

or even (equivalent since you have $_ here)

tr/[A-Za-z0-9]//dc; 

Read about the tr/// operator in 'perldoc perlop'.

Tassilo
-- 
Laughing at you is like drop kicking a wounded humming bird.


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

Date: Thu, 15 Nov 2001 17:59:05 +0100
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: How to remove non alpha-numeric characters from a string.
Message-Id: <9t0s8o$lmf$01$1@news.t-online.com>

On Thu, 15 Nov 2001 17:55:58 +0100, Tassilo v. Parseval wrote:
> On Thu, 15 Nov 2001 16:39:41 -0000, Paul Bye wrote:
>> Hi,
>> 
>> I'm trying to achieve this using a line such as
>> 
>> $_ = s/[^a-z]//g;
>      ^
> 
> Wrong operator: Use =~ instead.
> 
> And for such a case, you wouldn't need a regex at all. Use tr///
> instead:
> 
> $_ =~ tr/[A-Za-z0-9]//dc;
           ^         ^
This is wrong. Must be:

tr/A-Za-z0-9//dc;

likewise...
> tr/[A-Za-z0-9]//dc; 

Tassilo
-- 
Preserve Wildlife!  Throw a party today!


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

Date: 15 Nov 2001 12:02:32 -0500
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: How to remove non alpha-numeric characters from a string.
Message-Id: <m33d3gvufr.fsf@DCCMBX01.njitdm.campus.njit.edu>

"Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de> writes:

> On Thu, 15 Nov 2001 16:39:41 -0000, Paul Bye wrote:
> > 
> > I'm trying to achieve this using a line such as
> > 
> > $_ = s/[^a-z]//g;
>      ^
> Wrong operator: Use =~ instead.
> 
> And for such a case, you wouldn't need a regex at all. Use tr///
> instead:
> 
> $_ =~ tr/[A-Za-z0-9]//dc;

this will keep [ and ] as well. Use:

y/A-Za-z0-9//dc;

> Read about the tr/// operator in 'perldoc perlop'.

yeah ;)

-- 
$_="\n,rekcah egnufeB rehtona tsuJ";#v1<?>g\:pv-<5<
s s\S+(?:B)sunpack'u',q q$;')E4qsee;#>60#^<(v!<)g6<
print scalar reverse,$@ unless m,[+;#]55,;m:_,:#^1<


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

Date: Thu, 15 Nov 2001 11:14:06 -0500
From: "Tom Atkins" <tatkins@aug.com>
Subject: Re: Learning Perl Book Example problem
Message-Id: <1005840852.536976@savina>

That worked! Thanks for your help

"Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de> wrote in
message news:9suf35$6ln$01$1@news.t-online.com...
> On Wed, 14 Nov 2001 13:43:59 -0500, Tom Atkins wrote:
> > which perl shows /usr/bin/perl
> > the first line of my script (created with pico total 2 lines) is
> > #!/usr/bin/perl (I tried a space after ! also)
> >
> > enter test1 command not found
> > enter . test1 bash errors
> > enter perl test1 gets Hello World!
> >
> > all done in the directory where the file resides
>
> In the directory where the file resides, you say? Unless '.' is part of
> your path and you did not happen to create the file in one of the
> path-directories, the bash just doesn't find the script since it does
> not scan the current directory. Try ./test1 instead.
>
> Tassilo
> --
> Lewis's Law of Travel:
> The first piece of luggage out of the chute doesn't belong to anyone,
> ever.




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

Date: 15 Nov 2001 10:06:36 -0800
From: richardbriggs@att.com (rab)
Subject: Re: Match a pattern plus the next 3 lines...
Message-Id: <900b7105.0111151006.40be595@posting.google.com>

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message news:<3BF2C22F.B795E6D6@stomp.stomp.tokyo>...
> rab wrote:
>  
> > How can I make a script that will search a log file for a text
> > pattern, say "ERROR" then upon finding the pattern also give me the
> > next 3 lines in the file?
> 
> You have failed to provide clear and concise parameters.
> There is no mention of nor example of your data structure.
> Without decent parameters all answers, including my own,
> are nothing more than wild guesses.
> 
> Do work on posting clear, concise and coherent articles.
> It is rude to not provide information with which to work
> and expect others to invest personal time, for free.
> <snip>

Oh GAWDzilla!  Always the perfectionist!   (I still like you though
;-)

> Beneath my signature you will discover a test script with
> which you may play and possibly attain your goal. <snip>

THANKS!  here's what I came up with...now help me make it better.

    11  $infile="dlog.bak";
    12
    13  #######################################################
    14
    15  open(LOG,"/opt/log/$infile")|| die "cannot open $infile";
    16  @line = <LOG>;
    17  close(LOG);
    18  open (TEMP, ">>/tmp/temp")|| die "cannot open temp file";
    19  foreach ($i = 0; $i <= (<LOG>); $i++) {
    20     if ($line[$i] =~ /BOOTP REQUEST from/i ) {
    21        chomp($my_first = ($line[$i]));
    22        chomp($my_value = ($line[$i+2]));
    23        print TEMP "$my_first $my_value\n";
    24     }
    25  print TEMP "\n";
    26  }
    27  @temp = `sort -u /tmp/temp`;
    28  open (TEMPTWO,">/tmp/bootp_list.txt")|| die "cannot open
output file";
    29  print TEMPTWO @temp;
    30  close (TEMPTWO);
    31  system("/usr/bin/rm /tmp/temp");


I know there must be a way to populate an array as it finds matches in
the first
if loop instead of printing to <TEMP> file handle...but I don't know
how to preserve the greps that set $my_first and $my_value outside of
the loop - I realize that the above code only gets the line and then
the 3rd line, which is a change from my original post.  I wanted to
grab all three at first, but decided to just get the two, so I am
aware of it.


Incidentally, the dbak.log file is of similar structure to a
syslog.log  and it has about 600,000 lines.


I'm admittedly a self-taugh perl scripter, with a severe POSIX SHELL
PROGRAMMING
Affinity Disability.(PSPAD?)   So, tear it apart, even with extreme
gawdzilla prejudice, I want to get better.

rab


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

Date: Thu, 15 Nov 2001 10:26:12 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Match a pattern plus the next 3 lines...
Message-Id: <3BF408C4.B1C269AE@stomp.stomp.tokyo>

rab wrote:
 
> Godzilla! wrote:
> > rab wrote:

(snipped)

> > > How can I make a script that will search a log file for a text
> > > pattern, say "ERROR" then upon finding the pattern also give me the
> > > next 3 lines in the file?

> > Beneath my signature you will discover a test script with
> > which you may play and possibly attain your goal. <snip>
 
> THANKS!  here's what I came up with...now help me make it better.
 
No.


> the loop - I realize that the above code only gets the line and then
> the 3rd line, which is a change from my original post.  I wanted to
> grab all three at first, but decided to just get the two, so I am
> aware of it.

You are also aware of how annoyed I become with posters
changing parameters at wish, whim and will.


Godzilla!


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

Date: Thu, 15 Nov 2001 18:06:42 +0100
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: ranged arrays
Message-Id: <9t0slr$afi$03$2@news.t-online.com>

"Mark Jason Dominus" <mjd@plover.com> schrieb im Newsbeitrag
news:3bf2fb3e.7044$c@news.op.net...
| In article <9suoln$nak$06$1@news.t-online.com>,
| Steffen Müller <tsee@gmx.net> wrote:
| >- I'm not missing the point that in your example, there is never a value
| >assigned to the internal array and
|
| It wasn't a complete example.  You're supposed to fill in the blanks
| (the comment marked "Do something with $n") to get the fetch and store
| behavior you want.

I know. I did that, of course. The problem was for() using FETCHSIZE.

| >- I'm not missing the point that that's not possible without STORE
either.
|
| You can handle STORE the same way you handle FETCH.

I know. That's all good & working :)

| I agree that the for (@a) {} probably cannot be made to work.

The only I thing I could think of was something involving caller() to
distinguish between different uses, but after a little more consideration, I
gave up the thought.

Still, you get the prize for the most elegant hack - just not a solution.

Thanks,
Steffen
--
$_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
$1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;$o=$_;push@o,substr($o,$_*8,8) for(0..
24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\r";$i++};print"\n"#stm





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

Date: Thu, 15 Nov 2001 18:00:24 +0100
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: ranged arrays
Message-Id: <9t0slq$afi$03$1@news.t-online.com>

"Logan Shaw" <logan@cs.utexas.edu> schrieb im Newsbeitrag
news:9sv1sl$evb$1@charity.cs.utexas.edu...
| In article <9sug8o$nlp$07$1@news.t-online.com>,
| Steffen Müller <tsee@gmx.net> wrote:
| >Worse yet, how would you realize a decent syntax for multi-dimensional
| >BoundedArray's?
| >
| >use BoundedArray;
| >
| >$ba = BoundedArray->new(-5, 50);
| >
| >$ba->at(-3)         = BoundedArray->new(5,13);
| >$ba->at(-3)->at(10) = "This is horrible\n";
|
| I don't even think it'd be possible to implement autovivification,
| which I think is just about the only way to make that any better.  But
| that's probably OK, because you probably don't want autovivification
| with bounded arrays.  If you have autovivification, then the bounds are
| undefined, and that seems just _slightly_ out of line with the spirit
| of bounded arrays, don't you think?

Well besides not working, it could just copy the bounds from the parent
array, but, oh well, AFAIK this won't do.

| So in that case, you probably want a normal array anyway[1].  And
| although it's not a thing of beauty, it's not so terribly bad:
|
|     ${$ba->at(-3)}[10] = "This is arguably less horrible\n";

Matter of taste. At least it *does* work!

| At least, I think this should work.  I know it works if I replace
| "$ba->at(-3)" with some random scalar variable, so I'd hope/assume it
| works when I use a subroutine call that returns an lvalue.  (I don't
| have a recent enough version of Perl handy to test it with.)

lvalues are weird stuff. They're not well documented and I know little of
them. Judging from my tests, you can *not* use this: (example)

sub example : lvalue {
   my $var1 = shift;
   my $var2 = shift;
   if ( $var1 ) { return $var1 }
   return $var2;
}

It seems like you can't explicitly return lvalues. This should work:

sub example : lvalue {
   my $var1 = shift;
   my $var2 = shift;
   if ( $var1 ) { $var1 }
   else { $var2 }
}

Makes the implementation of more complicated stuff a horrible pain.

| Another approach is to implement bounded arrays so they can have more
| than one dimension, so you can do things like "$ba->at(-3,7)".  But an
| approach I like better is to just make syntactic sugar for it, so that
| at() would look like this:
|
|     sub at : lvalue
|     {
| my $self = shift;
|
| if (@_ > 1)
| {
|     # syntactic sugar
|
|     my $outer_index = shift;
|
|     die "too many dimensions!\n" unless
| UNIVERSAL::isa ($self->at($outer_index), "BoundedArray"));
|
|     return $self->at($outer_index)->at(@_);
      ^^^^^^
doesn't seem to work...

| }
| else
| {
|     # regular implementation goes here
| }
|     }
|
| That way, "$ba->at(3,7)" gets reduced to "$ba->at(3)->at(7)".
|
| Once again, I'm sort of on thin ice with my knowledge of lvalues.  I'm
| only assuming an lvalue can be passed through multiple levels of
| return.  (But then, it's not *actually* necessary to implement it
| recursively.  It's just simpler and more fun.)

Maybe I'll just settle for the ugly, ugly syntax without lvalues?

| Hell, if you want, make at() check if any index is an array ref, and if
| it is, it means a slice instead of an individual element, so you can
| type
|
|     $ba->at(2,4,[7..9])
|
| and get back a slice bound to the elements at (2,4,7), (2,4,8), and
| (2,4,9).  And if you're feeling really frisky, then
|
|     $ba->at([2..3],4,[7,9])
|
| can be a slice bound to the elements at (2,4,7), (2,4,9), (3,4,7), and
| (3,4,9).  But now I'm just being silly[2].

I'm not that far yet ;)

| [1]  Unless you are trying to get unbounded arrays with negative
|      indices.  But the obvious implementation wouldn't support that
|      anyway, because it would determine the index of the lowest
|      possible element at object creation time and manage the storage
|      accordingly.
|
| [2]  But I do want to point out that if one actually does implement
|      slices in an array class, then using the ".." to operator is
|      probably not that great an idea.  Better to pass the *idea* of a
|      range to the object than to pass it a list of all the elements in
|      the range.  Unfortunately, "[2,'..',3]" is an ugly syntax.  Maybe
|      "[2, 'thru', 3]" is a tiny bit better, although it's still bad.

Both ugly :(

After all, lvalues are considered experimental anyway.
Thanks for your help.

Steffen
--
$_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
$1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;$o=$_;push@o,substr($o,$_*8,8) for(0..
24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\r";$i++};print"\n"#stm





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

Date: 15 Nov 2001 08:26:34 -0800
From: tom@hbsrx.com (Tom Pinkl)
Subject: reading messages through Net::FTP and/or Net::Cmd
Message-Id: <6dc8d464.0111150826.5909490c@posting.google.com>

I'm using Net::FTP to login and issue commands to a daemon whose
behavior is modeled after an FTP server.  This works.    This daemon
accepts one command that may take 60 seconds or so to process (it's
establishing a PPP connection).  While the command is being processed,
messages are output intermittently.    I'm currently using
$ftp->message() to read these messages AFTER the command completes.   
Is there a way to read the messages as they arrive?    I'd appreciate
any suggestions.    --  Tom Pinkl


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

Date: 15 Nov 2001 10:37:19 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Regular Expression Madness
Message-Id: <3bf40b5f@news.victoria.tc.ca>

Bernard El-Hagin (bernard.el-hagin@lido-tech.net) wrote:
: On Thu, 15 Nov 2001 10:03:51 GMT, Tyler Cruz <tylercruz@home.com> wrote:
: > I'm a Perl newbie so I'm not sure about this, but other than switching to
: >=~, doesn't the RegEx parameters have to be in parethethis?:
: > 
: > $text =~ s/<%(.*?)%>//sg;


: The parentheses are only necessary if you want to use what ".*?"
: captures. It will be stored in the special $1 variable if the
: ()s are present. Read more in perlre.

Not entirely true, the ()'s are also important for logical grouping.

e.g.	([A-Z][a-z]*[0-9]+)?

the final ? is for everything in the parentheses - the match within the
()'s must happen exactly zero or one times. 

Add "?:" to prevent the ()'s from setting $1 $2 etc.

e.g.	(?:[A-Z][a-z]*[0-9]+)?



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

Date: Thu, 15 Nov 2001 19:10:26 +0100
From: "Michael" <michael.stuttgart@gmx.de>
Subject: Re: socket can't be opend, filerights?
Message-Id: <9t10m8$abf$1@news.online.de>



--


"Tim Haynes" <usenet@stirfried.vegetable.org.uk> schrieb im Newsbeitrag
news:86k7wt6qq1.fsf@potato.vegetable.org.uk...
>
> strace will tell you exactly which files it can't open.
>
> Check /etc/{resolv.conf,hosts,nsswitch.conf}.
>
Thanks strace did help. The files were the above files + /etc/services






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

Date: Thu, 15 Nov 2001 08:33:03 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Sorting of arrays by an element of each
Message-Id: <3BF3EE3F.AB188563@stomp.stomp.tokyo>

Michael Cook wrote:

(snipped)

> I am having a difficult time with this sort.

> @1001 = (field1, field2, 1001, field3)
> @1002 = (field4, field5, 1002, field6)
> @1003 = (field6, field7, 1003, field8)
 
> ...but I don't want to display them in the order of the array names,
> I am trying to sort them by the second element in the array.

> Any ideas? I am stumped (I think maybe a hash....


You have failed to provide clear and concise parameters.
Additionally, you have a glaring error in your arrays.

Your failure to provide parameters is evidenced by no
examples of data contained in each field. Clearly it
is unknown if these fields contain numbers, letters,
odd characters or a mix of whatever. The nature of
your data directly effects how a sort will behave.

Your error is listing two field sixes in your arrays.

It is rude to not provide parameters and expect others
to invest their personal time, for free, to help you.

Incorporating errors into your lacking examples is
very sloppy and indicative of laziness.

Any and all answers provided are, as often is the case
in this group, wild guesses. My answer is a wild guess.
None can ascertain the nature of your data due to your
neglecting to be courtesy enough to invest time and
effort into your article in exchange for free help.

There is no need to use a slow memory wasteful hash
for a simple task you inadequately describe. Below
my signature is a test script which displays a type
of logic which might solve your needs. However, there
is no way of knowing; you failed to provide parameters.

I have plugged in numbers for each of your second fields
to exemplify how this could be done without a hash. This
is a simple straightforth method.

If this is not what you need, fault yourself for posting
such an incoherent article.


Godzilla!
--

TEST SCRIPT:
____________

#!perl

@1001 = (field1, 789, 1001, field3);
@1002 = (field4, 123, 1002, field6);
@1003 = (field7, 456, 1003, field9);

@Sort = ("$1001[1]:1001", "$1002[1]:1002", "$1003[1]:1003");

@Sort = sort (@Sort);

for (@Sort)
 {
  ($key, $value) = split (/:/, $_);
  print "@$value\n\n";
 }

exit;


PRINTED RESULTS:
________________

field4 123 1002 field6

field7 456 1003 field9

field1 789 1001 field3


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

Date: Thu, 15 Nov 2001 17:53:40 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Sorting of arrays by an element of each
Message-Id: <x7y9l7gbr9.fsf@home.sysarch.com>

>>>>> "MC" == Michael Cook <mikecook@cigarpool.com> writes:

  MC> Hi folks,
  MC>     I am having a difficult time with this sort. I have a group of arrays
  MC> like:

  MC> @1001 = (field1, field2, 1001, field3)
  MC> @1002 = (field4, field5, 1002, field6)
  MC> @1003 = (field6, field7, 1003, field8)

@1001 is a very poor way to name an array. and it looks like you will be
donw the path to symbolic references if you need to manage many of those
arrays. 

so you should go to an array of arrays (also called list of lists)
arrangement. read perllol and perldsc for more on that.

then you want to sort an LoL which is covered in an FAQ on how to sort
by anything. also read this paper on sorting:

	http://www.sysarch.com/perl/sort_paper.html

and in general ignore anything you read from moronzilla. 

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Thu, 15 Nov 2001 19:01:08 +0100
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Sorting of arrays by an element of each
Message-Id: <9t0vt4$6vo$06$1@news.t-online.com>

On Thu, 15 Nov 2001 17:53:40 GMT, Uri Guttman wrote:

> and in general ignore anything you read from moronzilla.

Oh, she's lurking around again? As Tad said: "Gotta love a scoring
news-reader".

Tassilo
-- 
What we see depends on mainly what we look for.
		-- John Lubbock


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

Date: Thu, 15 Nov 2001 10:19:25 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Sorting of arrays by an element of each
Message-Id: <3BF4072D.F0EFCBB8@stomp.stomp.tokyo>

Uri Guttman wrote:
 
> Michael Cook wrote:

(snipped Uri's inadequate and impotent... uhh... helpful hints!)


> and in general ignore anything you read from moronzilla.

Oh po' boy. Have my recent articles of stunning brilliance
bruised your ever so fragile masculine ego?


 "Don't take life so seriously. You will never get out of it alive."

   - Bugs Bunny


For trivia sake, you have missed, have overlooked my most 
brilliant, smooth and slick technological con to date!


Godzilla!  Queen Of Stomped Egomania.


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

Date: Thu, 15 Nov 2001 11:52:54 -0700
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Re: Sorting of arrays by an element of each
Message-Id: <waUI7.120$2M4.111127@news.uswest.net>

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3BF3EE3F.AB188563@stomp.stomp.tokyo...
(snipped)

> You have failed to provide clear and concise parameters.
> Additionally, you have a glaring error in your arrays.

» Sorry, the last time I posted, I was chided for wasting folks' time with
too much info

> Your failure to provide parameters is evidenced by no
> examples of data contained in each field. Clearly it
> is unknown if these fields contain numbers, letters,
> odd characters or a mix of whatever. The nature of
> your data directly effects how a sort will behave.
>
> Your error is listing two field sixes in your arrays.

» typo, sorry

> It is rude to not provide parameters and expect others
> to invest their personal time, for free, to help you.

» I never try to be rude

> Incorporating errors into your lacking examples is
> very sloppy and indicative of laziness.

» In the Camel book, Laziness is given as one of the great virtues of a
programmer; however, I am quite industrious

(snipped)>
>
> Godzilla!
> --
>
> TEST SCRIPT:
> ____________
>
> #!perl
>
> @1001 = (field1, 789, 1001, field3);
> @1002 = (field4, 123, 1002, field6);
> @1003 = (field7, 456, 1003, field9);
>
> @Sort = ("$1001[1]:1001", "$1002[1]:1002", "$1003[1]:1003");
>
> @Sort = sort (@Sort);
>
> for (@Sort)
>  {
>   ($key, $value) = split (/:/, $_);
>   print "@$value\n\n";
>  }
>
> exit;
>
>
> PRINTED RESULTS:
> ________________
>
> field4 123 1002 field6
>
> field7 456 1003 field9
>
> field1 789 1001 field3

Thanks for the help!!! This was indeed exactly what I was looking for -
great guess  ;-)
    Michael
--
== CigarPool ==
http://www.cigarpool.com




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

Date: Thu, 15 Nov 2001 11:54:06 -0700
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Re: Sorting of arrays by an element of each
Message-Id: <qbUI7.122$2M4.111441@news.uswest.net>

"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x7y9l7gbr9.fsf@home.sysarch.com...
> >>>>> "MC" == Michael Cook <mikecook@cigarpool.com> writes:
>
>   MC> Hi folks,
>   MC>     I am having a difficult time with this sort. I have a group of
arrays
>   MC> like:
>
>   MC> @1001 = (field1, field2, 1001, field3)
>   MC> @1002 = (field4, field5, 1002, field6)
>   MC> @1003 = (field6, field7, 1003, field8)
>
> @1001 is a very poor way to name an array. and it looks like you will be
> donw the path to symbolic references if you need to manage many of those
> arrays.
>
> so you should go to an array of arrays (also called list of lists)
> arrangement. read perllol and perldsc for more on that.
>
> then you want to sort an LoL which is covered in an FAQ on how to sort
> by anything. also read this paper on sorting:
>
> http://www.sysarch.com/perl/sort_paper.html
>
> and in general ignore anything you read from moronzilla.
>
> uri
>
> --
> Uri Guttman  ------  uri@stemsystems.com  --------
http://www.stemsystems.com
> -- Stem is an Open Source Network Development Toolkit and Application
Suite -
> ----- Stem and Perl Development, Systems Architecture, Design and
Coding ----
> Search or Offer Perl Jobs  ----------------------------
http://jobs.perl.org


Thanks for the pointers, Uri - I may go back & rethink my logic...
    Michael
--
== CigarPool ==
http://www.cigarpool.com




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

Date: Thu, 15 Nov 2001 16:12:19 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: specific array items, loop iterator
Message-Id: <3BF3E963.330AD2BE@bms.umist.ac.uk>

Bernard El-Hagin wrote:
> 
> On Thu, 15 Nov 2001 15:18:58 +0100, Philip Newton
> <pne-news-20011115@newton.digitalspace.net> wrote:
> > On Thu, 15 Nov 2001 09:13:38 +0000 (UTC), Bernard El-Hagin
> ><bernard.el-hagin@lido-tech.net> wrote:
> >
> >> On Thu, 15 Nov 2001 09:06:23 GMT, Sean Hamilton <sh@planetquake.com> wrote:
> >> > 1. Is there a good way to extract only certain items from an array? For
> >> > example, if I only want the inode of a file, I can use something like
> >> >
> >> > my $inode = (stat ($file))[1];
> >> >
> >> > However, what if I want the first and ninth item? Must I create a bunch of
> >> > dummy variables?
> >>
> >> (stat($file))[1,9];
> >
> > That gives you the second and tenth item.
> 
> $[ = 1;

I would have thought that you would be one of the first people to hand
out a scolding for the response you've just given, Bernard ;-)

Paul


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

Date: Thu, 15 Nov 2001 10:11:59 -0800
From: "Arvin Portlock" <temp133@hotmail.com>
Subject: Re: Trees, Memory mgt and GC in perl 5.005_3
Message-Id: <9t10hi$kfk$1@agate.berkeley.edu>

Logan (got your name right this time!)

This is all very clear. I thought about your earlier post quite a bit
and finally understood what was going on. This post makes things
even clearer, especially the comparison between perl's garbage
collection and those of other interpreters. I don't feel quite so insane
for my mistaken impression now!

Thank you very much  for your time and patience.

Arvin


Logan Shaw <logan@cs.utexas.edu> wrote in message
news:9sv2sd$f3b$1@charity.cs.utexas.edu...
> In article <9sujds$2i9q$1@agate.berkeley.edu>,
> Arvin Portlock <temp133@hotmail.com> wrote:
> >Anyway, I guess now I'm confused by what exactly is meant by
> >an external reference and why I would want or need to iterate through
> >my data structure deleting references to parent nodes, or why you
> >feel this might be easiest. All of my nodes are referenced as my
> >variables within subroutines. So when the program finishes they
> >should all pass out of scope. Only the root remains. Only the root
> >is accessible to the outside world. There seems to me to be a bit
> >of danger in this assumption, the user of the module assumes the
> >burden, but assuming that is actually the case, would undef'ing the
> >root be sufficient? Or do the references from one node to another
> >constitute external references? Yes, they are definitely circular but
> >are not "exposed."
>
> Your confusion is understandable.
>
> Deleting the root (i.e. all external references) IS sufficient to make
> it possible in theory for a garbage collector to reclaim your entire
> data structure.  In fact, there are real interpreters for other
> languages that have a garbage collector that can do that.
>
> But that kind of garbage collection is somewhat slow.  So, Perl uses a
> different garbage collection algorithm that is fast but not
> "thorough".  The particular algorithm that Perl uses works just great
> unless there are cycles in the data structure.  If there are cycles,
> then Perl's garbage collector is tricked into thinking that it can't
> reclaim some of the storage when actually it could.
>
> To put it a different way, a perfect garbage collector deletes all data
> that is no longer reachable by the program.  Perl's garbage collector
> deletes all data that has a reference count of zero.  The only time
> when there's a difference is when the data has a cycle.
>
> So the reason I suggest you break links from nodes to their parents is
> that it's an easy way to eliminate all cycles.  And if you do that,
> then Perl's imperfect garbage collector won't be tricked into thinking
> that your data is still in use.
>
>   - Logan
> --
> "In order to be prepared to hope in what does not deceive,
>  we must first lose hope in everything that deceives."
>
>                                           Georges Bernanos




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

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


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