[23637] in Perl-Users-Digest
Perl-Users Digest, Issue: 5844 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 22 00:06:37 2003
Date: Fri, 21 Nov 2003 21:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 21 Nov 2003 Volume: 10 Number: 5844
Today's topics:
Assigning split to a list: undefined values? <mitia.nospam@northwestern.edu.invalid>
Re: Assigning split to a list: undefined values? <kuujinbo@hotmail.com>
Re: comments on JAPH? (Jay Tilton)
Re: Comments on parsing solution. <tore@aursand.no>
Re: Executing Perl from PHP <abigail@abigail.nl>
Re: Executing Perl from PHP <dan@mathjunkies.com>
Re: first line in each file in a dir (David)
Re: first line in each file in a dir <uri@stemsystems.com>
Re: How to extract info from a HTML input box (Tad McClellan)
Re: How to extract info from a HTML input box <asu1@c-o-r-n-e-l-l.edu>
Re: LWP & HTTPS problem <kuujinbo@hotmail.com>
Re: Need a simple script that deletes files older than (Tad McClellan)
Re: Need a simple script that deletes files older than <kkeller-usenet@wombat.san-francisco.ca.us>
Re: Need a simple script that deletes files older than <jurgenex@hotmail.com>
Re: Need a simple script that deletes files older than <me@privacy.net>
Re: Need strong Perl developer <tore@aursand.no>
Re: Newbie Problem/Question: LWP and SSLEAY <kuujinbo@hotmail.com>
Re: Newbie Question: Best way to Extract Post Hashes? (Tad McClellan)
Re: Protecting Source code of a perl script <rgarciasuarez@free.fr>
Re: read matrix file into 2d array (Tad McClellan)
Re: read matrix file into 2d array (David)
Re: read matrix file into 2d array <invalid-email@rochester.rr.com>
Re: read matrix file into 2d array <uri@stemsystems.com>
Re: What is a tied hash? (Tad McClellan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Nov 2003 00:25:14 GMT
From: Dmitry Epstein <mitia.nospam@northwestern.edu.invalid>
Subject: Assigning split to a list: undefined values?
Message-Id: <Xns943ABB7CF691Cmitianorthwesternedu@63.218.45.22>
Here is a code snippet:
while ($line = <F>) {
my ($node1, $node2, $node3) = split ' ', $line;
last unless defined $node3;
...
}
The idea here was that the loop stops if the line was split into
fewer than 3 values. It doesn't work however: when the line has
only 2 values, the variable $node3 is initialized with zero instead
of remaining undefined. How come?
(I have since changed the code to use an array instead of a list.)
--
Dmitry Epstein
Northwestern University, Evanston, IL. USA
mitia(at)northwestern(dot)edu
------------------------------
Date: Sat, 22 Nov 2003 10:23:24 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Assigning split to a list: undefined values?
Message-Id: <bpme0m$25q$1@pin3.tky.plala.or.jp>
Dmitry Epstein wrote:
> Here is a code snippet:
>
> while ($line = <F>) {
> my ($node1, $node2, $node3) = split ' ', $line;
> last unless defined $node3;
> ...
> }
>
> The idea here was that the loop stops if the line was split into
> fewer than 3 values. It doesn't work however: when the line has
> only 2 values, the variable $node3 is initialized with zero instead
> of remaining undefined. How come?
>
> (I have since changed the code to use an array instead of a list.)
>
Since the pattern ' ' is split()ing on whitespace, the newline on each
line results in an empty trailing field ('', which is a defined value).
So you need to get rid of the newline on each line:
use strict;
use warnings;
while (my $line = <DATA>) {
chomp $line;
my ($node1, $node2, $node3) = split ' ', $line;
last unless defined $node3;
print join(" ", $node1, $node2, $node3), "\n"
}
__DATA__
a s d
a s
HTH- keith
------------------------------
Date: Sat, 22 Nov 2003 03:38:22 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: comments on JAPH?
Message-Id: <3fbec430.81996275@news.erols.com>
Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de> wrote:
: Michele Dondi wrote:
:
: >
: > My first comments, modulo the fact that I didn't even try (yet) to
: > understand what it does due to absymal lack of time, are:
: >
: > (i) it doesn't work, for the following meaning of "doesn't work": it
: > prints "J" and then exits!
:
: That's because you are on Win* are you? It will work when you
: change the 14 in the first line to 15.
Alternatively, you could tighten up the algorithm so there's room for code
to detect when it's running in Windows and adjust itself.
$r=$^O=~/MSWin32/?75:74;open STDIN,"<&DATA";{ #J~.> a>n~>>e~.......>r.
seek STDIN,$i||=50,0;$_=getc;/\./&&last;/\w| / #.u.t.^..oP..r.>h>a~.e..
&&print;$i+=($d=/~/?$r:/\^/?-$r:/>/?1:/</?-1:$d #.>s^~h<t< ..~. ...c.^..
?$d:1);redo}__END__ #....>>e>r^..>l^...>k^..
Or, more ambitiously, add path corrections to the befunge-like data that
will steer the "program address" back on course when run under Windows.
------------------------------
Date: Sat, 22 Nov 2003 04:15:11 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Comments on parsing solution.
Message-Id: <pan.2003.11.21.12.30.00.826094@aursand.no>
On Thu, 20 Nov 2003 19:42:35 -0600, Eric J. Roode wrote:
>> my @files = ();
>> my %seen = ();
>
> Why not simply
>
> my @files;
> my %seen;
>
> ?
> Less typing, less chance for typos.
You have a point, of course. My personal style, however, implies that I
set each variable when I declare them. Even if it's not necessary, and
even when they're empty.
--
Tore Aursand <tore@aursand.no>
"A teacher is never a giver of truth - he is a guide, a pointer to the
truth that each student must find for himself. A good teacher is
merely a catalyst." -- Bruce Lee
------------------------------
Date: 21 Nov 2003 23:26:38 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Executing Perl from PHP
Message-Id: <slrnbrt7pe.el5.abigail@alexandra.abigail.nl>
Dan Anderson (dan@mathjunkies.com) wrote on MMMDCCXXXIV September
MCMXCIII in <URL:news:m23cchzbqe.fsf@syr-24-59-76-83.twcny.rr.com>:
[]
[] I have a PHP frontend to a Perl script. Currently the PHP
[] script opens up the Perl script and posts what to do, and the Perl
[] script outputs the results, and that's how they communicate. I find
[] it very inefficient though, and was curious, does anyone know of a way
[] to run Perl from inside of PHP?
[]
[] I know that PHP has a system call -- sort of like back ticks
[] in perl -- but it can be disabled depending on the way PHP is set up.
[] Anyone know another way?
That would be PHP questions, now wouldn't they?
Abigail
--
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";
------------------------------
Date: Sat, 22 Nov 2003 03:55:06 GMT
From: Dan Anderson <dan@mathjunkies.com>
Subject: Re: Executing Perl from PHP
Message-Id: <m2n0ap5a79.fsf@syr-24-59-76-83.twcny.rr.com>
Abigail <abigail@abigail.nl> writes:
> Dan Anderson (dan@mathjunkies.com) wrote on MMMDCCXXXIV September
> MCMXCIII in <URL:news:m23cchzbqe.fsf@syr-24-59-76-83.twcny.rr.com>:
> []
> [] I have a PHP frontend to a Perl script. Currently the PHP
> [] script opens up the Perl script and posts what to do, and the Perl
> [] script outputs the results, and that's how they communicate. I find
> [] it very inefficient though, and was curious, does anyone know of a way
> [] to run Perl from inside of PHP?
> []
> [] I know that PHP has a system call -- sort of like back ticks
> [] in perl -- but it can be disabled depending on the way PHP is set up.
> [] Anyone know another way?
>
>
> That would be PHP questions, now wouldn't they?
Well it seemed reasonable to assum that since perl is easily
integrated with other languages that somebody might have written a
module in CPAN or would know something about it.
-Dan
------------------------------
Date: 21 Nov 2003 16:09:51 -0800
From: diberri@yahoo.com (David)
Subject: Re: first line in each file in a dir
Message-Id: <31b26f4.0311211609.15fe85a8@posting.google.com>
Edo <eddhig22@yahoo.com> wrote in message news:<3FBE61F0.6000100@yahoo.com>...
> I need to do somthing with the first line in each file in a given dir, this is not working.
>
> opendir(DIR, "/.../");
> my @files = readdir(DIR);
> closedir(DIR);
>
> foreach my $file (@files) {
> open FL, $file or die $!;
> print <FL>, "\n";
> }
Hi Edo,
It's difficult to tell what you mean by "this is not working". But
without any more information, I'd bet that you're expecting @files to
contain a list of file paths when in fact it only contains a list of
file names.
From "perldoc -f readdir perlfunc":
If you're planning to filetest the return values out of a
"readdir", you'd better prepend the directory in question.
Otherwise, because we didn't "chdir" there, it would have been
testing the wrong file.
So your best bet would be to prepend the original directory when
building your @files array. Something like this might do the trick:
require File::Spec;
my $dir = '/';
opendir( DIR, $dir );
my @files = map {
File::Spec->catfile( $dir, $_ )
} readdir(DIR);
closedir( DIR );
Cheers,
David
------------------------------
Date: Sat, 22 Nov 2003 04:43:48 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: first line in each file in a dir
Message-Id: <x7r80157y3.fsf@mail.sysarch.com>
>>>>> "T" == Tintin <me@privacy.net> writes:
T> use Data::Dumper;
why use that? you don't call it anywhere.
T> foreach my $file (</some/sensible/path/*>) {
T> open FL, $file or die "Can not open $file $!\n";
T> print <FL>;
<> is in list context and will slurp and print the whole file. this is
the same bug the OP had.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 21 Nov 2003 16:55:18 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to extract info from a HTML input box
Message-Id: <slrnbrt5um.795.tadmc@magna.augustmail.com>
Blue Cat <bluecat22@go.com> wrote:
> It is from a paper "Active
> Scripting with PERL" from MSDN:
I would have more confidence in their code if they knew enough
to be able to spell the name of the language correctly...
It is "Perl", not "PERL".
> Obviously I'm dealing with something in this paper that I do not
> understand.
If only we knew what paper you are referring to, then we could
perhaps clear up your misunderstanding.
But we don't.
So we can't.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 22 Nov 2003 01:23:04 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: How to extract info from a HTML input box
Message-Id: <Xns943ACF5E1F4E3asu1cornelledu@132.236.56.8>
tadmc@augustmail.com (Tad McClellan) wrote in
news:slrnbrt5um.795.tadmc@magna.augustmail.com:
> Blue Cat <bluecat22@go.com> wrote:
>
>> Obviously I'm dealing with something in this paper that I do not
>> understand.
>
>
> If only we knew what paper you are referring to, then we could
> perhaps clear up your misunderstanding.
>
> But we don't.
>
> So we can't.
It seems like the OP's referring to:
http://www.microsoft.com/mind/0897/perl.asp
What I can't figure out is why he is not willing to look at the examples
provided with AS Perl but would rather use 6 year old examples from MSDN.
OP: Please look in the C:\Perl\eg\IEExamples directory on your system.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Sat, 22 Nov 2003 11:57:51 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: LWP & HTTPS problem
Message-Id: <bpmjhs$72p$1@pin3.tky.plala.or.jp>
Andy Parris wrote:
> Hi,
> I'm trying to use LWP to download a file from the net. The site is
> secure so I need to use https.
>
> the script can download http fine, but not https.
>
> I've installed the Crypt-SSLeay module
> I've managed to locate and download the SSLeay32.dll and libeay32.dll
> modules and I've copied them into \winnt\system32 (I'm on NT4)
>
> The script obviously needs these 2 dll's because if they are not there I
> get an error message asking for them. If the are then the script just
> returns :unknown error :unknown error
>
> Any ideas anyone? TIA
Put them in the bin subdirectory of your Perl installation, typically
c:/perl/bin/
If you still have problems (assuming your using ActiveState), add either
http://theoryx5.uwinnipeg.ca/ppms/ - 5.8xx
http://theoryx5.uwinnipeg.ca/ppmpackages/ - 5.6xx
to your list of package repositories and install. During installation
the .dlls are also installed.
HTH - keith
------------------------------
Date: Fri, 21 Nov 2003 17:51:11 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Need a simple script that deletes files older than 30 days
Message-Id: <slrnbrt97f.7cc.tadmc@magna.augustmail.com>
Chris Gregory <christian_gregory2002@yahoo.com> wrote:
> Is there a script that deletes files older than 30 days
You could write one in about 10 lines of Perl.
It is such a simple thing to do that there isn't much point
in "packaging" it, just write it anew in 5 minutes whenever
you need it.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 21 Nov 2003 16:36:58 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Need a simple script that deletes files older than 30 days
Message-Id: <a3bmpb.ti6.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
On 2003-11-21, Chris Gregory <christian_gregory2002@yahoo.com> wrote:
> Is there a script that deletes files older than 30 days
Yes. If you post it here, we can help you debug it.
- --keith
- --
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQE/vq+lhVcNCxZ5ID8RAsR2AJ9K/Rv78NZLB02O2wcP0Z+qwYA4FgCgj5Xg
bgwL0tG6b8TFz7kFm6Uv+dE=
=35/j
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 22 Nov 2003 02:53:39 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Need a simple script that deletes files older than 30 days
Message-Id: <TcAvb.956$Pm4.843@nwrddc03.gnilink.net>
Chris Gregory wrote:
> Is there a script that deletes files older than 30 days
perldoc -f unlink
perldoc File::Find
perldoc -f -X (see in particular the -M operator)
jue
------------------------------
Date: Sat, 22 Nov 2003 16:59:35 +1300
From: "Tintin" <me@privacy.net>
Subject: Re: Need a simple script that deletes files older than 30 days
Message-Id: <bpmn0r$1pqtn4$1@ID-172104.news.uni-berlin.de>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnbrt97f.7cc.tadmc@magna.augustmail.com...
> Chris Gregory <christian_gregory2002@yahoo.com> wrote:
>
> > Is there a script that deletes files older than 30 days
>
>
> You could write one in about 10 lines of Perl.
or one command if cygwin is installed.
------------------------------
Date: Sat, 22 Nov 2003 04:59:10 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Need strong Perl developer
Message-Id: <pan.2003.11.22.03.18.18.151648@aursand.no>
On Fri, 21 Nov 2003 16:12:05 +0000, Brian Wakem wrote:
>> We are looking for a strong Perl developer
> I go to the gym twice a week - am I eligible?
What is a gym? :-)
--
Tore Aursand <tore@aursand.no>
"A teacher is never a giver of truth - he is a guide, a pointer to the
truth that each student must find for himself. A good teacher is
merely a catalyst." -- Bruce Lee
------------------------------
Date: Sat, 22 Nov 2003 12:17:09 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Newbie Problem/Question: LWP and SSLEAY
Message-Id: <bpmklu$826$1@pin3.tky.plala.or.jp>
Andrew wrote:
> Hello,
>
> I am learning Perl and I have come across something I dont understand.
> I have put together some code from examples and I see something
> strange between data returned from HTTP and HTTPS sites. When I run
> my script on a non secured site (http://www.yahoo.com for example) I
> get connection info and page source. When I run the same script on a
> HTTPS site (https://www.helsinki.fi/) I get the connection info, but
> it returns an empty <HTML></HTML> bracket. Can anyone explain to me
> why this is occuring in this script?
>
> #!/usr/bin/perl
> use warnings;
> use strict;
> use LWP;
> use HTTP::Cookies;
> use HTML::Parser ();
>
> my $browser = LWP::UserAgent->new();
> my $cj = HTTP::Cookies->new(file
> =>"/home/awilhite/perl/cookies.lwp",autosave => 1,);
> $browser->proxy(['http','https'],'Edited_ContainsMyProxyInfo');
> $browser->cookie_jar($cj);
> my $req = HTTP::Request->new(GET => "$ARGV[0]");
^^^^^^^^^^
get rid of the quotes
can shorten, see below
> my $res = $browser->request($req);
you can shorten the two lines above to:
my $res = $ua->get( $ARGV[0] );
> if ($res->is_success) {
> print $res->as_string;
> #print $res->content;
> } else {
> print "Failed: ", $res->status_line, "\n";
> }
Ran your script with the suggestions above and the line using proxy()
commented out, and it worked fine. So it could have something to do with
proxy(). You must pass a URL as the second argument to proxy(), from the
docs something like 'http://proxy.sn.no:8001/'. In your script its where
you use 'Edited_ContainsMyProxyInfo'.
HTH - keith
------------------------------
Date: Fri, 21 Nov 2003 17:56:10 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Newbie Question: Best way to Extract Post Hashes?
Message-Id: <slrnbrt9gq.7cc.tadmc@magna.augustmail.com>
Andrew <awilhite@cableone.net> wrote:
> I am a Perl newbie
You are expected to check the Perl FAQs before posting to
the Perl newsgroup.
> and I was wondering if anyone could tell me the
> best way to extract expected post keys and values from websites?
Use the CGI module for that:
perldoc CGI
> is
> there an easy way to extract the expected post/value from a web site
> with the intention of using the information to write an agent or
> spider script for?
I'm afraid I cannot make sense of your question there. Sorry.
> Does anyone know of way to automatically gather it
> and post dynamically?
perldoc -q CGI
What is the correct form of response from a CGI script?
How do I decode a CGI form?
perldoc -q HTML
How do I fetch an HTML file?
How do I automate an HTML form submission?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 21 Nov 2003 23:05:29 GMT
From: Rafael Garcia-Suarez <rgarciasuarez@free.fr>
Subject: Re: Protecting Source code of a perl script
Message-Id: <slrnbrt6jo.ggt.rgarciasuarez@dat.local>
ctcgag@hotmail.com wrote in comp.lang.perl.misc :
>> That is not what is meant by "security by obscurity".
>
> I just think it's kind of cheating to coerce the language into making
> your argument for you. When something you think should be open is not,
> that is labelled obscurity, while when something you think should not be
> open is not, that is labelled security. So then when you say not to do
> security by obscurity, it's really just saying "don't do that which you
> shouldn't do."
You don't seem to perceive the difference between data and algorithms.
Obscuring data and obscuring algorithms that operate on data are two
very different things. What makes a program secure is preventing the
data it uses to be compromised or disclosed ; obscuring the algorithm is
practically useless if the data can be compromised. Here's a simple
comparison : to secure a door, you would probably rely on a complex
lock, rather than on a concealed but weak lock.
------------------------------
Date: Fri, 21 Nov 2003 16:51:32 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: read matrix file into 2d array
Message-Id: <slrnbrt5nk.795.tadmc@magna.augustmail.com>
Uri Guttman <uri@stemsystems.com> wrote:
> and if you use the module file::slurp (soon to be a major upgrade) then
> you can remove the open too:
>
> use File::Slurp ;
> my @data = map [ split ], read_file( $file ) ;
>
> makes loading data like this a snap.
>
> if the file was passed in on the command line you can even go with:
>
> my @data = map [ split ], <> ;
And if it is not passed on the command line and you don't have
File::Slurp, you can still get it done pretty easily:
my @data;
{ local @ARGV = $file;
@data = map [ split ], <> ;
}
:-)
> JJT> Ain't Perl great?
>
> yeah :)
And all the congregation said "Amen!"...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 21 Nov 2003 16:34:19 -0800
From: diberri@yahoo.com (David)
Subject: Re: read matrix file into 2d array
Message-Id: <31b26f4.0311211634.3149158d@posting.google.com>
"zhong huang" <zhong.huang@jefferson.edu> wrote in message news:<pan.2003.11.21.17.55.56.136548@jefferson.edu>...
> I have a matrix file (matrix.dat) which looks like this:
[snip]
> I want to open the file and put each element in a 2d array.
Hi Zhong,
Being as you're most likely a C programmer (the for-loop with prefix
incrementing was a dead give away!), here's some code that's decidedly
non-C that'll do the trick of reading in your matrix:
my $file = 'matrix.dat';
my @data;
open( FILE, $file ) or die "Can't open file '$file': $!";
while( <FILE> ) {
chomp;
my @row = split;
push @data, \@row;
}
close( FILE );
# Access data with $data[row][col], noting
# that row and col are indexed at zero, not one
print 'Cell (0, 0) = ', $data[0][0], "\n";
print 'Cell (1, 3) = ', $data[1][3], "\n";
print 'Cell (3, 4) = ', $data[3][4], "\n";
HTH,
David
P.S. You wouldn't happen to be on the TJU Medical College's admissions
committee, would you? Maybe you could help pass my application
along... :-) (Probably not, but hey, it was worth a shot!)
------------------------------
Date: Sat, 22 Nov 2003 04:27:01 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: read matrix file into 2d array
Message-Id: <3FBEE4D2.8080604@rochester.rr.com>
zhong huang wrote:
> Could anyone help me?
>
> I have a matrix file (matrix.dat) which looks like this:
>
> 0.97 0.97 0.97 0.81 0.8 0.53 0.54 0.54 0.36 0.41 0.5 0.46 0.61 0.86
> 0.95 0.7 0.86 0.81 0.57 0.55 0.55 0.46 0.46 0.47 0.63 0.7 0.9 1.05
> 0.98 0.88 0.86 0.89 0.85 0.57 0.6 0.49 0.46 0.37 0.53 0.43 0.79 1.06
> 0.87 0.67 1 0.71 0.79 0.5 0.51 0.69 0.45 0.63 0.61 0.58 0.78 1.06
> 1.14 0.69 1.23 0.63 0.92 0.6 0.46 0.55 0.32 0.38 0.46 0.47 0.68 0.82
> 1.16 0.77 1.02 0.8 0.85 0.47 0.54 0.55 0.37 0.43 0.57 0.53 0.64 0.87
> 1.15 0.81 0.89 0.67 0.77 0.48 0.59 0.48 0.4 0.34 0.51 0.5 0.59 0.91
>
> I want to open the file and put each element in a 2d array. My code is
> like this:
>
You might want to check out the Math::MatrixReal module (there are
examples in its docs of how to read a matrix from a file). It will
probably greatly simplify life for whatever you are intending to do with
the matrix once you have read it.
...
> Zhong
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Sat, 22 Nov 2003 05:04:24 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: read matrix file into 2d array
Message-Id: <x7n0ap56zr.fsf@mail.sysarch.com>
>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:
TM> And if it is not passed on the command line and you don't have
TM> File::Slurp, you can still get it done pretty easily:
TM> my @data;
TM> { local @ARGV = $file;
TM> @data = map [ split ], <> ;
TM> }
double blech!!
my @data = do { local @ARGV = $file ; map [ split ], <> } ;
:-)
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 21 Nov 2003 16:43:30 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: What is a tied hash?
Message-Id: <slrnbrt58i.795.tadmc@magna.augustmail.com>
Edo <eddhig22@yahoo.com> wrote:
> perldoc -f tie
>
> has to do with keeping the hash sorted
No it doesn't.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 5844
***************************************