[7603] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1229 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 26 00:08:14 1997

Date: Sat, 25 Oct 97 21:00:23 -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           Sat, 25 Oct 1997     Volume: 8 Number: 1229

Today's topics:
     Re: Adding html to URLs (Jeremy D. Zawodny)
     Re: Adding html to URLs (John Moreno)
     An Interesting CGI Problem ... <bjorn@realitynet.com>
     Re: An Interesting CGI Problem ... <dagon@halcyon.com>
     Re: Anyone have Perl5.004 on SCO Enterprise 5.004 (Danny Aldham)
     Re: ARGV question <rjk@coos.dartmouth.edu>
     awk style field variables in perl (Waqar Hafiz)
     Re: awk style field variables in perl (John Moreno)
     Re: CGI tools <zenin@best.com>
     Re: context (M.J.T. Guy)
     detection of first execution since login <chenyang@mashie.ece.jhu.edu>
     Re: Editing Passwords (Jeremy D. Zawodny)
     Email the form information (Connie Wang)
     initgroups(2) Support - Why not? <ingo@blank.pages.de>
     Memory problems - how can I fix? (Ryan)
     Re: perl + Blat on NT problem (David Green)
     perl telnet, run command ,then get the result lxl6136@oak.njit.edu
     Re: Primes via regexen (Was: Re: non-greedy regexps) (Ilya Zakharevich)
     Reading 2D matrix efficiently(the best way?). <jong@mrc-lmb.cam.ac.uk>
     Re: Reading 2D matrix efficiently(the best way?). (Toutatis)
     Re: Reading 2D matrix efficiently(the best way?). (Daniel S. Lewart)
     running a shell script through Perl without waiting for (PRamanujam)
     sfio compile problems on solaris 2.4 <afc@c2o.com>
     Re: subscripting a function to get a single return valu (E.None Archibald)
     To get perl running on my system... <gellergrant@mindspring.com>
     Re: To get perl running on my system... (Jonathan Stowe)
     Re: Win32 Perl return code missing <youngej@magpage.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sat, 25 Oct 1997 19:34:41 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Adding html to URLs
Message-Id: <345248f6.20254284@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On Fri, 24 Oct 1997 18:21:04 -0600, harry_murphy@sfbayguardian.com
wrote:

> I have a list of 1,000 URLs in MSWord that I want to
>put on a Web page. I need to put the HTML coding in
>each URL so that when I click on a URL, it will bring up
>a Web page.
> It would probably take me 20 hours to type in the
>html coding for each URL. However, I understand that
>if I use BBedit and regular expressions, I can have all
>of this done automatically.
>  I have tried to use the following regular expression
>but can't seem to get it to work to add the html coding
>for each URL. Can anyone advise me on how to do this
>and what is wrong with my coding:

I dunno about BBEdit, but in Perl, I'd do something like this.

Put the URLs in a flat text file (call it urls.txt).

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

use strict;

while(<>) {
	chomp;
	my $url = $_;
	print qq|<A HREF="$url">$url</A><BR>\n|;
} # end while
--

And invoke it like this:

 ./script.pl < urls.txt

Of course, there are more succinct ways, but I figure this is somewhat
readable, at least.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Sat, 25 Oct 1997 12:58:13 -0400
From: phenix@interpath.com (John Moreno)
Subject: Re: Adding html to URLs
Message-Id: <1997102511350332708950N@roxboro-179.interpath.net>

<harry_murphy@sfbayguardian.com> wrote:

]  I have a list of 1,000 URLs in MSWord that I want to
] put on a Web page. I need to put the HTML coding in
] each URL so that when I click on a URL, it will bring up
] a Web page.
]  It would probably take me 20 hours to type in the
] html coding for each URL. However, I understand that
] if I use BBedit and regular expressions, I can have all
] of this done automatically.
]   I have tried to use the following regular expression
] but can't seem to get it to work to add the html coding
] for each URL. Can anyone advise me on how to do this
] and what is wrong with my coding:
] Search: (^.*//([^/]+)/.*)
] Replace: <ahref="/1">/2</a>

Why don't you post a bit of the url's - they can be kept in several
different formats which would (or could) make a difference.

Are they enclosed in brackets <>?
Do they use the full url format or just a abbreviated version?
Are they domain address, user address, cgi address or a combination?

BBEdit doesn't (or at least BBEdit Lite doesn't) allow you to do the
find and then the replace - you have to do a replace all.

But this seems to work (assuming that they aren't encased in angle
brackets):
Search: (.+)(//)([^/]+)(/.*)
Replace: <ahref="\1\2\3\4">\3</a>


If you are doing a lot of this type of work I'd recommend that you get
MacPerl - where you would set up a loop and do something like:

s#http://([^/]+)(/.+)#<ahref=\"http://\1\2\">\1<\/a>#;
print $_;

of course this would print it to a window and you want to have it print
save it in a file so you'd need to set that up too, but even with that
the whole things only a few lines of code - but you'll need to save the
file as text before doing this.

open(URLIN,"url") or die "Can't open file with url's";
open(URLOUT,">html.urls") or die "Can't open output file";
while (<URLIN>) {
        s#http://([^/]+)(/.+)#<ahref=\"http://\1\2\">\1<\/a>#;
        print URLOUT $_;
    }
close URLOUT;
close URLIN;

-- 
John Moreno


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

Date: Sat, 25 Oct 1997 12:00:06 -0700
From: Bjorn Lindstrom <bjorn@realitynet.com>
Subject: An Interesting CGI Problem ...
Message-Id: <Pine.BSF.3.96.971025115927.16022A-100000@shell5.ba.best.com>

Hi,

I have a strange problem with a WWW page and perl script I've written.
The purpose of the page is to take input (which may contain HTML code),
display it for confirmation, then put it in a file for display from
somewhere else.

The process is:

HTML Input Form (user enters information)
Confirmation CGI (information echoed as a form that user submits again)
Acceptance CGI (information sent to file)

Everything works perfectly, until I get to the third CGI.  Even there,
it's almost perfect.

But if a user enters HTML code (like a URL), the rest of the information
that they typed into the TEXTAREA is lost, including the URL.

At first, I thought the problem was trying to work with embedded double
quotes ("), but testing proved that wasn't the case.  It only seems to
happen with HTML that contains double quotes.  I have verified the problem
via HTML output from the CGI, as well as dumping the info to a text file
when it is received.

Perhaps this is a side effect of trying to use HIDDEN input tags to pass
the data, instead of normal input tags?

Has anyone run into this before?  Does anyone have any suggestions?  I
hate to recode for every INPUT tag just to find it doesn't work ...

Thanks in advance!

Bjorn Lindstrom

http://www.realitynet.com/bnk

bjorn@realitynet.com (home)
b45klin@ptss.com (work)
Heartagold@aol.com (AOL)




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

Date: 25 Oct 1997 13:50:09 -0700
From: Mark Rafn <dagon@halcyon.com>
Subject: Re: An Interesting CGI Problem ...
Message-Id: <62tm21$t95$1@halcyon.com>

Bjorn Lindstrom <bjorn@realitynet.com> arranged electrons like this:
>I have a strange problem with a WWW page and perl script I've written.
>The purpose of the page is to take input (which may contain HTML code),
>display it for confirmation, then put it in a file for display from
>somewhere else.

This raises my hackles just a bit.  Allowing Q. Random Luser to put HTML
tags on my page doesn't seem very safe (think JavaScript).  But I'll
assume you know what you're doing.

>At first, I thought the problem was trying to work with embedded double
>quotes ("), but testing proved that wasn't the case.  It only seems to
>happen with HTML that contains double quotes.  I have verified the problem
>via HTML output from the CGI, as well as dumping the info to a text file
>when it is received.

Right.  do a view source on your validation form (the second one, that
echoes the original input).  Does it include a piece that looks like:
  <INPUT TYPE="hidden" VALUE="<A HREF="lalala.html">foo</A>">
This is bad, and it should be expected to break.  Look into URLencoding
of stuff that is going to be used in the quoted part of an HTML tag.

Something like 
  <INPUT TYPE="hidden"
  VALUE="%3CA%20HREF%3D%22lalala%2Ehtml%22%3Efoo%3C%2F%3E">
would do the trick, and then your final form can decode it when
necessary.

good luck!
--
Mark Rafn    dagon@halcyon.com    <http://www.halcyon.com/dagon/>   !G



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

Date: 25 Oct 1997 15:49:37 -0700
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: Anyone have Perl5.004 on SCO Enterprise 5.004
Message-Id: <62tt21$1b1$1@lennon.postino.com>

Gary Pike (gary@newsinform.com) wrote:

: I downloaded the GNU c compiler and Perl 5.004_01. Giving Up on
: intalling it. Anyone have a binary already installed or how they did it?

Not sure why you had trouble. On Openserver5 with gcc perl5.004 
builds clean out-of-the-box. But , if you go to www.sco.com and look
in the Skunk directories, (Skunk, Skunk2 & Skunk96) , you will find
a custom installable package, with source code, binaries, and all the 
config files.

--
Danny Aldham           SCO Ace , MCSE , JAPH , DAD
I wak'd, she fled, and day brought back my night. jm


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

Date: Sat, 25 Oct 1997 18:35:26 -0400
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: ARGV question
Message-Id: <3452742E.50BC@coos.dartmouth.edu>

Nem W Schlecht wrote:
> 
> $len = scalar @ARGV;    # using '$len = @ARGV' is bad, because if @ARGV
>                         # contains only one element, $len will be set to
>                         # that instead of '1'

Whereever did you get that crazy idea from?

Using '$len = @ARGV' already puts @ARGV in a scalar context.
In this case, specifying scalar() explicitly doesn't accomplish
anything.

~> perl -e '$a = @ARGV; print "$a\n";' hi there
2
~> perl -e '$a = @ARGV; print "$a\n";' hi
1

Chipmunk


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

Date: Sat, 25 Oct 1997 17:26:32 +0100
From: waqar.hafiz@virgin.net (Waqar Hafiz)
Subject: awk style field variables in perl
Message-Id: <3.0.3.32.19971025172632.006a0964@mail.virgin.net>

This probably is a simple question for some of you:

In awk, fields within each record/line can be accessed
through awk variables $1, $2 ...
Is there such mechanism in perl?

Thanks in advance
Waqar Hafiz




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

Date: Sat, 25 Oct 1997 23:29:12 -0400
From: phenix@interpath.com (John Moreno)
Subject: Re: awk style field variables in perl
Message-Id: <1997102520232213849410N@roxboro-183.interpath.net>

Waqar Hafiz <waqar.hafiz@virgin.net> wrote:

] This probably is a simple question for some of you:
] 
] In awk, fields within each record/line can be accessed
] through awk variables $1, $2 ...
] Is there such mechanism in perl?

Well it has them as the result of pattern matching.  Frex:

$teststring="This is what you are looking for.";

print "\n\n";

$teststring =~ /(\w+) (\w+) (\w+) (\w+) (\w+) (\w+) (\w+)/;

print "$1 $2 $3 $4 $5 $6 $7$' - Ditto\n";

print "\nBut note that this is a easier way \n\n";

@ar = $teststring =~ /(\w+)/g;
print "@ar  - note this doesn't have a period\.\n";
@ar = $teststring =~ /([^ ]+)+/g;
print "@ar - Note that this DOES have period\.\n";

-- 
John Moreno


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

Date: 26 Oct 1997 02:22:18 GMT
From: Zenin <zenin@best.com>
Subject: Re: CGI tools
Message-Id: <62u9gq$qhj$3@nntp2.ba.best.com>

Connie Wang <c0w0461@unix.tamu.edu> wrote:
> What's the advantage or disadvantage of Perl over other CGI tools

	Perl is not a "CGI tool".

> such as Cold Fusion,

	Non-portable, inflexible, and if you need to replace your programmer
	you can bet that you'll find good Perl programmers easier to come
	by.

> JDBC
	This is not a CGI tool.  When used within CGI, you're of course
	using Java.  In this case you server is now slower then mud, buggy,
	and non-portable (yet).

> , Active Server Pages.
	Non-portable, _vary_ limited, slow, etc.  Everything you'd expect
	from Microsoft.

	If you are looking for super speed, flexibility, and portability, I
	_highly_ recommend running Apache on a Unix server with (at the vary
	least) the mod_perl extentions.  Apache is the king of web servers,
	and when combined with mod_perl (even better with ApacheDBI too, if
	you're using a database) it's an _extremely_ hard package to beat. 

	I'd _much_ sooner run Apache the _anything_ from Microsoft or
	Netscape.

-- 
-Zenin (zenin@best.com)
 The Bawdy Caste (San Jose, CA)       http://www.netmagic.net/~dmcgrath/bawdy/
 Barely Legal   (Berzerkly, CA)                    http://www.barelylegal.org/
 Zenin's Rocky Archive (Moving soon!)              http://www.best.com/~zenin/


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

Date: 25 Oct 1997 16:36:30 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: context
Message-Id: <62t76e$3ao$1@lyra.csx.cam.ac.uk>

brian d foy <comdog@computerdog.com> wrote:
>In article <62qfct$jlq$1@lyra.csx.cam.ac.uk>, mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:
>
>> $result = "$var";
>
>>But the circumstances where you need this sort of forcing are extremely
>>rare.    Perl usually does it for you.

The most obvious example is the bit operators & | ^ ~ which do different
things for numbers and strings.    Other cases could be arguments passed
to C subroutines or to syscall.


Mike Guy


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

Date: Sat, 25 Oct 1997 16:37:16 -0400
From: Chenyang Xu <chenyang@mashie.ece.jhu.edu>
Subject: detection of first execution since login
Message-Id: <3452587C.A0E277C9@mashie.ece.jhu.edu>

On UNIX, is there a way for a perl script to find out whether its
current execution is the first execution since the recent user login?

Please help ......

Thanks,

--
Chenyang




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

Date: Sat, 25 Oct 1997 19:37:14 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Editing Passwords
Message-Id: <34534a57.20607862@woody.wcnet.org>

[original author automagically cc'd via e-mail]

On Sat, 25 Oct 1997 11:55:33 +0900, Mic <nishin@bekkoame.or.jp> wrote:

>Does anyone know where I can find a program that with add, change &
>delete passwords from the file .htpasswd.

Yes.

There are modules on CAPN that do this, I believe.

CPAN is your friend.

Jeremy
-- 
Jeremy D. Zawodny                 jzawodn@wcnet.org
Web Server Administrator          www@wcnet.org
Wood County Free Net (Ohio)       http://www.wcnet.org/


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

Date: Sat, 25 Oct 1997 18:37:46 GMT
From: c0w0461@unix.tamu.edu (Connie Wang)
Subject: Email the form information
Message-Id: <34523b45.1543068@news.tamu.edu>

I use win32odbc to process a form information. I'd like to have  users
Email the  information they fill in the form once they submit the form
or before they submit the form.

I know there is a email function, but I don't know how to use it. What
the sytax? or Where can I find that systax or example?

Thanks Greatly
connie


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

Date: Sat, 25 Oct 1997 20:09:18 +0200
From: "Ingo L|tkebohle" <ingo@blank.pages.de>
Subject: initgroups(2) Support - Why not?
Message-Id: <345235CE.8524381D@blank.pages.de>

PERL doesn't seem to have support for initgroups, neither built-in nor
in the POSIX module. Before I go out and write a module for it:

	Is there a reason for the absence of initgroups(2) support?

-- 
Ingo Luetkebohle, CTO
dev/consulting Gesellschaft fuer Netzwerkentwicklung und -beratung mbH
url: http://www.devconsult.de/ - fon: 0521-1365800 - fax: 0521-1365803


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

Date: Sun, 26 Oct 1997 00:56:55 GMT
From: wwolfe@netcom.com (Ryan)
Subject: Memory problems - how can I fix?
Message-Id: <wwolfeEIMvyv.LG5@netcom.com>

I'm having memory problems with hashes and I was wondering how
to fix them.

I have a bit of code that does a wonderful job of sucking up
tons of memory when I don't really think it should.

$var = "0";
$name{group}->{$var}->{field} = "foo";
for (1..100000) {
   $name{group}->{$_} = $name{group}->{$var};
   delete($name{group}->{$var});
   $var = $_;
}

The only "data" being stored is "foo" in a hash that is pointed
to by a few references.

The for does a good job of copying the reference to a new key in the
hash before it, but stil this little bit of code sucks ram like
there's no tomorrow.

The delete doesn't seem to free up the memory allocated for the old key.

It's not even freed up for reuse from within perl.

What am I doing wrong?

And if nothing, is there another way to store the data like I have
above?

-Ryan


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

Date: Sat, 25 Oct 1997 17:43:15 -0500
From: dgreen+usenet@eceem0.eng.uab.edu (David Green)
Subject: Re: perl + Blat on NT problem
Message-Id: <MPG.ebc32027a0044c7989688@news.bhm.bellsouth.net>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

There is also a registry key 

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\Cre
ateProcessWithNewConsole

which should be set to 1 for the IIS .DLL approach to work.

Dave
-- 
David G. Green    mailto:dgreen@uab.edu
UAB Electrical and Computer Engineering
Birmingham, AL  35294-4461

-----------------
Above in response to article <877548367.30597@dejanews.com>,  where 
rex@atomicvision.com says...
> In article <877535077.14150@dejanews.com>,
>   matthewb@atomicvision.com wrote:
> >
> > I am using Blat 1.5, NT 4, and Activeware Perl build 504.
> >
> > + Blat works from the command line.
> > + a Perl script that calls Blat works from the command line.
> > + the same perl script, executed through a web browser, does NOT
> > successfully call Blat.
> 
> I answered my own question. Here it is for the benefit of the audience
> (I'm using IIS 3 by the way):
> 
> My .pl files were set to be interpreted by PerlIS.dll, not Perl.exe. I
> added a registry entry for .plx that routed to Perl.exe. When I put the.
> ..plx extension on the perl script (that calls Blat), and used Perl.exe
> instead, it worked fine.
> 
> So, I suppose the lesson here is that when you want to use Blat, Perl,
> and IIS together, use the Perl.exe interpreter.



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

Date: Sat, 25 Oct 1997 13:11:30 -0600
From: lxl6136@oak.njit.edu
Subject: perl telnet, run command ,then get the result
Message-Id: <877801493.5142@dejanews.com>

How to  write perl to telnet a account, then run a shell command,
after that return the result to the program ?

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 26 Oct 1997 02:38:31 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Primes via regexen (Was: Re: non-greedy regexps)
Message-Id: <62uaf7$aub$1@agate.berkeley.edu>

In article <slrn6533dm.e7.abigail@betelgeuse.wayne.fnx.com>,
Abigail <abigail@fnx.com> wrote:
> I get the following results:
> 
> 3000 (abi) : 230 secs (229.75 usr  0.02 sys = 229.77 cpu)
> 3000 (john): 222 secs (221.78 usr  0.00 sys = 221.78 cpu)
> 
> 
> The (11+?) marginally better, but much less than I expected it to be.

Why?  As many people explained, minimal-repeaters (applied for simple
nodes) are slower (per try) than the usual ones.  

For compicated constructions there is no difference (but the algorithm
is two orders of magnitude slower).

Ilya


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

Date: Sun, 26 Oct 1997 00:07:07 +0100
From: Jong <jong@mrc-lmb.cam.ac.uk>
Subject: Reading 2D matrix efficiently(the best way?).
Message-Id: <34527B9B.167E@mrc-lmb.cam.ac.uk>

Hi,

I am trying to read in a 2D matrix as follows into a hash.

%hash={ AA, 4, AR, -1,,,,, etc };

So that I would get a pair AA=4, another pair AT=0, etc.


Is there a known way of doing it fast?

Thanks very much.

Jong


   A  R  N  D  C  Q  E  G  H  I  L  K  M  F  P  S  T  W  Y  V  B  Z  X 
*
A  4 -1 -2 -2  0 -1 -1  0 -2 -1 -1 -1 -1 -2 -1  1  0 -3 -2  0 -2 -1  0
-4 
R -1  5  0 -2 -3  1  0 -2  0 -3 -2  2 -1 -3 -2 -1 -1 -3 -2 -3 -1  0 -1
-4 
N -2  0  6  1 -3  0  0  0  1 -3 -3  0 -2 -3 -2  1  0 -4 -2 -3  3  0 -1
-4 
D -2 -2  1  6 -3  0  2 -1 -1 -3 -4 -1 -3 -3 -1  0 -1 -4 -3 -3  4  1 -1
-4 
C  0 -3 -3 -3  9 -3 -4 -3 -3 -1 -1 -3 -1 -2 -3 -1 -1 -2 -2 -1 -3 -3 -2
-4 
Q -1  1  0  0 -3  5  2 -2  0 -3 -2  1  0 -3 -1  0 -1 -2 -1 -2  0  3 -1
-4 
E -1  0  0  2 -4  2  5 -2  0 -3 -3  1 -2 -3 -1  0 -1 -3 -2 -2  1  4 -1
-4 
G  0 -2  0 -1 -3 -2 -2  6 -2 -4 -4 -2 -3 -3 -2  0 -2 -2 -3 -3 -1 -2 -1
-4 
H -2  0  1 -1 -3  0  0 -2  8 -3 -3 -1 -2 -1 -2 -1 -2 -2  2 -3  0  0 -1
-4 
I -1 -3 -3 -3 -1 -3 -3 -4 -3  4  2 -3  1  0 -3 -2 -1 -3 -1  3 -3 -3 -1
-4 
L -1 -2 -3 -4 -1 -2 -3 -4 -3  2  4 -2  2  0 -3 -2 -1 -2 -1  1 -4 -3 -1
-4 
K -1  2  0 -1 -3  1  1 -2 -1 -3 -2  5 -1 -3 -1  0 -1 -3 -2 -2  0  1 -1
-4 
M -1 -1 -2 -3 -1  0 -2 -3 -2  1  2 -1  5  0 -2 -1 -1 -1 -1  1 -3 -1 -1
-4 
F -2 -3 -3 -3 -2 -3 -3 -3 -1  0  0 -3  0  6 -4 -2 -2  1  3 -1 -3 -3 -1
-4 
P -1 -2 -2 -1 -3 -1 -1 -2 -2 -3 -3 -1 -2 -4  7 -1 -1 -4 -3 -2 -2 -1 -2
-4 
S  1 -1  1  0 -1  0  0  0 -1 -2 -2  0 -1 -2 -1  4  1 -3 -2 -2  0  0  0
-4 
T  0 -1  0 -1 -1 -1 -1 -2 -2 -1 -1 -1 -1 -2 -1  1  5 -2 -2  0 -1 -1  0
-4 
W -3 -3 -4 -4 -2 -2 -3 -2 -2 -3 -2 -3 -1  1 -4 -3 -2 11  2 -3 -4 -3 -2
-4 
Y -2 -2 -2 -3 -2 -1 -2 -3  2 -1 -1 -2 -1  3 -3 -2 -2  2  7 -1 -3 -2 -1
-4 
V  0 -3 -3 -3 -1 -2 -2 -3 -3  3  1 -2  1 -1 -2 -2  0 -3 -1  4 -3 -2 -1
-4 
B -2 -1  3  4 -3  0  1 -1  0 -3 -4  0 -3 -3 -2  0 -1 -4 -3 -3  4  1 -1
-4 
Z -1  0  0  1 -3  3  4 -2  0 -3 -3  1 -1 -3 -1  0 -1 -3 -2 -2  1  4 -1
-4 
X  0 -1 -1 -1 -2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -2  0  0 -2 -1 -1 -1 -1 -1
-4 
* -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 
1 

-- 
================
Let's support Free Software Foundation.

  http://www.gnu.ai.mit.edu/help/donate.html#BecomeAPatronOfTheFSF

  http://www.mrc-lmb.cam.ac.uk:80/genomes/jong/copyleft.html


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

Date: 26 Oct 1997 01:15:33 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: Reading 2D matrix efficiently(the best way?).
Message-Id: <toutatis-ya023180002610970215320001@news.euro.net>

Jong <jong@mrc-lmb.cam.ac.uk> wrote:

> I am trying to read in a 2D matrix as follows into a hash. 
> %hash={ AA, 4, AR, -1,,,,, etc }; 
> So that I would get a pair AA=4, another pair AT=0, etc.

> Is there a known way of doing it fast?

I'd suggest a list of arrayrefs in your case.
Unless a lot of index values will be unused, arrays are much compacter, and
faster, than hashes.

If you've GOT a hash already, you could do this, for optimum speed and
compactness. (I guess you want to *use* that data...). 

my %hash = ( AA, 4, AR, -1,,,,, etc );
my (@matrix,$key,$val,$h,$v);

while (($key,$val) = each %hash){
   ($h,$v) = map{$_-65}unpack('C2',$key);
   $matrix[$h][$v] = $val;
}

You could leave out the map{$_-65} part if you want to use asci values
lower than 'A', but then you'll end up with a much bigger @matrix.

Your could also do the following, if your input is a file, formatted as a
matrix:

my (%h,%v,@matrix,@row,$i);
my $file = '/your/matrix.file'
open (F,$file) or die 'Grrr: @$*#!',\l$!;#;-)
$_ = <F>;
chomp;
@row = split /\s+/;
shift @row;
$i= 0;
%h = map{$_,$i++}@row;
$i = 0;
while (<F>){
   chomp;
   @row = split /\s+/;
   $v{shift @row} = $i;
   $matrix[$i++] = [@row];
}
close (F);

Then you can access the matrix like this:
$value = $matrix[$h{'A'}][$v{'B'}];

I do not guarantee the above to be bugfree. But it'll be close at least.

-- 
Toutatis
no mail replies please


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

Date: 26 Oct 1997 03:51:52 GMT
From: d-lewart@uiuc.edu (Daniel S. Lewart)
Subject: Re: Reading 2D matrix efficiently(the best way?).
Message-Id: <62ueoo$88e$1@vixen.cso.uiuc.edu>

Jong <jong@mrc-lmb.cam.ac.uk> writes:

> I am trying to read in a 2D matrix as follows into a hash.
> %hash={ AA, 4, AR, -1,,,,, etc };
> So that I would get a pair AA=4, another pair AT=0, etc.
> Is there a known way of doing it fast?

The script below will read the matrix into a hash.  It is pretty fast,
but you could speed it up by using an array and/or utilizing its symmetry.

Daniel Lewart
d-lewart@uiuc.edu
-------------------------------------------------------------------------------
#!/usr/bin/perl -w

use strict;

my @cols = split(' ', <DATA>);
my %hash;
while (<DATA>) {
    my ($row, @values) = split;
    @hash{ map("$row$_", @cols) } = @values;
}

__DATA__
   A  R  N  D  C  Q  E  G  H  I  L  K  M  F  P  S  T  W  Y  V  B  Z  X  *
A  4 -1 -2 -2  0 -1 -1  0 -2 -1 -1 -1 -1 -2 -1  1  0 -3 -2  0 -2 -1  0 -4
 .
 .
 .
* -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4 -4  1
-------------------------------------------------------------------------------


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

Date: 25 Oct 1997 17:54:22 GMT
From: pramanujam@aol.com (PRamanujam)
Subject: running a shell script through Perl without waiting for the return status
Message-Id: <19971025175401.NAA11672@ladder01.news.aol.com>

If I have a benchmark program which I wish to run for save 10 to 15 iterations
How Do I achieve this in perl
Note 1 I do not wish to fork 15 processes. as this will have 15 instances of
 perl running.
       2. I cannot use system as it waits for the output.

     Is there a way in which I can achieve
     for ( $i=0.; $i < 100 ; $i++) 
     {
         run shell program is background . do not wait for the results
     }


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

Date: Fri, 24 Oct 1997 17:28:50 -0500
From: Andy Cohan <afc@c2o.com>
Subject: sfio compile problems on solaris 2.4
Message-Id: <34512122.59E2@c2o.com>

We are having some trouble compiling sfio on a Solaris 2.4 machine.  The
error happens when compiling the sfsetbuf.c file:

sfsetbuf.c: In function `sfsetbuf':
sfsetbuf.c:51: `Stat_t' undeclared (first use this function)

tracking this definition to sfhdr.h it appears we are not picking up a
typedef for that structure since _sys_stat is not defined.  This
definition
appears to come from FEATURES/sfio on a 2.5 machine we have working
fine.

The FEATURES/sfio on each machine is very different:  about 35 #defines
to
1 on the good machine, only 1 #defines, without _sys_stat, on the
machine that is not working.

Can anybody point us in the right direction?

It is definitely a good possibility that this OS was not installed in a
completely kosher way but our hands are pretty tied about what we can do
to
it.

Thanks in advance,

AFC

P.S. If you could also email any replies (afc@c2o.com), I would
sincerely appreciate it.


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

Date: 25 Oct 1997 22:37:32 GMT
From: yevgene@xochi.tezcat.com (E.None Archibald)
Subject: Re: subscripting a function to get a single return value
Message-Id: <62tsbc$831$1@tepe.tezcat.com>

Tim Gray <tim@hcirisc.cs.binghamton.edu> wrote:
: I just tried something like this
: 	$foo = ($dbh->sql("select foo from bar"))[0][0]
: and it didn't work.

: I am looking for the value of foo from the database and want to assign
: it to $foo.  The sql method returns an array of references to arrays.
                                         ^^^^^^^^^^^^^^^^^^^
You need to dereference the array reference, with (...)[x]->[y]. See:

impslap:~$ perl -d
 ...debugger startup...
sub test {
  @array = ( [1,2], [3,4], [5,6] );
}         
print;   

  DB<1> $foo = (test)[0][1]
Can't use subscript on list slice at (eval 8) line 2, near "1]"

  DB<2> $foo = (test)[0]->[1]
  DB<3> print $foo
2

HTH!

--eugene archibald
  tezcat system administration


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

Date: Sat, 25 Oct 1997 14:47:44 -0400
From: "Scott Geller" <gellergrant@mindspring.com>
Subject: To get perl running on my system...
Message-Id: <62temb$h6j@camel20.mindspring.com>

 ... I think I need to compile it with Visual C++ ... correct?  Is there a
pre-compiled version of perl available to download?

If my only option is to compile it with V C++, anyone know where I can get a
copy?

Your help is appreciated... learning perl is turning out to be more
difficult than I thought it would be.

If possible, I would prefer a direct e-mail response...
gellergrant@mindspring.com

Regards,

Scott Geller.




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

Date: 25 Oct 1997 23:27:03 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: To get perl running on my system...
Message-Id: <62tv87$8ap@neon.btinternet.com>

In article <62temb$h6j@camel20.mindspring.com>, 
gellergrant@mindspring.com says...
>
>... I think I need to compile it with Visual C++ ... correct?  Is there 
a
>pre-compiled version of perl available to download?
>
>If my only option is to compile it with V C++, anyone know where I can 
get a
>copy?
>
>Your help is appreciated... learning perl is turning out to be more
>difficult than I thought it would be.
>
>If possible, I would prefer a direct e-mail response...
>gellergrant@mindspring.com
>
>Regards,
>
>Scott Geller.
>
>

I assume then you have an nt/win95 system if so a binary distribution can 
be had from http://www.activeware.com/ .



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

Date: 25 Oct 1997 16:31:03 GMT
From: Ed Young <youngej@magpage.com>
To: Bill Mohn <bmohn@wln.com>
Subject: Re: Win32 Perl return code missing
Message-Id: <62t6s7$fbn$0@204.179.92.229>

Your suspicions are correct.  I had the same problem and called
Microsoft support.  The support person said that's the way it worked,
and they weren't going to fix it for backward compatibility reasons.

Also note: if you open pipes 'to' with the perl 'open' command you will
find the same behavior.  The close will happily report success even
though the pipe fails completely.  The only solution I can find is to
use UNIX or NT.

However, neither NT nor Win95 support piping into or out of shell
scripts. Sadly, Microsoft operating systems do not well support
sophisticated command line computing.  Use Linux, UNIX, or possibly the
Cygnus bash shell (I haven't tried this)...

Bill Mohn wrote:
> 
> I'm having trouble making Perl on Win95 work the way I think it should.
> It performs correctly on Unix and NT.  The problem relates to getting
> return codes back from external commands that are invoked.  My
> understanding is that if I invoke a command with system() or with
> backticks, $? should be set to the exit status of the external command.
> I get the following results on Win95:
> 
> $rc=system("failing_cmnd");  # returns a proper return code and output
> goes to the terminal.
> 
> $rc=system("failing_cmd >outfile");  #sets $rc and $? to zero and puts
> stdout in outfile.
> 
> $output=`failing_cmd`;  #sets $? to zero and puts the output in $output.
> 
> Techniques like open (TMP, "failing_cmd >");  don't give a return code
> until the asynchronous command ends.
> 
> In other words, if I want a true final exit code AND I want the
> stdout/stderr from the command I can't seem
> to get both.  As I said, all forms work as I'd expect on NT and UNIX.
> 
> I'm running the Activeware Win32 Perl Build 310.  I suspect it has
> something to do with cmd32.exe but
> I can't figure it out.  Seems like it's an obvious bug that would have
> been fixed so I must be doing something
> wrong.
> 
> Bill Mohn


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

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

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