[10127] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3720 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 15 14:08:35 1998

Date: Tue, 15 Sep 98 11:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 15 Sep 1998     Volume: 8 Number: 3720

Today's topics:
    Re: assigning file contents to a string <murrayb@vansel.alcatel.com>
        cypt help (Richard Zilavec)
    Re: cypt help (David A. Black)
    Re: File mod time in future? (Mike Stok)
    Re: finding out yesterdays date (Larry Rosler)
    Re: finding out yesterdays date (Noble Thomas)
        flock error <ldc023@nabu.isg.mot.com>
    Re: getting number of elements in multiple dimensions <uri@camel.fastserv.com>
        HELP (bug?) : backtick and system return different valu <pomarede@isty-info.uvsq.fr>
        How to pass perl script's STDIN to Korn shell's ARGV nguyen.van@imvi.bls.com
    Re: HTTP-Proxy written in Perl - Possible? How? <arno@gmx.de>
    Re: Long Int representation ? <jhi@alpha.hut.fi>
        Looking for a FORM cgi script. (Richard Dols)
    Re: milliseconds? <jhi@alpha.hut.fi>
        Net::FTP Problems shawn_campbell@my-dejanews.com
    Re: Perl & Java - differences and uses (Abigail)
    Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
    Re: Perl & Java - differences and uses <uri@camel.fastserv.com>
        print statement in perl <tpham@ee.gatech.edu>
    Re: reserving explicit memory for a hash reference... <zenin@bawdycaste.org>
        Script to add user accounts from the web <ava@softclub.net>
    Re: script: scriptMangle! (Craig Berry)
        stock quote service (Tom Tingdale)
    Re: Transposing an array (Abigail)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 15 Sep 1998 08:24:11 -0700
From: Brad Murray <murrayb@vansel.alcatel.com>
Subject: Re: assigning file contents to a string
Message-Id: <uaf41o0v8.fsf@vansel.alcatel.com>

avern@hotmail.com writes:

> I know this is a very newbie-ish question, but I've already checked the FAQ. 
> Does any know a very concise way (say, 1 line) to assign the contents of a
> file to a string variable? I've seen instructions on processing a file
> line-by-line or paragraph-by-paragraph, but I don't want to manipulate the
> file contents in any way.  I just want to store the entire file in a
> variable, so that I can later refer to the variable in a print statement. 
> Can this be done without creating a sub-procedure?


open FH, "somefile.name";

# $stuff contains a single string whose contents are the file
# @stuff is an array of all lines in the file

$stuff = join ("", @stuff = <FH>);

If you just want the array, it's even more concise:

@stuff = <FH>;


-- 
"Never trust a man in a blue trenchcoat,           Brad Murray
 Never drive a car when you're dead."         Software Analyst
 (Tom Waits)                                    Alcatel Canada


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

Date: Tue, 15 Sep 1998 16:24:40 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: cypt help
Message-Id: <35fe93d8.8809713@199.166.4.3>

I just tried some code from a book I purchased(Programming Perl) to
find a password:

if(crypt($in{'password'}, $passwd) ne $passwd) {
                Error(3);
                exit();
        }

The problem is that if

username: bill
password: billy

it will accept billy, billyy, billyasdfkakdfj but not anything
shorter.  Is there a way to prevent this?

Richard


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

Date: Tue, 15 Sep 1998 12:36:07 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: cypt help
Message-Id: <6tm51n$duh$1@earth.superlink.net>

Hello -

rzilavec@tcn.net (Richard Zilavec) writes:

>I just tried some code from a book I purchased(Programming Perl) to
>find a password:

>if(crypt($in{'password'}, $passwd) ne $passwd) {
>                Error(3);
>                exit();
>        }

>The problem is that if

>username: bill
>password: billy

>it will accept billy, billyy, billyasdfkakdfj but not anything
>shorter.  Is there a way to prevent this?

I cannot duplicate your error.  Can you show a complete working
script which allows for inaccurate passwords?  

Here is a version that works:

my $cr = crypt("billy", time);
print "Password: ";
my $pw = <STDIN>; chomp $pw;

if(crypt($pw, $cr) ne $cr) { print "Bad password\n" }
else { print "Correct\n" }


I can't get it not to work.

David Black
dblack@saturn.superlink.net


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

Date: 15 Sep 1998 17:04:53 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: File mod time in future?
Message-Id: <6tm6nl$qj3@news-central.tiac.net>

In article <35FE709A.C9D9BFCD@cowboys.anet-dfw.com>,
Tom Turton  <tturton@cowboys.anet-dfw.com> wrote:
>In some simple scripts I've written, I've used (with no problems before)
>a file modification test to see how long since a file has been modified:
>
>     if (-M $filename >= $age_set) {}
>
>Now one of my scripts is not executing the if-block code, and when I put
>debug print statements I find that the modification time is NEGATIVE!?
>About 5-7 minutes (-0.0037037 to -0.004976851851).

Sometimes excitement like this happens if you're storing files on a file
server whose idea of the current time is different from the machine you're
running on.

Just a thought,

Mike
 
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Tue, 15 Sep 1998 09:10:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: finding out yesterdays date
Message-Id: <MPG.1068314fc85bf887989859@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <6tkp8s$qv2$1@newsflash.concordia.ca> on 15 Sep 1998 04:09:00 
GMT, Neil Kandalgaonkar <neil@domingo.concordia.ca> says...
> In article <35fd5a3e.8691503@news.ais.net>, Steve . <syarbrou@ais.net> wrote:
> >I have a system that outputs a comma delimited file and then is passed
> >to my linux box.  The first field is the date like 09/14/98.  The date
> 
> hm, I wonder what would happen in the year 2000? 
> 
> come to think of it, there are a lot of programs out there like this...
> 
> it's 1998 -- use four digit years.

Why?  No one else will.

One of the great lies about the century bug is accusing programmers of 
short-sightedly saving on storage by storing years with only two digits.  
They were simply following the vernacular use of referring to years by 
the year of the century only.

In a couple of years, our checks will again have the date field filled 
in, with 20___, and New Year's Day will be 01/01/00.  So don't fight it.

$year % 100 

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 15 Sep 1998 16:17:16 GMT
From: nthomas@eclipse.cise.ufl.edu (Noble Thomas)
Subject: Re: finding out yesterdays date
Message-Id: <6tm3uc$f65$1@thunder.cise.ufl.edu>

Steve <syarbrou@ais.net> wrote:

> I want to be able to reset the dates that are sent to one day less.  Is
> there somthing to do this?  So if the date is stamped 09/14/98 I want it
> to be 09/13/98.  Thanks.

As someone already pointed out, Date::Manip is excellent for this sort of
thing, here is one solution to your problem using this module:

# --------------------
#!/local/bin/perl

use Date::Manip;
$date="09/14/98";
$date=&Date_GetPrev($date,undef,0,0);
$date=&UnixDate($date,"%m/%d/%y");

print "$date\n";
# --------------------

peace,
noble

---------------------
N. Thomas
nthomas@cise.ufl.edu
---------------------


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

Date: Tue, 15 Sep 1998 12:11:55 -0400
From: David Capredoni <ldc023@nabu.isg.mot.com>
Subject: flock error
Message-Id: <35FE91CA.32D064EC@nabu.isg.mot.com>

Hi

I'm trying to lock a file using the flock command,  It works on hpux,
however it
won't work on Sun Microsystems Inc. SunOS 5.5.1.  Do any of you know how
to make the flock command work for the Sun system.  The code is below:

sub ReqNumber {

    my($dLock) = "/tmp/file1.lock";
    my($LOCK_SH) = 1;
    my($LOCK_EX) = 2;
    my($LOCK_NB) = 4;
    my($LOCK_UN) = 8;

    print "<pre>\n" if $verbose;

    # see if need to wait on semaphore (lock file)
    open ( DLOCK, ">>$dLock" )  or die "Can't open lockfile, $dLock:
$!\n";

    # lock semaphore or wait
    unless (flock (DLOCK, ($LOCK_SH | $LOCK_NB)) ) {
        print "$$: CONTENTION; waiting for lock ($!) ..." if $verbose;
        unless (flock (DLOCK, $LOCK_SH)) { die "flock($LOCK_SH): $!\n" }

    }
     print "$$: lock granted\n" if $verbose;

    #perform code here


    flock(DLOCK, $LOCK_UN);        # unlock semaphore
    close DLOCK;
    print "</pre>\n" if $verbose;
}

The error that I get on the Sun system is flock(1): Bad file number.

Thanks



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

Date: 15 Sep 1998 13:28:49 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: lr@hpl.hp.com (Larry Rosler)
Subject: Re: getting number of elements in multiple dimensions
Message-Id: <sariuip8eum.fsf@camel.fastserv.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
  >> For example: $stuff[4][5] = "dog";
  >> 
  >> how would you return "5" if that was the last element in the array?

  LR> Amazing -- identical question twice in one day.

  LR> $#{$stuff[4]}

that's whay they call them FAQ!

:-)

uri

-- 
Uri Guttman                             Speed up your web server with Fast CGI!
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Tue, 15 Sep 1998 18:20:23 +0200
From: Nicolas Pomarede <pomarede@isty-info.uvsq.fr>
Subject: HELP (bug?) : backtick and system return different value !!
Message-Id: <35FE92BB.3CBFFA72@isty-info.uvsq.fr>

Hello,

I have a big problem which pops up when my perl program executes an
external script and then get the exit status.

Here're 2 sample scripts which cause the bug :


a.pl (this is the main script, calls bb.sh):
----

#!/usr/bin/perl -w

$res=`/etc/ppp/bb.sh`;
print "res $res ret $?\n";

system ( "/etc/ppp/bb.sh" );
print "ret2 $?\n";


and /etc/ppp/bb.sh
------------------

#!/bin/sh
echo "bb done"
exit 4


Then, I run a.pl :

res bb done ret 1024
ret2 1024

So here, both invocations of system and `` give the same result.

But if I use a crontab or the at command to run a.pl at a fixed date,
I get :

res bb done ret -1
ret2 1024



This means that whatever I return in my exit in bb.sh, I always get -1
as exit code in a.pl !!

I tried to run this exemple as root or another user, but it's the same.

My perl version is 5.00401 (5.0 patchlevel 4 subversion 1), running on a
Red Hat 5.1.


BUT, when I run these examples on a Red Hat 4.1 with perl 5.0 patchlevel
3 subversion 0, they always work fine in all the situations.

So, am I missing an env variable, is there a problem with the red hat
perl version, or is this a bug in perl ??


Please, send any possible help, because I'm really becoming crazy ;
I have many scripts in perl which need the result $? of the backtick
operator, and I don't see any solution for now.

Also, forward your answer to pomarede@paris.kapt.com, because I don't
browse news on a regular basis.


----------------
Nicolas Pomarede                e-mail:      pomarede@isty-info.uvsq.fr
                                             pomarede@paris.kapt.com


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

Date: Tue, 15 Sep 1998 17:09:31 GMT
From: nguyen.van@imvi.bls.com
Subject: How to pass perl script's STDIN to Korn shell's ARGV
Message-Id: <6tm70b$bst$1@nnrp1.dejanews.com>

Hi guys,

how can I pass a perl script's STDIN to be a korn shell script's argument.
This is the codes which I had in my perl script which calls korn shell
script.

-------------------------------------------------------
$DATE = <STDIN>;
chomp($DATE);
`browser_crno.ksh $DATE > $DOCS_DIR/browser_crno.html`;
_------------------------------------------------------

what's wrong with this code? It seems not working for me. Your help is
appreciated.

THanks
Van

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 15 Sep 1998 18:22:35 +0200
From: "A. Beckmann" <arno@gmx.de>
Subject: Re: HTTP-Proxy written in Perl - Possible? How?
Message-Id: <35FE944B.3F0BAD48@gmx.de>

Gary Mc Closkey wrote:
> As an alternative, try the Xitami web server, free,
> OpenSource, multiple platform, easy to use, small footprint.
> See  http://www.imatix.com/   .
> I  have no connection, apart from being a very happy user.

Thank. I'm using Xitami as a test server on W95 sometimes.
I'll try to compile the unix sources, cause the proxy
should run on different Unix systems by remote.

Compiling, installing, testing by telnet... much 2 do.

Thanks, Arno


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

Date: 15 Sep 1998 19:41:04 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Long Int representation ?
Message-Id: <oeek935z5un.fsf@alpha.hut.fi>


sjagadish@my-dejanews.com writes:

> Can I use Long Integer representation in Perl ? How do I do it ?

No, at the moment you can't use long longs (et alia) natively in
Perl.  But you might want to use the

	Math::BigInt

package instead.  It's not as fast as being native but for light
work, it should be okay.

> thanks
> 
> jagadish
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: Tue, 15 Sep 1998 17:49:45 +0200
From: Red.Digital@usa.net (Richard Dols)
Subject: Looking for a FORM cgi script.
Message-Id: <MPG.1068aaffb79cba3598968f@news.tip.nl>

Hello Everyone.

MY old ISP used a cgi script for WWW > e-mail gate. Very common, i know. 
but when he send a e-mail to me the body containd the following 
information.

DATE            : 
PROCESSED_URL   : 
REMOTE_HOST     : 
REMOTE_ADDR     : 
SERVER_NAME     : 
HTTP_USER_AGENT : 

My new ISP has a complete other cgi script. but i can use my own scripts. 
so i'm looking for this, or simular one.
Onyone a idea where i can download this script?

Maybe someone knows a good url for freeware CGI scripts?

Grtx, Richard Dols


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

Date: 15 Sep 1998 19:42:09 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: milliseconds?
Message-Id: <oeehfy9z5su.fsf@alpha.hut.fi>


miho21@yahoo.com writes:

> Huh? can anyone explain that please? what does qw has to do with anything???
> qw is a built in function? how come i never heard of it?

Not a function, an operator.  Peruse perlop.

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: Tue, 15 Sep 1998 16:27:47 GMT
From: shawn_campbell@my-dejanews.com
Subject: Net::FTP Problems
Message-Id: <6tm4i5$94p$1@nnrp1.dejanews.com>

I am having a very similar problem to the following:

'A Privileged Port Was Requested'

Does anyone have any ideas?  Is it a security problem with the ftp server or
firewall?

Thanks,

Shawn Campbell

>Subject: Re: Net::FTP and ActiveState Perl
>From: Ed Kear <ed@roundthebend.com>
>Date: Mon, 17 Aug 1998 6:17:12
>X-Message-Number: 4

>I've been having problems too.

>Sample code:
>use Net::FTP;

>$ftp = Net::FTP->new("ftp.foo.com");  print $ftp->message();
>$ftp->login("yyyy","xxxxx");  print $ftp->message();
>$ftp->cwd("WWW-Pages");  print $ftp->message();
>$ftp->ascii();  print $ftp->message();
>print "Downloading\n";
>$ftp->get("index.html"); print $ftp->message();
>$ftp->quit;

>Results:
>FTP server (Version 4.122 Wed Nov 5 23:06:48 EST 1997) ready.
>User yyyy logged in.
>CWD command successful.
>Type set to A.
>Downloading
>Will not send to privileged port.

>I also get the same "Will not sent to privileged port" when try
>$ftp->put("localfile","remotefile").

>Ed Kear

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 15 Sep 1998 16:00:35 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl & Java - differences and uses
Message-Id: <6tm2v3$7pe$1@client3.news.psi.net>

Zenin (zenin@bawdycaste.org) wrote on MDCCCXLI September MCMXCIII in
<URL: news:905868425.452048@thrush.omix.com>:
++ Abigail <abigail@fnx.com> wrote:
++ : Zenin (zenin@bawdycaste.org) wrote on MDCCCXLI September MCMXCIII in
++ : <URL: news:905830672.564598@thrush.omix.com>:
++         >snip<
++ : Please show me an easy to use data encapsulation method to use with
++ : Perl-OO. (Beyond the simple "Don't touch that!") I've been looking for years.
++ 
++         Are you looking for a real electric fence, or just something that
++         looks like one?  I was working on a real one with the electricity
++         turned off, until the betas of 5.005 got fields.pm, which did
++         a bulk of what I was trying to do in a much better way.
++ 
++         The electricity is still turned off though.  The only way I've found
++         to turn it up is to tie your object's thingy, which forces two
++         method lookups for every access. :-(  Fields.pm helps, but only
++         for compile time.  Run time lookups are wide open.

It's not whether one uses method lookups or not. That's irrelevant.
The point is where data is *stored*, not how you access it. The usual
implementation of OO in Perl is by using a blessed hash. Which means
that all the classes use the same scribble area.

I guess you would tear your hairs out of your head if Perl wouldn't have
name spaces, but dumped everything in main::. I can't believe that the
people who designed Perl5 though it was acceptable behaviour for OO-Perl.

++         All that said, you're right.  There is no way to fully keep someone
++         out of your sand box if they really want in.  And there is no
++         simple way to put up a big fence.

I don't care about people keeping out if they really want in. But you
don't want to accidentially use the same storage space for a piece of
data as one of the classes you inherit does.


George is right in the sense that if you want a true OO environment,
suitable for several programmers to work on the same project, Perl is
a lousy choice.



Abigail
-- 
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT


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

Date: 15 Sep 1998 16:24:12 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <905876301.453090@thrush.omix.com>

Andrew M. Kuchling <akuchlin@cnri.reston.va.us> wrote:
        >snip<
: 	That's interesting; what 5.005 regex features do you use, and
: for what purpose?  From the list of:
        >snip<

        Zero-width negative lookbehind assertion is a great help with
        mini-tokenizers.  Without it, finding foo not proceeded by
        bar is a pain, or slow, or both, depending.

        I've played with subexpressions, but haven't made them do anything
        I've really found useful yet.  All in due time. :-)

: 	None of these except feature 4 seems a vast advance over
: 5.004's notation.

        Conditional expressions and eval code inside a regex work well
        together.

        After all, how useful would logic inside a regex if it could not
        change the course of the regex?

        ## Are we funky?
        sub is_funky (1);  ## Yes, we are

        /some common pattern (?(?{ is_funky() })funky|normal)/

        Sure, you could do:

        if (is_funky) {
            /some common pattern funky/;
        }
        else {
            /some common pattern normal/;
        }

        But if you're dealing with a large pattern, possibly with many
        different switches, this gets ugly quick.  Dynamically building
        the expression is another option, but it has many drawbacks (namely,
        speed).

: My intuition is that they're all aimed at highly
: sophisticated users,

        I'd say so too, but why should it matter?

: and most uses of regular expressions are simple.

        True.  But in the tradition of making simple things simple and hard
        things possible, they do help with the hard things quite a bit.

: In particular, 2 and 4 require that you have a very good idea of how
: the regular expression engine operates.

        Why?  2 can be funky, but 4 is pretty straightforward I'd say.
-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: 15 Sep 1998 13:20:16 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <sark9358f8v.fsf@camel.fastserv.com>

>>>>> "A" == Abigail  <abigail@fnx.com> writes:

  A> It's not whether one uses method lookups or not. That's irrelevant.
  A> The point is where data is *stored*, not how you access it. The
  A> usual implementation of OO in Perl is by using a blessed
  A> hash. Which means that all the classes use the same scribble area.

dearest sweet abby,

how about this idea to separate class data in an object. create a hash
ref as the top level object and its top level keys are the names of the
classes with another hash ref for a value. then each class can have its
own hash to scribble in. and if they behave nicely they can peek into
others in the same object by climbing up the class tree and looking at
those hashes. possibly even top level data can be kept in the object as
long as the keys are not in the form of a class name.

this could even be folded into some new syntax/semantics. when you
dereference a hash object, you automatically get the current class's
subhash. i won't propose the new syntax but i am sure larry, et al, can
come up with something nice. maybe a variant on bless will create this
new class private hash off the main object. i feel this is an avenue to
explore. 

this is not a fully worked out idea so don't flame me for this.

uri


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

Date: Tue, 15 Sep 1998 13:24:29 -0400
From: Tien Pham <tpham@ee.gatech.edu>
Subject: print statement in perl
Message-Id: <35FEA2CD.C006DC97@ee.gatech.edu>

Hello there,

I have a question regarding to Perl.

On page 117 of "Programming Perl" by O'Reilly & Associates,
there is an example (near the bottom of the page) showing
how to pass arrays using typeglob approach.
I include the example here for convenience:

     (*a, *b) = func(\@c, \@d);
     print "@a has more than @b\n";
     sub func {
        local (*c, *d) = @_;
        if (@c > @d) {
           return (\@c, \@d);
        }
        else {
           return (\@d, \@c);
        }
     }

Notice how @a and @b are printed in the print statement in
the codes above.

I follow pretty much the method shown on that page, but I
always got error message when I executed my Perl program:

    % In string, @cout now must be written as \@cout at
      add.prl line 17, near "@sum \t @cout"
      Execution of add.prl aborted due to compilation errors.

This is my Perl program:
-----------------------

@x = ([1,0,1], [0,1,1]);
@y = ([1,1,1], [1,1,0]);

$row = $#x;
$col = $#{$x[0]};

for $time (0..$row) {
  (*sum,*cout) = add_arr (\@x,\@y);
  print "@sum \t @cout \t aaa\n";
}

sub add_arr {
  local (*x,*y) = @_;
  print STDOUT "@x\t@y\tbbb\n";

  return (\@x,\@y);
}

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

Basically, it complains that I cannot have @sum or @cout like that
in the quotation.  According to the book, I can.

If I add another print statement to the program:

 ...
for $time (0..$row) {
  (*sum,*cout) = add_arr (\@x,\@y);

  print @sum, "\t", @cout, "\t aaa\n";      <---- Added
  print "@sum \t @cout \t aaa\n";
}
 ...

Both statements are executed properly!  Without the added
line, the 2nd print statement will give error message.

Does anybody know what's going on, and how to fix this?

thanks,

tien pham
tpham@ee.gatech.edu


--
Plan:

To live
 To enjoy
  To appreciate
   every opportunity and every minute here, in America!
--------------------------------------





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

Date: 15 Sep 1998 16:39:53 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: reserving explicit memory for a hash reference...
Message-Id: <905877242.774488@thrush.omix.com>

[posted & mailed]

Gerald Kropitz <gkropitz@ghome.intern.Austria.EU.net> wrote:
: while (%ccc = $qh->fetchhash) {
: 	push @{$zzz[0]}, \%ccc;
: }
: after finishing the loop i can pop from zzz but the hash
: reference seems to be dysfunctional... i suspect that i'm
: overwriting the same memory area every loop...
        >snip<

        Yep.  It's a scoping issue.  %ccc is in the same scope for
        every iteration of the loop.  It might as well be global if it
        isn't already.  As such, any references to it will all be the
        same, regardless of the number of times you take a reference off
        it.

: is there a more intelligent solution out there?

        Yes, limit the life of %ccc to one iteration of the loop like
        so:

        while (my %ccc = $qh->fetchhash) {
            push @{$zzz[0]}, \%ccc;
        }

        -Just the "my" was added.

        Hope this helps!
-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Tue, 15 Sep 1998 20:02:12 +0400
From: "Alexei V. Alexandrov" <ava@softclub.net>
Subject: Script to add user accounts from the web
Message-Id: <35FE8F84.822359DD@softclub.net>

I would like to write a script that would add users from web.
So a user can register his account on the fly from the web. Like
geocities or tripoid. I don`t want to invent a circle. Is there a script
that makes it?


-- 
----
  s uWAVENIEM,
  aLEKSEJ w. aLEKSANDROW
  Mail: ava@softclub.net
  WWW:  www.softclub.net


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

Date: 15 Sep 1998 16:45:17 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: script: scriptMangle!
Message-Id: <6tm5it$fn8$1@marina.cinenet.net>

Tom Christiansen (tchrist@mox.perl.com) wrote:
: There are only two solutions to preventing "theft": either give the
: thing away right from the get-go, or else slap a killer licence on it.

Only the former actually prevents 'theft', by defining it out of
existence.  The latter gives you (better) legal recourse to punish theft
if it occurs.  And nobody is talking about 'preventing' theft; the idea
(if one takes such a path) is to *discourage* it -- to make theft so
expensive/difficult/annoying that it's not worthwhile.  Locking my front
door doesn't prevent burglary, as the thief could theoretically knock the
entire door out of its frame, or tunnel through the wall, or come down the
chimney.  Nonetheless, I lock my front door, and I suspect you do, too. 

I happen to be in sympathy with your general free software approach.  I
just wish you'd stop attacking strawmen when criticizing the non-free
approach(es).

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: Tue, 15 Sep 1998 16:26:42 GMT
From: tingdale@c2o.com (Tom Tingdale)
Subject: stock quote service
Message-Id: <35fe92e0.5012735@news.ses.cio.eds.com>

I am looking for a stock quote service that can give me this
information as raw data, and a Perl solution to get this data and
format it into a web site.

I have seen posting here before about how to get an URL which would
give me a  HTML file of formatted stock quote data, then extract this
data by stripping the HTML tag out. This is not what I want, however I
would consider other ways to do it, such as using a socket connection
to download the data? (I have never worked with sockets in Perl
before, but I am willing to give it a shot!).

Anybody with any ideas on most reliable method of getting this info?
Any vendor names that you have dealt with would be helpful.

Thanks,
Tom Tingdale


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

Date: 15 Sep 1998 16:25:14 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Transposing an array
Message-Id: <6tm4da$8ht$1@client3.news.psi.net>

perlperlperl@my-dejanews.com (perlperlperl@my-dejanews.com) wrote on
MDCCCXLI September MCMXCIII in <URL: news:6tlqdm$t1t$1@nnrp1.dejanews.com>:
++ APL provides a generalized transpose function for interchanging the
++ coordinates of an array. Is there a corresponding function in perl, or an
++ easy way to get from @a to @b, where:
++ 
++    @a = ([1, 2, 3],
++          [4, 5, 6]);
++ 
++ and:
++ 
++    @b = ([1, 4],
++          [2, 5],
++          [3, 6]);
++ 

@c = @{$a [1]};
@b = map {[$_, shift @c]} @{$a [0]};

But this makes unnessary copies of data.

This doesn't:

$i = -1;
$b [$i] = [map {$a [$_] -> [$i]} 0, 1] while ++ $i < @{$a [0]};

++ The next step of this question is how to convert the above to a hash.
++ Suppose you have a multidimensional array of names and IQ scores:
++ 
++    @c = (['Larry Wall', 200],
++          ['Tom Christiansen', 180],
++          ['Gary Burnore', 0]);
++ 
++ How can this be transformed into the following:
++ 
++    %d = (names => ['Larry Wall', 'Tom Christiansen', 'Gary Burnore'],
++          iqs   => [200, 180, 0]);
++ 
++ ?

%d = (names => [map {$_ -> [0]} @c],
      iqs   => [map {$_ -> [1]} @c]);

But I would store it as a name to iq mapping:

%e = map {@$_} @c;



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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