[8463] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2080 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 12 04:07:36 1998

Date: Thu, 12 Mar 98 01:00:35 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 12 Mar 1998     Volume: 8 Number: 2080

Today's topics:
    Re: attachments <qdtcall@esb.ericsson.se>
    Re: c.l.p.mod and TPI <rjk@coos.dartmouth.edu>
    Re: Does anybody know how to do ftp in perl? <slreid@micron.net>
        help with hash jimmyp@marimba.com
    Re: How do I rename a file using perl <c..bojswbo@83.usenet.us.com>
        Lots of work for CGI PROGRAMMER <sunshine@infinet.com>
        New problem .... <ben@wallroyds.demon.co.uk>
        Newcomer problem :) Cus I'm 17 :) <ben@wallroyds.demon.co.uk>
    Re: Newcomer problem :) Cus I'm 17 :) <ben@wallroyds.demon.co.uk>
    Re: Newcomer problem :) Cus I'm 17 :) <ben@wallroyds.demon.co.uk>
        Program cores if not runder under debugger (redhat 5 on (Kevin Currie)
    Re: random numbers? mwsasser!nospam!@timetrend.com
    Re: Skipping within a line to read URL? (John Moreno)
        Sorry... Need A DBM to USE! (Jason Hazzard)
    Re: splice -- useful uses? <tchrist@mox.perl.com>
    Re: splice -- useful uses? (Michael W Peterson)
    Re: splice -- useful uses? (Abigail)
    Re: splice -- useful uses? (Abigail)
    Re: splitting by one or more spaces (Martin Vorlaender)
        to: tom c. Re: splice -- useful uses? <uri@sysarch.com>
        using exec to call telnet in perl <dspeidel@thunder.ocis.temple.edu>
    Re: Way of testing whether a variable is blessed (Martin Vorlaender)
        where can I find the on line books crlin@hotmail.com
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 12 Mar 1998 09:42:45 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: attachments
Message-Id: <is90qggv0a.fsf@godzilla.kiere.ericsson.se>

colte@hem.passagen.se (Robert) writes:

> Does anyone know if it is possible to attach a simple textfile to a
> mail message using sendmail or blat ?

Yes, it is possible.
-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: Wed, 11 Mar 1998 23:36:32 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: c.l.p.mod and TPI
Message-Id: <35076651.D2A934C7@coos.dartmouth.edu>

Chip Salzenberg wrote:
> 
> According to stanley@skyking.OCE.ORST.EDU (John Stanley):
> >Quoting from the proposed charter:
> >
> >]In addition, the moderators will reject any article:
> >]
> >]+ which contains an advertisement or commercial solicitation
> >]  of any sort; (EXCEPTION: The Perl Insitute may post
> >]  commercials that its board deems to be of general interest
> >]  to the Perl community, such as announcements of upcoming
> >]  Perl-oriented conferences.)
> >
> >It would seem that this section of the charter needs to be reworded. It
> >does say that non-TPI ads will be rejected.
> 
> It says that ads must be posted by TPI.  It does NOT say that such ads
> must have originated with or otherwise involve the affairs of TPI people.

Okay, so why must someone who wants to post an ad pass it through TPI?  Why
does TPI get exclusive say on which ads can be posted to c.l.p.mod and which
ones can't?

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Wed, 11 Mar 1998 21:31:34 -0700
From: "Steven L Reid" <slreid@micron.net>
Subject: Re: Does anybody know how to do ftp in perl?
Message-Id: <6e7ocr$5fk$1@news01.micron.net>

Okay, Maybe I just like the hard road, but I just open a pipe to ftp and
push it commands using print?!  Too simple!

open(FTP, "|ftp hostname") || die "ick, can't open ftp!";
print FTP "get thefile\n";
close FTP;

Too make things simple, I added the .netrc file with the username and
password (don't forget to make it read only by you!).  Better than embedding
it in the script.  I wouldn't make this a CGI script though!

(P.S. this probably only works on a UNIX box!)

Steven
goldfinger69@geocites.com




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

Date: Wed, 11 Mar 1998 22:26:32 -0600
From: jimmyp@marimba.com
Subject: help with hash
Message-Id: <6e7o3b$lhl$1@nnrp1.dejanews.com>

Hi,

I hope someone can help me in making a hash for a perl script.

I have some data like this:

username,password,(product1=>build1, build2, build3),
                  (product2=>build4),
                  (product3=>build1, build2)

so I thought I would have the database provide me with a hash that would be
efficient to parse.

I thought of something like this:

####
 %Acl = (
    bart => {
        password => "simpson",
        products => [
            {prod_name1 => ["build1" , "build2", "build3"]},
            {prod_name2 => ["build3"]},
            {prod_name3 => ["build5", "build2"]},
        ],
     },
    george => {
        password => "jetson",
        products => [
            {prod_name1 => "build1" , "build2", "build3"},
            {prod_name2 => "build3"},
        ],
     },
    fred => {
        password => "flintstone",
        products => [
            {prod_name1 => "build1" , "build2", "build3"},
            {prod_name2 => "build3"},
        ],
     },
);

###

but I don't know if I am building the right structure here, and I'm not sure
how to dereference and pull out the items I want. I would want to use the name
as a key for the entire record, and then pull out some info based on each
product name and build.

I have looked at perlref and perllol, and perldsc, but they get pretty steep
quickly and I don't really understand them.

If anyone understands what I'm trying to do here, and can help me out, I would
appreciate it greatly!

thanks

jimmy


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 12 Mar 1998 07:19:59 GMT
From: Anirvan Chatterjee <c..bojswbo@83.usenet.us.com>
Subject: Re: How do I rename a file using perl
Message-Id: <6e82av$js6$1@samba.rahul.net>

Dave Bushong <spamfree@yahoo.com> wrote:
> Great tip.  Except I didn't even get a dinosaur.

Probably because you're using a dinosaur. Try a newer version of perl
to enjoy the glory of perldoc's -f flag. For the time being, man
perlfunc the old fashioned way to find the following bit:

       rename OLDNAME,NEWNAME
               Changes the name of a file.  Returns 1 for
               success, 0 otherwise.  Will not work across file
               system boundaries.

_____________________________________________________________________
Anirvan Chatterjee  . anirvan @ chatterjee.net .  PGP 2048/0xE2D13BA9
Fast & free new/used multi-bookstore searching @ http://www.mxbf.com/


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

Date: Wed, 11 Mar 1998 23:58:26 -0500
From: "Steve Sunshine" <sunshine@infinet.com>
Subject: Lots of work for CGI PROGRAMMER
Message-Id: <6e7puo$f9a@news1.infinet.com>

Looking for a contract programmer located near Dayton Ohio.

MSQL, PERL, C

Email me qualifications, time schedule and rates directly  to

steve@webmarkservices.com

Thank You.




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

Date: Thu, 12 Mar 1998 08:42:10 -0000
From: "Ben" <ben@wallroyds.demon.co.uk>
Subject: New problem ....
Message-Id: <889692133.25548.0.nnrp-02.c2de5b4a@news.demon.co.uk>

The print stuff problem has solved ... But this one can't be solved by
myself ....

Can't find string terminator "end_of_html" anywhere before EOF at id2.cgi
line 3
 .

The code is ...

#!/usr/local/bin/perl

print <<"end_of_html";

Content-Type: text/html\n\n
<HTML>\n
<BODY BGCOLOR=\"#000000\" TEXT=\"#FF0000\">\n\n
<FONT FACE=\"vendana\" SIZE=\"3\">\n
Your IP address - $ENV{'REMOTE_ADDR'}\n\n
</BODY>\n
</HTML>

end_of_html

Anyone?

Sorry again for posting so many questions!

Regards

Ben :)




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

Date: Thu, 12 Mar 1998 08:09:04 -0000
From: "Ben" <ben@wallroyds.demon.co.uk>
Subject: Newcomer problem :) Cus I'm 17 :)
Message-Id: <889690147.24847.0.nnrp-02.c2de5b4a@news.demon.co.uk>

I'll paste the code and tell you what happened ...

-- The start of the code --

#!/usr/local/bin/perl

print <<"end_of_html";
Content-Type: text/html
<HTML>
<BODY BGCOLOR="#000000" TEXT="#FF0000">
<FONT FACE="vendana" SIZE="2">
Your IP address - $ENV{'REMOTE_ADDR'}
</BODY>
</HTML>
end_of_html

-- The end of the code --

When I tried to run it via telnet (perl id.cgi) .... Then I got ...

-- The start of the error message --

Can't find string terminator "end_of_html" anywhere before EOF at id.cgi
line 3
 .

-- The end of the error message --

ANYONE? ....

Thanks in advance!

Regards

Ben :)




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

Date: Thu, 12 Mar 1998 08:13:33 -0000
From: "Ben" <ben@wallroyds.demon.co.uk>
Subject: Re: Newcomer problem :) Cus I'm 17 :)
Message-Id: <889690415.24957.0.nnrp-02.c2de5b4a@news.demon.co.uk>

Oh sorry! Have just realised the answer ....

<BODY BGCOLOR="#000000"> ... WRONG!

<BODY BGCOLOR=/"#000000/"> .... RIGHT?

Ain't I right? :)

Regards

Ben :)

Ben wrote in message
<889690147.24847.0.nnrp-02.c2de5b4a@news.demon.co.uk>...
>I'll paste the code and tell you what happened ...
>
>-- The start of the code --
>
>#!/usr/local/bin/perl
>
>print <<"end_of_html";
>Content-Type: text/html
><HTML>
><BODY BGCOLOR="#000000" TEXT="#FF0000">
><FONT FACE="vendana" SIZE="2">
>Your IP address - $ENV{'REMOTE_ADDR'}
></BODY>
></HTML>
>end_of_html
>
>-- The end of the code --
>
>When I tried to run it via telnet (perl id.cgi) .... Then I got ...
>
>-- The start of the error message --
>
>Can't find string terminator "end_of_html" anywhere before EOF at id.cgi
>line 3
>.
>
>-- The end of the error message --
>
>ANYONE? ....
>
>Thanks in advance!
>
>Regards
>
>Ben :)
>
>




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

Date: Thu, 12 Mar 1998 08:23:46 -0000
From: "Ben" <ben@wallroyds.demon.co.uk>
Subject: Re: Newcomer problem :) Cus I'm 17 :)
Message-Id: <889691028.25154.0.nnrp-02.c2de5b4a@news.demon.co.uk>

Eck! Ignore this now .... The problem has solved ...

/" ..... WRONG!

\" .... RIGHT!

Sorry that I'm putting those stupid questions in ....

Regards

Ben :)

Ben wrote in message
<889690415.24957.0.nnrp-02.c2de5b4a@news.demon.co.uk>...
>Oh sorry! Have just realised the answer ....
>
><BODY BGCOLOR="#000000"> ... WRONG!
>
><BODY BGCOLOR=/"#000000/"> .... RIGHT?
>
>Ain't I right? :)
>
>Regards
>
>Ben :)
>
>Ben wrote in message
><889690147.24847.0.nnrp-02.c2de5b4a@news.demon.co.uk>...
>>I'll paste the code and tell you what happened ...
>>
>>-- The start of the code --
>>
>>#!/usr/local/bin/perl
>>
>>print <<"end_of_html";
>>Content-Type: text/html
>><HTML>
>><BODY BGCOLOR="#000000" TEXT="#FF0000">
>><FONT FACE="vendana" SIZE="2">
>>Your IP address - $ENV{'REMOTE_ADDR'}
>></BODY>
>></HTML>
>>end_of_html
>>
>>-- The end of the code --
>>
>>When I tried to run it via telnet (perl id.cgi) .... Then I got ...
>>
>>-- The start of the error message --
>>
>>Can't find string terminator "end_of_html" anywhere before EOF at id.cgi
>>line 3
>>.
>>
>>-- The end of the error message --
>>
>>ANYONE? ....
>>
>>Thanks in advance!
>>
>>Regards
>>
>>Ben :)
>>
>>
>
>




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

Date: Thu, 12 Mar 1998 04:05:04 GMT
From: kcurrie@cisco.com (Kevin Currie)
Subject: Program cores if not runder under debugger (redhat 5 only)
Message-Id: <35075d44.16684187@usenet.cisco.com>



	I just changed workstations and installed Redhat 5 instead of
the Caldera Openlinux I was running.
	When I try to run the "spong-display.cgi" program (the display
part of the SPONG network monitoring package-- highly recommended) it
dumps core with a segmentation fault.  If I run it with -d and then do
a "c", the program will run without incident.
	What does the debugger set up that is different?  Note that
this script runs fine on Solaris and OpenLinux 1.1.  The version of
perl in all cases is 5.004_01.  Redhat 5 uses glibc BTW.




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

Date: Thu, 12 Mar 1998 02:21:26 GMT
From: mwsasser!nospam!@timetrend.com
Subject: Re: random numbers?
Message-Id: <35074687.927984@news.ax.centuryinter.net>

	Boy do I feel like a goober.  Thanks all for the answers.
I'll get myself straight eventually.


On Mon, 09 Mar 1998 00:07:22 GMT, mwsasser!nospam!@timetrend.com
wrote:

>	I'm trying to generate real random numbers but all I generally
>get are numbers from 8 to 14 when I try adding 3 random numbers from 1
>to 6.  Should not 9 be the average number here?  I'm trying
>int(rand(6)+1)   what am I missing?



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

Date: Wed, 11 Mar 1998 23:11:35 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Skipping within a line to read URL?
Message-Id: <1d5qyvc.1dxihc71rqd0ibN@roxboro0-003.dyn.interpath.net>

Craig Berry <cberry@cinenet.net> wrote:

> John Moreno (phenix@interpath.com) wrote:
> : That it doesn't have a space would depend upon how the url is being
> : stored - file names can and do have spaces in them, so that MIGHT not be
> : able to be guaranteed.
> 
> I don't think urls can have spaces in them, however.  (I'm ready to have
> this disproved, if someone knows something I don't.)

They usually get encoded as %20, but some programs can handle it.
 
> : But since it seems to be on just one line. my ($url) = $line =~ /access
> : to (.+)$/;
> 
> That won't work; see the original post, there's error-message text 
> following the url.

The comments in the example are on another line - and it doesn't say
whether that's because the line would be over 80 chars long or because
that's the way it is.

But looking at the message closer, the character that starts off the
next line is a L, not capital a i - looks like his newsreader broke
inside a word.  Which probably means that everything is on the same
line.

If spaces are disallowed I'd use: my ($url) = $line =~ m#(\S*/[^ ]+)#;

Your sig should be preceded by a line consisting of "-- " (I'd recommend
changing the lines of dashes with a sigdash).

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

-- 
John Moreno
I am trying to convince the author of YA-NewsWatcher that the latest
version should be released to the public.  He doesn't think there's much
interest in a new version.  Help me prove him wrong.  To do so, send me
mail <mailto:phenix@interpath.com> with a Subject of New YA.  Comments
on what you like/dislike in the current version will be appreciated.


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

Date: Thu, 12 Mar 1998 06:46:01 GMT
From: hazzard@usa.net (Jason Hazzard)
Subject: Sorry... Need A DBM to USE!
Message-Id: <MPG.f712373302067ee989697@news.direct.ca>

I have read a lot of pages...

And i have seen that SDBM is guaranteed to be there!

But i try.. use SDBM_file;

and i get an error......How do i use SDBM with perl installed, if no 
other packages exist! Is the use SDBM_File wrong?  I am quite confused!


I just need a DBM package to work, but all seem to fail, using tie()

Ohh, please help. I need some basic instruction i am missing :(

JAy


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

Date: 12 Mar 1998 04:39:30 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: splice -- useful uses?
Message-Id: <6e7ou2$3jn$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, Uri Guttman <uri@sysarch.com> writes:
:i will admit your version is faster since there is no slicing, but both
:algorithms are linear. unless you are counting the slice (shifting down
:the array) as the quadratic behaviour.

This is a slice:  @foo[5,2,18]
This is a splice: splice(@foo, 4, 5);

It takes linear time (N) to perform *each* splice.  Therefore, 
performing one splice for each element (N) in an array is itself 
a quadratic operation (N**2).

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

Let us be charitable, and call it a misleading feature  :-)
        --Larry Wall in <2609@jato.Jpl.Nasa.Gov>


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

Date: 12 Mar 1998 05:31:41 GMT
From: michael@flash.net (Michael W Peterson)
Subject: Re: splice -- useful uses?
Message-Id: <6e7rvt$fbu$1@excalibur.flash.net>

On 12 Mar 1998 02:12:40 GMT, <tchrist@mox.perl.com> wrote:
> [courtesy cc of this posting sent to cited authors via email]
>
>In comp.lang.perl.misc, michael@flash.net (Michael W Peterson) writes:
>:On 12 Mar 1998 00:07:03 GMT, <abigail@fnx.com> wrote:
>:>I hate to see a quadratic algorithm being used a an example
>:>for what people use splice for if there's a linear algorithm
>:>doing the same.
>:>
>:>Knuth's algorithm:
>:>for ($i = @arr; $i; $r = rand $i --, @arr [$r, $i] = @arr [$i, $r]) {}
>:
>:Interestingly, the quadratic algorithm is faster (at least on my box):
>:Benchmark: timing 100000 iterations of c, perl...
>:         c: 50 secs (50.74 usr  0.01 sys = 50.75 cpu)
>:      perl: 37 secs (36.13 usr  1.88 sys = 38.01 cpu)
>
>Hold on there.  She's going to chew on your noggin for inappropriate
>benchmarks.

Consider it chewed. ;)

>You are comparing a trivial little 10 element array.
>Overhead will eat you up.  Try it more like this:
>
>    for ($N = 1; $N < 300; $N <<= 1) { 
>	@a = (0 .. 9) x $N;
>	** run the timing on @a here **
>    }

OK. I gave that a try.

>And you'll see that Abigail's clearly wins in the long run.  You can
>certainly have a situation where a quadratic algorithm (with low overhead)
>can beat a linear one (with high overhead).  That's what's going on
>here -- in the tiny cases, the more native way wins.  But keep doubling
>your data size and you'll see what I mean.  Hers eventually pulls ahead,
>as it inevitably must.  

But, as it appears from my results, not because the linear is faster.
The native quadratic algorithm continues be optimized to run faster, at
the cost of huge memory usage. The quadratic version slows down as the OS
thrashes about more and more trying to satisfy the ever-increasing memory
demands.

>Using just 10,000 iterations so things can get done in my lifetime,
>at $N == 32, here's what happened:
>
>    Benchmark: timing 10000 iterations of c, perl...
>	     c: 55 secs (54.59 usr  0.00 sys = 54.59 cpu)
>	  perl: 70 secs (41.60 usr  2.67 sys = 44.27 cpu)
>

When I ran it on my workstation, I got 'Out of Memory!' errors on the
quadratic algorithm at $N == 32. Bells went off at this point, so I threw
it on a bigger box where I could watch it easier and got the following:

$N==32 Benchmark: timing 10000 iterations of c, perl...
         c: 49 secs (47.98 usr  0.00 sys = 47.98 cpu) 
      perl: 31 secs (30.23 usr  0.70 sys = 30.93 cpu)

Memory usage starts at 2.4M and stays there while 'c' runs and then grows
to 68M while 'perl' runs.

$N==64 Benchmark: timing 10000 iterations of c, perl...
         c: 99 secs (97.36 usr  0.00 sys = 97.36 cpu)
      perl: 67 secs (64.46 usr  2.51 sys = 66.97 cpu)

Memory stays at 68M while 'c' runs again and then grows to 234M while
'perl' runs again.

-- 
Michael W Peterson                      <http://www.flash.net/~michael/>
Chief System Administrator              FlashNet Communications
Meddle not in the affairs of sysadmins, for they are subtle and quick to lart.


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

Date: 12 Mar 1998 05:46:47 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: splice -- useful uses?
Message-Id: <6e7ss7$s90$1@client3.news.psi.net>

Uri Guttman (uri@sysarch.com) wrote on 1654 September 1993 in
<URL: news:x71zw8zixi.fsf@sysarch.com>:
++ abigail@fnx.com (Abigail) writes:
++ 
++ > Andrew M. Langmead (aml@world.std.com) wrote on 1653 September 1993 in
++ > ++ klassa@aursgh.aur.alcatel.com (John Klassa) writes:
++ > ++ push @random, splice @orig, rand @orig, 1 while @orig;
++ > 
++ > I hate to see a quadratic algorithm being used a an example
++ > for what people use splice for if there's a linear algorithm
++ > doing the same.
++ > 
++ > Knuth's algorithm:
++ > for ($i = @arr; $i; $r = rand $i --, @arr [$r, $i] = @arr [$i, $r]) {}
++ 
++ i will admit your version is faster since there is no slicing, but both
++ algorithms are linear. unless you are counting the slice (shifting down
++ the array) as the quadratic behaviour.


Of course, with your rules, both algorithms are linear, if not
logarithmic. For everyone else, the splice solution is quadratic, Knuths
algorithm is linear.


Here is a small benchmark program:

#!/usr/local/bin/perl -w

use strict;
use Benchmark;

my  @sizes  = (50, 500, 5000, 50000);
my  $arrays = {map {$_ => [map {int rand 1000} 1 .. $_]} @sizes};

my (@orig, @arr);

timethese 100, [map {my $size = $_; (
    "splice $size" =>
        sub {@orig = @{$arrays -> {$size}} unless @orig == $size;
             my @random;           
             push @random, splice @orig, rand @orig, 1 while @orig           
        },           

    "knuth  $size" =>
        sub {@arr  = @{$arrays -> {$size}} unless @arr  == $size;
             my ($i, $r);           
             for ($i = @arr; $i;           
                  $r = rand  $i --, @arr [$r, $i] = @arr [$i, $r]) {}           
        },          
)} @sizes];

__END__

Benchmark: timing 100 iterations of splice 50, knuth  50, splice 500, knuth  500, splice 5000, knuth  5000, splice 50000, knuth  50000...
splice    50:   0 secs (  0.10 usr  0.00 sys =   0.10 cpu)
knuth     50:   0 secs (  0.11 usr  0.00 sys =   0.11 cpu)
splice   500:   1 secs (  1.05 usr  0.00 sys =   1.05 cpu)
knuth    500:   2 secs (  1.06 usr  0.00 sys =   1.06 cpu)
splice  5000:  16 secs ( 16.07 usr  0.00 sys =  16.07 cpu)
knuth   5000:  11 secs ( 10.58 usr  0.00 sys =  10.58 cpu)
splice 50000: 922 secs (887.08 usr  0.03 sys = 887.11 cpu)
knuth  50000: 124 secs (118.63 usr  0.01 sys = 118.64 cpu)


Still convinced they are both linear?

(I don't know why you even suggest not counting the splice(), after that's
 about all the one algorithm does).


Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: 12 Mar 1998 06:26:16 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: splice -- useful uses?
Message-Id: <6e7v68$2s8$1@client2.news.psi.net>

Tom Christiansen (tchrist@mox.perl.com) wrote on 1654 September 1993 in
<URL: news:6e7ou2$3jn$1@csnews.cs.colorado.edu>:
++  [courtesy cc of this posting sent to cited author via email]
++ 
++ In comp.lang.perl.misc, Uri Guttman <uri@sysarch.com> writes:
++ :i will admit your version is faster since there is no slicing, but both
++ :algorithms are linear. unless you are counting the slice (shifting down
++ :the array) as the quadratic behaviour.
++ 
++ This is a slice:  @foo[5,2,18]
++ This is a splice: splice(@foo, 4, 5);
++ 
++ It takes linear time (N) to perform *each* splice.  Therefore, 
++ performing one splice for each element (N) in an array is itself 
++ a quadratic operation (N**2).

It will depend on what you do with the splice. I use the first
form of splice in my implementation of Knuth's algorithm as well,
but since it's of the form @arr [$i, $j] = @arr [$j, $i], no 
shifting of the array needs to be done. [1]

The linear time comes from the need to shift the array, because
a slice is replaced by something of a different length.


[1] I ran Knuths algorithm again, now using ($arr [$i], $arr [$j]) =
   ($arr [$j], $arr [$i]) and it's about 5% faster that way. Small,
    but more than I expected it to be.


Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle 'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Additional/s) [0]'


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

Date: Thu, 12 Mar 1998 04:19:51 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: splitting by one or more spaces
Message-Id: <35075457.524144494f47414741@radiogaga.harz.de>

Oosterom (oosterom@e-mark.nl) wrote:
: I am trying to extract the date from the localtime value. I have to split
: this value, but if the daynumber is smaller than 10, there are two spaces
: before this number in the localtime value. This means I have to split by
: one or more spaces. The codes below don't work:

: ($day, $month, $daynr, $time, $year) = split (/*\s/, localtime);

: Any suggestions anyone? Thanks.

If you call localtime() in list context, you get numeric versions of
all of the fields:

($day, $month, $year) = (localtime)[3,4,5];

Beware that $month is in the range 0..11, and $year is the offset from 1900.

perldoc -f localtime

cu,
  Martin
--
                          | Martin Vorlaender | VMS & WNT programmer
 Ceterum censeo           | work: mv@pdv-systeme.de
 Redmondem delendam esse. |       http://www.pdv-systeme.de/users/martinv/
                          | home: martin@radiogaga.harz.de


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

Date: 12 Mar 1998 00:30:15 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: to: tom c. Re: splice -- useful uses?
Message-Id: <x7soooxyqg.fsf_-_@sysarch.com>


tom,

i tried replying to you but you filter out mediaone.net. might you add
my address in a pass through filter. we have met at the perl conference
and exchanged email before. i am not a spammer as you know nor a
winblows newbie. i am just using mediaone for its speed. i have my own
domain but those turds don't even do domain support yet. so check my
that my reply-to address is sysarch.com and my true address is
sysarch.ne.mediaone.net. 

thanx,

uri


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

>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc, Uri Guttman <uri@sysarch.com> writes:
> :i will admit your version is faster since there is no slicing, but both

> :algorithms are linear. unless you are counting the slice (shifting down
> :the array) as the quadratic behaviour.

tom,

note i said as such in the sentence above!! i am not that dumb. i just
look it.
 
> This is a slice:  @foo[5,2,18]
> This is a splice: splice(@foo, 4, 5);

duh, i do know the difference. one has a 'p' and the other doesn't! :-)

uri

-- 
Uri Guttman                     SYStems ARCHitecture and Software Engineering
uri@sysarch.com                                          Have Perl, Will Hack
http://www.sysarch.com                (781) 643-7504 x*2  FAX: (781) 643-2710
Try the Best Search Engine on the Net -------->  http://www.northernlight.com


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

Date: Wed, 11 Mar 1998 23:52:17 -0500
From: Duncan Speidel <dspeidel@thunder.ocis.temple.edu>
Subject: using exec to call telnet in perl
Message-Id: <Pine.OSF.3.91.980311233711.1456A-100000@thunder.ocis.temple.edu>

Hi Everybody,

I use several different servers all are some variety of unix.  I have a 
base server that I always check first get my mail and then from there I 
telnet to one of the servers that I'm currently working with (I am a CIS 
student at Temple University and very few classes use the same machine).  
I figured I could do the telnet quickier if i wrote a script to connect 
to the machine.  The script below took no time to create and it 
intializes telnet okay its after the exec that things get weird.  I can 
enter user name in okay but after I push enter and it prompts me for my passwd 
problems arise.  First I now can see the password that I'm entering (no 
biggie I figured that the script was echoing my input to the screen and 
ignoring the password hiding function of the remote machine- I know this 
as a name but I never dealt with it).  The bigger 
problem is that when I enter the password it doesn't all arrive.  I tried 
just entering the known password and not worring about so charecters not 
appearing -login failed.  I entered the password so it all appeared 
-login failed.  I'm now wondering if forking a telnet from the parent is 
possible. The script used is below
#!/usr/local/bin/perl
#y.pl 3/12/98 by Duncan Speidel
if (!defined($kidpid=fork()) )
{
#fork failed
        warn "could not fork: $!";
}
elsif ($pid==0){
#fork returned zero so this is the child process
#including user name and password as print commands fail to help
#including user name as an argument to exec gives invalid port error
        exec("telnet yoda.cis.temple.edu");
        die "can't execute telnet $!";
}else {
        #fork returned neither 0 nor undef so this branch is the parent
        waitpid($kidpid, 0);
} 

#end script

The yoda account is on a Sun Solaris (ver 2.4 I think). The script itself 
is called from a Alpha running Digtial Unix 64

An suggestions would be greatly apperciated
Thanks in Advance,
Duncan 


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

Date: Thu, 12 Mar 1998 04:39:23 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Way of testing whether a variable is blessed
Message-Id: <350758eb.524144494f47414741@radiogaga.harz.de>

Allen Choy (achoy@us.oracle.com) wrote:
: Is there a standard way of testing whether a variable is blessed or not?

ref($var) !~ /^(?:REF|SCALAR|ARRAY|HASH|CODE|GLOB)$/;

Or is there anything else ref() could return if $var isn't blessed
into a package?

: The only way I can think of is testing whether a reference has an '='
: sign.

Where would that come from?!

cu,
  Martin
--
                          | Martin Vorlaender | VMS & WNT programmer
 Ceterum censeo           | work: mv@pdv-systeme.de
 Redmondem delendam esse. |       http://www.pdv-systeme.de/users/martinv/
                          | home: martin@radiogaga.harz.de


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

Date: Thu, 12 Mar 1998 00:21:00 -0600
From: crlin@hotmail.com
Subject: where can I find the on line books
Message-Id: <6e7upo$qcs$1@nnrp1.dejanews.com>

  I want to find the on line text of books about perl such as "PROGRAMMING
PERL",

"LEARNNING PERL" and etc.Pleas tell me where can I find them or mail to me.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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


------------------------------
End of Perl-Users Digest V8 Issue 2080
**************************************

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