[19520] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1715 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 8 14:08:04 2001

Date: Sat, 8 Sep 2001 11:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <999972306-v10-i1715@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 8 Sep 2001     Volume: 10 Number: 1715

Today's topics:
    Re: ActivePerl says Out of Memory, but I'm not out of m (Jonadab the Unsightly One)
    Re: AoH - continued <goldbb2@earthlink.net>
    Re: Confused (again) over complex data structures. (Abigail)
    Re: Disappearing Compiler messages (Jonadab the Unsightly One)
    Re: Extract the relative sorting of items from multiple <goldbb2@earthlink.net>
    Re: Extract the relative sorting of items from multiple (Randal L. Schwartz)
    Re: Need help passing visitor's cookies to target site  <gnarinn@hotmail.com>
    Re: pictures saving problem... <wm@rd66.rr.nu>
    Re: pictures saving problem... <wm@rd66.rr.nu>
    Re: pl or not pl, that is the question <goldbb2@earthlink.net>
        running ActivePerl on W2k Prof <the@executioner.tmfweb.nl>
    Re: Shared Libraries <william-seeley@home.com>
    Re: Simple Question <goldbb2@earthlink.net>
        Simple regexp <scotty99@earthlink.net>
    Re: Simple regexp (Tad McClellan)
    Re: sudhir: array references. <pilsl_@goldfisch.at>
    Re: sudhir: array references. (Tad McClellan)
    Re: sudhir: array references. <sudhir@newmail.net>
    Re: system() can't start serever app - HELP <gnarinn@hotmail.com>
    Re: system() error message <gnarinn@hotmail.com>
    Re: Where can I find a Perl SSH Telnet Client? <pilsl_@goldfisch.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 08 Sep 2001 15:11:55 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: ActivePerl says Out of Memory, but I'm not out of memory?  Is this  a  limitation in the Perl build I have?
Message-Id: <3b9a34ef.2488583@news.bright.net>

Martin Julian DeMello <mdemello@blue.owlnet.rice.edu> wrote:

>  http://home.earthlink.net/~fomalhaut/fcfaq.html

Oh my word, *somebody* has way too much free time :-)


- jonadab


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

Date: Sat, 08 Sep 2001 08:02:46 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: AoH - continued
Message-Id: <3B9A08E6.FAC182D6@earthlink.net>

TuNNe|ing wrote:
[snip]
> # sort the keys of the hash and pull out the values in that order
> my @sortkeys = @sorthash{sort keys %sorthash};

It won't make a difference for very few [0..9] keys, but for more, you
need to do it as sort {$a <=> $b} keys %sorthash, otherwise it will
think "10" is less than "2".

> foreach my $href (@data) {
>     for (@sortkeys) {
>         push(@goods, $href->{$_});
>     }
> }

This pair of loops could be shortened to:
@goods = map $_->{@sortkeys}, @data;

> print join (', ', @goods), "\n";
> exit;

This results in the following order:
music, video, very good, too long, mp3, mpeg

Is this really what you want?  It might be, but I'm not sure.

> __DATA__
> 1|category|3|type|2|info
> category|music|type|mp3|info|very good
> category|video|info|too long|type|mpeg

Have you considered simplifying your data?
A fixed order, and just have the values, not the keys.

music|very good|mp3
video|too long|mpeg

Then the program becomes *much* simpler:
my @goods = map {chomp; split /\|/} <DATA>;

-- 
"I think not," said Descartes, and promptly disappeared.


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

Date: 8 Sep 2001 13:09:40 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Confused (again) over complex data structures.
Message-Id: <slrn9pk67u.mir.abigail@alexandra.xs4all.nl>

Tassilo v. Parseval (Tassilo.Parseval@post.rwth-aachen.de) wrote on
MMCMXXX September MCMXCIII in <URL:news:9ncia6$ban$1@nets3.rz.RWTH-Aachen.DE>:
][ 
][ Not to mention here-docs. Comments and PODs are often put into the
][ source to make it more legible to other people. And in some situations,
][ using otherwise superfluous brackets and arrows and other operators
][ increases readability as well.


I am not argueing one should always omit superfluous brackets and arrows.

I am argueing one should not recommend to always use them. There is a
middle ground.


Abigail
-- 
#!/opt/perl/bin/perl   --   # Remove trailing newline!
BEGIN{$SIG{__WARN__}=sub{$_=pop;y-_- -;print/".*(.)"/;  
truncate$0,-1+-s$0;exec$0;}}//rekcaH_lreP_rehtona_tsuJ


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

Date: Sat, 08 Sep 2001 15:34:16 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: Disappearing Compiler messages
Message-Id: <3b9a358c.2646187@news.bright.net>

"David F Dafoe" <david.f.dafoe@boeing.com> wrote:

> A few things changed recently in my .PL files hosted on an NT server at a
> large corporation.
> 
> You're supposed to put this line:
> 
> print "Content-type:text/html\n\n";

That's just an HTTP header.  Actually, you could put any HTTP headers
there that you want to send to the browser, as long as they don't
duplicate one that the web server software is already sending.

print "Content-type: text/plain\nLocation: http://www.fsf.org/\n\n";

Or whatever.  text/html for the Content-type is correct if 
the remainder of your script prints out an HTML document, 
but if it printed out some other kind of content (say, plain
text), you'd want to change that.  

If you need to see what HTTP headers the web server software is
sending, you can use Net::UserAgent (running locally on your own
computer) to access a working script (on the server), and read 
off the headers.  Among other things, it will very likely say
which brand of web server software it is.  

> at the beginning of each file.  This used to work and still works on other
> servers.  Recently, this line started to cause my scripts to stop running,
> so I had to comment them out.
>
> Also, I no longer get compiler error messages.  If there is any syntax error
> I get a message saying "script produced no output."  I have to laboriously
> remove all new code, and put it back in line by line until I find the
> offending code.

Sounds like the web server software has changed.  In what way, 
I can't say without knowing more details.

Many web servers do not pass on error messages printed by
a CGI script if it terminates with a nonzero exit code,
indicating an error.  I find that if I want to print any
meaningful error messages, I have to exit 0; instead of
using die.  

If there's a syntax error, then of course you can't
get normal (0) exit code, as Perl will always exit with
an error code.  But you can test for syntax errors at
home without uploading to the server.  Just install
Perl on your PC and run the script through Perl.  It
may not have exactly the same environment as on the
server, so your script may not do exactly as intended,
but it'll sure tell you if there's a syntax error.

> The server admin. says that none of the PERL software or 
> settings have changed.

No, probably what the web server is doing has changed -- the
environment it sets possibly, and how it interprets the script's
output most likely.  How and whether it interprets and/or needs
your shebang line ("#!/usr/bin/perl" or whatever) may also have
changed.  You are not, by any chance, placing the print statement
before the shebang, are you?  Because if for example they migrated
from IIS to Apache in the aftermath of the Code Red fiasco, the
shebang line might suddenly start to be necessary.  (There are
other possible causes as well.)

> Note that I don't have the luxury of sitting directly on NT and running the
> scripts from the command line.  I have to pump them over to a server from my
> lowly PC and hope for the best.
> 
> Any insights would be welcome

You could also install Apache on your PC and _test_ your 
scripts there, to make sure they're actually working before 
you upload them.  That way you can test them in a web server
environment, with query-string input and stuff.  It probably 
isn't useful to ultimately run the scripts on your PC, but 
it may be very helpful to be able to test them there.

- jonadab


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

Date: Sat, 08 Sep 2001 09:06:15 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Extract the relative sorting of items from multiple lists
Message-Id: <3B9A17C7.AA6F172F@earthlink.net>

David Combs wrote:
[snip]
> Heck, this one guy (cs prof) would type in pages
> and pages of code, using *ed* (actually, the version
> from "Software Tools" (Kermighan's classic book)
> that people used as a semi-unix toolset way
> back then, when Bell Labs kept unix locked up),
> and he'd *turn off the star prompt*!!!!!,
> ie no prompt at all!
> 
> He'd be typing all this stuff in, then
> get out of append-mode (he'd type that dot,
> you know), do some substition five lines back,
> go insert some stuff between two lines,
> all this with no cursor, hardly every doing
> a "p" to see where he was (he just *knew*),
> working essentially blind -- and making not one
> mistake.  Incredible.  MACHO!

I forget where I saw it, but this makes me think of a quote that was
something like "Real Programmers edit using 'cat'" :)

-- 
"I think not," said Descartes, and promptly disappeared.


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

Date: 08 Sep 2001 08:08:01 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Extract the relative sorting of items from multiple lists
Message-Id: <m1elphvhym.fsf@halfdome.holdit.com>

>>>>> "David" == David Combs <dkcombs@panix.com> writes:

David> Heck, this one guy (cs prof) would type in pages
David> and pages of code, using *ed* (actually, the version
David> from "Software Tools" (Kermighan's classic book)
David> that people used as a semi-unix toolset way
David> back then, when Bell Labs kept unix locked up),
David> and he'd *turn off the star prompt*!!!!!,
David> ie no prompt at all!

Real /bin/ed didn't have a prompt.  Maybe the "Software Tools"
imitation did, but the real one had only one error message ("?") and
no prompt.

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


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

Date: Sat, 8 Sep 2001 09:59:48 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Need help passing visitor's cookies to target site to obtain html content
Message-Id: <999943188.513686421792954.gnarinn@hotmail.com>

In article <27391167.0109071751.af45b24@posting.google.com>,
Alex <okizeme@hotmail.com> wrote:
>I'm attempting to write a cgi-perl script which will retrieve an html
>page from another site. The only problem is that the target site needs
>the session id of the web surfer located in a cookie so that it can
>spit out the contents of the html file.
>
>For example, the target site i'm trying to retrieve the html content
>from contains the web surfer's shopping cart information. But in order
>to generate the contents of their shopping bin, it needs to check for
>a cookie created by the site to identify the unique visitor. My
>question then...is there a way for me the create a script that allows
>me to pass the cookie of the user running my script so that the target
>site will generate the appropriate html contents for my script to
>obtain.
>
>I've heard that you might be able to do something like this with
>LWP::UserAgent and HTTP::Cookies, but I'm not sure exactly how to go
>about this.

if the cookie was created by the users direct browsing to the target site,
then you cannot do this. if all the users browsing to the target site
goes through you then you can do it. basically, when you get the cookie
from the target site, you can wrap it into your own cookie, to send back
to your user, and unwrap it for the next request.

gnari




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

Date: Sat, 08 Sep 2001 11:23:53 GMT
From: "WebMeester" <wm@rd66.rr.nu>
Subject: Re: pictures saving problem...
Message-Id: <ddnm7.1317$e6.35352@news.chello.be>


"Laocoon" <Laocoon@eudoramail.com> schreef in bericht
news:Xns9116D09249B8Laocooneudoramail@62.153.159.134...
| Try binmode()..perldoc -f binmode

Thanks, works perfectly :-)

Rudy




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

Date: Sat, 08 Sep 2001 11:27:01 GMT
From: "WebMeester" <wm@rd66.rr.nu>
Subject: Re: pictures saving problem...
Message-Id: <9gnm7.1318$e6.35442@news.chello.be>


"Joe Smith" <inwap@best.com> schreef in bericht
news:9nbq6b$2sak$1@nntp1.ba.best.com...
| In article <hfbm7.1285$e6.28999@news.chello.be>,
| WebMeester <wm@rd66.rr.nu> wrote:
| >I have to write a script that takes a few pictures (.gif and .jpg) from one
| >webserver and saves them on an other webserver (kind of a mirror thing). The
| >script I've written (using LWP) works partially. It does retrieve the
pictures
| >and saves them on the other server, but when I open a picture, it is all
| >scrambled.
|
| Why reinvent the wheel, when LWP::Simple does all that for you.

Because the problem is more complex than that, and I didn't know the wheel
existed :-)
Anyway, this will come in handy.

Thanks.

Rudy

|   perl -MLWP::Simple -e 'mirror("http://www.example.com/a.gif","a.gif");'
| -Joe
| --
| See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.




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

Date: Sat, 08 Sep 2001 08:59:24 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: pl or not pl, that is the question
Message-Id: <3B9A162C.BB13B71C@earthlink.net>

You don't have a question here.

I'll assume you meant to ask "is it easier to do this with perl"
And the answer of course, is yes.

#!/usr/bin/perl -w
use strict;

my $re = "(?:" . join( "|",
	qw/\.n?(awk) \.(loc)(?:|DKC|S|TOOLS) (kep)/,
	map "\\.($_)", qw/mod prj man 1 ps lib hlp txt
	out1 out nam dat doc xrf aux dif ex sed pl pm
	html htm source el sh gz Z/ ) . ")$";

my %files;
foreach( qx[ls -Aslt] ) {
	# if it matches:
	if( /$re/o ) {
		# Read up on $+ in perlvar
		my $ext = $+;
		open( $files{$ext}, ">$ext.dn" )
			or die "Couldn't open $ext.dn: $!\n"
			unless $files{$ext};
		my $fh = $files{$ext};
		print $fh $_;
	}
}

END: {
	close $_ foreach values %files;
}
__END__

Note that unlike the original shell script, this only creates files for
those things which exist... if there are no .xrf files, for example, it
will not create an xrf.dn.

-- 
"I think not," said Descartes, and promptly disappeared.


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

Date: Sat, 8 Sep 2001 19:09:07 +0200
From: "The Executioner" <the@executioner.tmfweb.nl>
Subject: running ActivePerl on W2k Prof
Message-Id: <9ndja7$fi0$1@azure.nl.gxn.net>

Hi,

I'm trying to run a perl script on my computer.
I have got Windows 2000 Prof.
I have installed ActivePerl-5.6.1.628-MSWin32-x86-multi-thread.msi

Where is the cgi-bin, or where can I define the cgi-bin?

Thanks in advance, Maarten





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

Date: Sat, 08 Sep 2001 12:56:50 GMT
From: William Seeley <william-seeley@home.com>
Subject: Re: Shared Libraries
Message-Id: <3B9A15A0.5C6DF6E1@home.com>

Perl is a semi-compliled language. Unlike C++ and Java, Perl is not compiled
until runtime. Servlets are associated with Java.

If your functions are already written you can put them in a single script or
put them into a package so they are available to all your scripts.

validate($user, $pw);
This assumes sub validate{ } exists somewhere in your script.

use chat;
use lib '/path/to/library';
chat::validate($user, $pw);
This assumes you have written a package called chat.pm and that it contains a
function called validate.

These are very simple illustrations that barely scratch the surface. As I
said earlier, OO is a big topic. If you are uninterested in buying a book,
you could go to perl.com and perl.org. If you don't know how to access them
on your system, the perl man pages are available on one or both of these
sites.

Good Luck, Smiley.

-Will

Smiley wrote:

> Wow, I didn't realize it was that big a topic.  I've already got the
> subroutines I want to use, I thought I could just compile them.
>
> I guess I should be more specific.  I'm trying to set up a chat
> program on a website I'm working on.  This isn't just a simple script
> though, it comes with it's own server and allows you to add servlets
> to override certain functions by setting up certain functions and
> compiling them into a shared library.
>
> I want to set up the library to set up a function called
> iServAutheticate that will check my user database and return whether
> the user in question is valid or not.
>
> I'm thinking that this shouldn't be too hard of a task to complete -
> but the documentation on this is a little fragmented and hard to
> understand.
>
> I don't think I need to go out and buy a book for a small task like
> this, could you perhaps point me in the direction of a website that
> might be able to help me out?
>
> >That's a big subject, and a broad question. I would suggest you start by
> >familiarizing yourself with the Object Oriented capabilities in Perl.
> >You will be more likely to enlist the help of others when you have at
> >least a general understanding of what you want to do as well as a very
> >specific question
> >



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

Date: Sat, 08 Sep 2001 08:12:25 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Simple Question
Message-Id: <3B9A0B29.F724C5C@earthlink.net>

Student wrote:
> 
> Hi All,
> 
> I am just a beginner and would like to drop all index
> that existing on a given table name. I ran into this
> error after dropping the first index. ( I have 3 index in that table)
> 
> "Can't call method "fetchrow_array" without a package or object
> reference"
> 
> Can anyone be kind enough to provide some quick pointers?
> 
> Snippets of my code enclosed below.
[snip]
> $sth = $dbh->prepare ("
[snip]
>      while (@All_Old_Index = $sth->fetchrow_array( ))

You have a valid $sth here, so all is good and well.

>      {
>         $sth = $dbh->do ("drop index $User_Name.@All_Old_Index");

You drop the first table... it works, but look what you do with the
return value!  You *had* an ok $sth, but now you've thrown it out and
clobbered it with something else!

Anyway, your program could be improved by using strict, warnings, and by
giving your variables appropriate [minimal required] scope.

#!/usr/bin/perl -w
use strict;
use DBI;

my ($User_Name, $Table_Name) = @ARGV;

my $dbh = DBI->connect( ..., {RaiseError=>1} );

drop_all_indices();

sub drop_all_indices {
	my $sth = $dbh->prepare( q[
		SELECT index_name
		FROM user_ind_columns
		WHERE table_name = ?
	] );
	$sth->execute( $Table_name );
	while( my ($index) = $sth->fetchrow_array ) {
		$dbh->do("DROP index $User_Name.$index");
		print "$index index has been dropped.\n";
	}
}

-- 
"I think not," said Descartes, and promptly disappeared.


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

Date: Sat, 08 Sep 2001 13:37:35 GMT
From: Scott <scotty99@earthlink.net>
Subject: Simple regexp
Message-Id: <3B9A1E74.140509FC@earthlink.net>

Hi,

Being a newbie to regexps, I find even the simplest of tasks extremely
daunting.  Anyways imagine if you will the following code snippet:

we have the following output piped in from a unix program:
12312      /home/this
3234        /home/that
12213     /var/horses

while(FD){
#I need an expression here that will make $_  just the first number
field
#ie the first time around in this case would be 12312
}

I know this is probably simple.  In awk I'd just do {print $1}
In perl I'm sure I can use a substitution pattern like s /something
here/ /
but I don't know what.

Thanks,
Scott





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

Date: Sat, 08 Sep 2001 15:04:58 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Simple regexp
Message-Id: <slrn9pk8ma.i4v.tadmc@tadmc26.august.net>

Scott <scotty99@earthlink.net> wrote:

>we have the following output piped in from a unix program:
>12312      /home/this
>3234        /home/that
>12213     /var/horses
>
>while(FD){
       ^^
       ^^

Bareword found in conditional at ...


>#I need an expression here that will make $_  just the first number
>field
>#ie the first time around in this case would be 12312


   $_ = (split)[0];    # split() and a "list slice"

or

   s/^(\d+).*/$1/s;    # substitution


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


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

Date: Sat, 8 Sep 2001 13:53:18 +0200
From: peter pilsl <pilsl_@goldfisch.at>
Subject: Re: sudhir: array references.
Message-Id: <3b9a06b2@e-post.inode.at>

Sudhir Krishnan wrote:

> Hi!,
> 
> I have a triple dimensional array a[i][j][k]
> 
> It's actually a reference to an reference to an array, thats how
> it works internally, right?
> 
> Now if I want to pass it as an argument to a function, how should the
> prototype be defined and how should the value be returned?
> 

you pass the reference and return the reference

example (for 2D, its the same with 3D)

$matrix=[[1,2],[4,5]];

now $matrix is a reference to an anonymous array that contains anonymous 
arrays again.

You can dereference the values like the following

print $matrix->[0][1];
or alternatively
print $matrix->[0]->[1];

then you subs can look like.

sub func1
{
  my $m=shift; 
  $m->[0][1]=7777;
  return $m;
}

sub main
{
  my $matrix=[[1,2],[4,5]];
  my $matrix2=func1($matrix);
  print $matrix2->[0][1],"\n";
}


If you want to access the values with $matrix[0][1] you need to define the 
structure like this:
@matrix=([1,2],[4,5]);
You define an array containing references to arrays and need to pass the 
array (or a pointer to it) as argument.
imho the above method is much cooler and more logical cause it doesnt mix 
types.

best,
peter



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



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

Date: Sat, 08 Sep 2001 13:28:32 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: sudhir: array references.
Message-Id: <slrn9pk489.hmu.tadmc@tadmc26.august.net>

Sudhir Krishnan <sudhir@newmail.net> wrote:
>
>I have a triple dimensional array a[i][j][k]

>Now if I want to pass it as an argument to a function, how should the
>prototype be defined 


I recommend not defining a prototype:

   http://www.perl.com/pub/a/language/misc/fmproto.html


>and how should the value be returned?


Return a reference.


>If it was just a normal (unidimensional) array then I would do the
>following:
>
>sub func1
>{
>  local (@a) = @_;
   ^^^^^
>  local (@tmp);
   ^^^^^
>  push (@tmp, @a);
>  .
>  .
>  .
>  <some processing on tmp>


If "some processing" includes function calls, and one of those
called functions happens to use an array named @a or @tmp, you
will end up with "action at a distance" and its attendant
troubleshooting woes.

   You should always use lexical (my) rather than dynamic (local)
   variables, unless you can't.


Lots of local()s is something you would see in Perl 4 code, I
hope you haven't picked up Bad Perl from somewhere...


>  .
>  .
>  .
>  return @tmp;


   return \@tmp;    # @tmp _must_ be a lexical variable, or each call
                    # will refer to the same array.



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


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

Date: Sat, 08 Sep 2001 17:38:07 GMT
From: Sudhir Krishnan <sudhir@newmail.net>
Subject: Re: sudhir: array references.
Message-Id: <3B9A584C.2D4C825F@newmail.net>

Thanks for the response!
I've tried both setting and retrieving the values in the array as:

a[i][j][k]=value;
and it seems to work.
is this implicitly  the same as a->[i]->[i][k]; ?

I've tried the same with a hash ...
h{"mykey"}[0]=value;
and that works too!

so is there a place where I'm forced to used a->[]?

Also frequently I'm having to get the number of elements in the triple D
array.
I've tried this at different levels:

$#{$a[i][j]} #works
$#{$a[i]}    #works
$#{$a}       #DOES NOT WORK (I usually get -1)

Would u happen to know why the 3rd case does not work?

thanks!
Sudhir


> 
> Sudhir Krishnan wrote:
> 
> > Hi!,
> >
> > I have a triple dimensional array a[i][j][k]
> >
> > It's actually a reference to an reference to an array, thats how
> > it works internally, right?
> >
> > Now if I want to pass it as an argument to a function, how should the
> > prototype be defined and how should the value be returned?
> >
> 
> you pass the reference and return the reference
> 
> example (for 2D, its the same with 3D)
> 
> $matrix=[[1,2],[4,5]];
> 
> now $matrix is a reference to an anonymous array that contains anonymous
> arrays again.
> 
> You can dereference the values like the following
> 
> print $matrix->[0][1];
> or alternatively
> print $matrix->[0]->[1];
> 
> then you subs can look like.
> 
> sub func1
> {
>   my $m=shift;
>   $m->[0][1]=7777;
>   return $m;
> }
> 
> sub main
> {
>   my $matrix=[[1,2],[4,5]];
>   my $matrix2=func1($matrix);
>   print $matrix2->[0][1],"\n";
> }
> 
> If you want to access the values with $matrix[0][1] you need to define the
> structure like this:
> @matrix=([1,2],[4,5]);
> You define an array containing references to arrays and need to pass the
> array (or a pointer to it) as argument.
> imho the above method is much cooler and more logical cause it doesnt mix
> types.
> 
> best,
> peter
> 
> --
> mag. peter pilsl
> pilsl_@goldfisch.at
> http://www.goldfisch.at


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

Date: Sat, 8 Sep 2001 09:52:14 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: system() can't start serever app - HELP
Message-Id: <999942734.697119834832847.gnarinn@hotmail.com>

In article <1a4e7e5d.0109071434.2e64ca81@posting.google.com>,
Steve Klebar <sjklebar@hotmail.com> wrote:
>I can not start an application on a server (Mandrake 8.0, apache) via
>a perl/cgi script started on a win client. I have set xhosts + (to
>simplify test)
>
>Client perl cgi script
>$runcmd = "bin/switch";
>$rtn = system ($runcmd);
>
>Server bash script "/bin/switch";
>echo "This is a test" >> /var/www/temp/test 
>/usr/bin/appname
> 
>Results:
>1) appname starts when bash script is run from the server cmd line
>2) bash script will not run when started from client cgi script
>($rtn=256)
>3) comment out #/usr/bin/appname in bash script and
>bash script runs when started from client cgi script ($rtn=0)
>
>Thanks in advance for your time and help with this. Any suggestions
>for areas of research or an actual fix is appreciated.

you did not say if you had looked into tha faq
perldoc -q CGI

when having CGI problems, you should also read
http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html

my guess is environment or permissions of the webserver user

gnari



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

Date: Sat, 8 Sep 2001 09:38:30 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: system() error message
Message-Id: <999941910.941194665618241.gnarinn@hotmail.com>

In article <3B993695.F61C317F@country-life.com>,
Matt Carey  <mattc@country-life.com> wrote:
>I have a perl program(running on Linux/Apache) that accepts form data
>from a web page(consisting of textareas) and then uses a remote shell
>command to pass the form data to another server( an HP-UX).
>
>$runcommand = "rsh consac /usr/bin/nsperl
>/u/data/CONSAC/SRC.PERL/runuvprog.pl $data";
> $result = system($runcommand);

i will assume $data has been processed and does not contain any
metacharacters. specially these: ;>|*?"' and $
in fact it is always best to limit it to only characters you KNOW are
ok, instead of dis-allowing characters you know are not ok, in case you
forget some

>
>Upon completion of the system call  this message appears in the browser:
>
>'Attempted READ of record ID larger than file/table maximum record ID
>size of 255 characters.'

i have no experience with rsh, but could it be that there is some limitation
on the size of the command line? is $data obscenely long?

did you try to print out the $runcommand to a file, and then run it
manually from command line to see if the error still occurs?

>
>I'm trying to find out why I'm getting this message.  I'm not reading
>any files in my code.

in both the cgi AND the remote runuvprog.pl ?

maybe it is an environment thing. is the webserver user allowed to rsh?
try to simulate the code in non-cgi situation

gnari


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

Date: Sat, 8 Sep 2001 14:00:52 +0200
From: peter pilsl <pilsl_@goldfisch.at>
Subject: Re: Where can I find a Perl SSH Telnet Client?
Message-Id: <3b9a0879@e-post.inode.at>

What A Man ! wrote:

> Does anyone know where I can find an SSH Client that's written in Perl
> that will allow me to input telnet commands thru SSH Telnet?
> 

You cant be such a man, when you cant look at www.cpan.org, where my search 
for ssh returned two modules. Got your powers in the wrong place ?

If this ssh-modules at cpan dont do what you need (I didnt take a look at 
them) you can still use any command-line-based ssh-client and let perl 
communicate with it. 

best,
peter

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



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

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


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