[7816] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1441 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 9 13:20:47 1997

Date: Tue, 9 Dec 97 10:00:26 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 9 Dec 1997     Volume: 8 Number: 1441

Today's topics:
     Re: "sed-like" File operations <rootbeer@teleport.com>
     Re: Bitwise operations on strings and diff strings/numb (M.J.T. Guy)
     Checking if integer/real <hvanlint@lodestar.be>
     Graphing <chris@starkimages.com>
     Graphing <chris@starkimages.com>
     help for Checking input to match a certain pattern (Sylvain Juneau)
     Re: help for Checking input to match a certain pattern <rootbeer@teleport.com>
     Re: Help print to an open file... <rootbeer@teleport.com>
     Re: Help print to an open file... <rootbeer@teleport.com>
     Re: Help with a regex <rootbeer@teleport.com>
     how do I make perl script interact with shall command? <lu@bratch.com>
     Re: How to get keyword <rootbeer@teleport.com>
     looking 4 WIN95 modules/scripts that work, is that thin <yuan@yuan.yuan>
     Re: multipile comments lines . <rootbeer@teleport.com>
     Need documentation on WORD_BASIC ole module (Graham Wile)
     Re: Perl Overhead <Jacqui.Caren@ig.co.uk>
     Re: PERL<-->databases ???(newbie) (Jim Esten)
     Printing to file.. <jerryl@connecti.com>
     Re: Printing to file.. <rhughes@bbn.com>
     Problem with Sys::Syslog <gtr@ast.cam.ac.uk>
     questions on counters and printing form variables <carolynv@huntsville.sgi.com>
     Re: questions on counters and printing form variables <rootbeer@teleport.com>
     Re: Shared libraries on IRIX? <altitude@ren.us.itd.umich.edu>
     Re: Sorting huge array (Andrew M. Langmead)
     Re: Sorting huge array (Bart Lateur)
     using PERL with Personal Web server under 95 <andrew.wood@cableol.co.uk>
     Re: using PERL with Personal Web server under 95 <rootbeer@teleport.com>
     Re: Which http-server ?? <rootbeer@teleport.com>
     Re: Wildcards (Scott DiNitto)
     Re: Wildcards <rootbeer@teleport.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 9 Dec 1997 08:38:27 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: sean <sean@fastinternet.net.au>
Subject: Re: "sed-like" File operations
Message-Id: <Pine.GSO.3.96.971209083755.26951H-100000@user2.teleport.com>

On Tue, 9 Dec 1997, sean wrote:

> how do i insert a username at the EOL  midway through a file ?

There's some good information in the FAQ about adding to the middle of a
text file. Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 9 Dec 1997 15:55:29 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Bitwise operations on strings and diff strings/numbers
Message-Id: <66jplh$b65$1@lyra.csx.cam.ac.uk>

Tom Phoenix  <rootbeer@teleport.com> wrote:
>On 8 Dec 1997, Vincent Lefevre wrote:
>> Are there other operations that differently operate on strings and
>> on integers? 
>
>Yes. If you're passing arguments to syscall(), you must pass either
>numbers or strings for certain parameters. I don't believe that there are
>other cases, but somebody will surely tell me if there are any. :-)

Since you ask, the result of a sort routine must be numeric, not string,
so you can't do perverse things like

@sorted = sort { ($a <=>$b) . '' } @array;

AFAIK that's the only other case.


Mike Guy


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

Date: Tue, 9 Dec 1997 18:03:45 +0100
From: "Hans Van Lint" <hvanlint@lodestar.be>
Subject: Checking if integer/real
Message-Id: <66jte3$68m$1@news2.xs4all.nl>

I check the user's input like this (integer/real or not):

  $response = ($veld =~ /^\d+$/) ? "OK" : "NOT INTEGER/REAL";

My problem:

Users can't fill in real numbers like 0.001, 3.35, ...

Somehow my code sees the point in the real number as a part of a string.

I want the user to be able to fill in real numbers,
how do i change my code to make this possible??

Thanks






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

Date: Tue, 09 Dec 1997 11:35:55 -0600
From: Chris Schmidt <chris@starkimages.com>
Subject: Graphing
Message-Id: <348D817B.E85D6323@starkimages.com>

I need a Module that will allow me to do graphs(pie, 3d, line,
multi-line,...etc)
I can do what I want with GD.pm, but if someone has already writen the
code for a 
nice grapher that would be great.  Also any Ideas that you might have as
how to go 
about crwating this I would also welcome.  I hate it when I reinvent the
wheel. :)

---
Chris Schmidt / Systems Manager
Stark Images
Phone         / Fax
4142262700    / 4142262705


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

Date: Tue, 09 Dec 1997 11:36:27 -0600
From: Chris Schmidt <chris@starkimages.com>
Subject: Graphing
Message-Id: <348D819B.D65F6152@starkimages.com>

I need a Module that will allow me to do graphs(pie, 3d, line,
multi-line,...etc)
I can do what I want with GD.pm, but if someone has already writen the
code for a 
nice grapher that would be great.  Also any Ideas that you might have as
how to go 
about crwating this I would also welcome.  I hate it when I reinvent the
wheel. :)

---
Chris Schmidt / Systems Manager
Stark Images
Phone         / Fax
4142262700    / 4142262705


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

Date: Tue, 09 Dec 1997 16:16:59 GMT
From: sjuneau@microtec.net (Sylvain Juneau)
Subject: help for Checking input to match a certain pattern
Message-Id: <348d6d01.429257799@news.cmc.ec.gc.ca>

I have a file and I want to add a name.

It has to have a specific format:

The first letter of the name has to have a certain accepted letter
(see below) as well as the last letter. Also the name as to be at
least 4 characters long and no longer than 8 characters long.

print"What is the product identification name?";
print"\n\nThe id should not be more than 8 letters\n";
print"\nThe first letter represent Message source:\n\n";
print"  A is for CWAO CMC\n";
print"  C is for CWWG Prairie weather center - Winnipeg\n";
print"  D is for CWTO OSD Downsview\n";
print"  H is for CWHF DMetOc Halifax\n";
print"  I is for CWIS Ice Centre - Ottawa\n";
print"  K is for CYXY Yukon\n";
print"  N is for KWBC United States National Weather Service\n";
print"  T is for CWHX Atlantic Weather Centre - Bedford\n";
print"  O is for CYYZ Ontario Weather Centre - Toronto\n";
print"  P is for CWVR Pacific Weather Centre - Vancouver\n";
print"  Q is for CWUL Quebec Weather Centre - Quebec\n";
print"  W is for CWEG Alberta Weather Centre - Edmonton\n";
print"  R is for CWNT Arctic Weather Center - Edmonton\n";
print"\n\nThe last letter represent the message type:\n\n";
print"  C = Weather Charts\n";
print"  I = ICE data\n";
print"  L = Metsis Directory\n";
print"  O = Weather RADAR image\n";
print"  P = Weather Satellite Photo\n";
print"  R = METSIS Routing Table\n";
print"  T = METSIS Time Updates\n";
print"  X = NCCS Alpha-numeric Messages\n\n";
print"The old value is: $a1\n";
print"\n1XXXXXXL\n";
chop($prid=<STDIN>);
$prid=~ tr/a-z/A-Z/;

I tryied this to begin with:

I used pattern matching

if($prid =~ /^[ACDHIKNTOPQWR]*[CILOPRTX]$/) {print "ok1"};


Any suggestion

Thank you in advance
Sylvain

e-mail sjuneau@microtec.net


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

Date: Tue, 9 Dec 1997 09:31:36 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Sylvain Juneau <sjuneau@microtec.net>
Subject: Re: help for Checking input to match a certain pattern
Message-Id: <Pine.GSO.3.96.971209092715.26951S-100000@user2.teleport.com>

On Tue, 9 Dec 1997, Sylvain Juneau wrote:

> The first letter of the name has to have a certain accepted letter
> (see below) as well as the last letter. Also the name as to be at
> least 4 characters long and no longer than 8 characters long.

Sounds like a job for a regular expression.

> if($prid =~ /^[ACDHIKNTOPQWR]*[CILOPRTX]$/) {print "ok1"};

That's a start. I don't think that the star means what you think it means.
Maybe you want this pattern?

    /
	^			# start of string
	[ACDHIKNTOPQWR]		# one of those characters
	[A-Z]			# those characters...
	    {2,6}		# (a string of at least two
				# and no more than 6 of them)
	[CILOPRTX]		# one of those characters
	$			# end of string
    /x

That is from four to eight capital letters, with the first and last ones
restricted to the specified sets. Does that do anything useful for you?
Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 9 Dec 1997 08:52:41 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: jerryl@connecti.com
Subject: Re: Help print to an open file...
Message-Id: <Pine.GSO.3.96.971209085135.26951J-100000@user2.teleport.com>

On Tue, 9 Dec 1997 lineberry@cyberdude.com wrote:

> open(FN, "str.txt");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 9 Dec 1997 09:01:36 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Emilio Maneiro =?iso-8859-1?Q?M=E1rquez?= <emaneiro@bigfoot.com>
Subject: Re: Help print to an open file...
Message-Id: <Pine.GSO.3.96.971209090048.26951M-100000@user2.teleport.com>

On Tue, 9 Dec 1997, Emilio Maneiro [iso-8859-1] M=E1rquez wrote:

>  open(FN, "str.txt");
>  open(OUT, ">str.txt.new");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
Thanks.

--=20
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 9 Dec 1997 08:37:30 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Scott Anguish <sanguish@digifix.com>
Subject: Re: Help with a regex
Message-Id: <Pine.GSO.3.96.971209083517.26951G-100000@user2.teleport.com>

On 9 Dec 1997, Scott Anguish wrote:

> How can I make the regex still work even in the cases where the 
> version number is missing, or the keyletters are missing?

You may use the question-mark quantifier, which means that something may
appear zero or one times. For example, to match either 'behavior' or
'behaviour', you may use the regular expression /behaviou?r/, (possibly
along with word boundary anchors and other stuff, of course). Hope this
helps! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 9 Dec 1997 12:20:54 -0500
From: "Elaine Lu" <lu@bratch.com>
Subject: how do I make perl script interact with shall command?
Message-Id: <66juq3$ssa$1@nntp3.uunet.ca>

Hello all:

Here is what I try to accomplish...
In my program, I invited user to enter his/her preferred username and
password.  After some security and password validation checking in perl, I
then want
to pass the username and password into Linux shall and use the "htpasswd"
command to add a new user and his/her corresponding password into my
 .htpasswd file.

The codes that I led to serve my purpose are:

open (DIR, "| htpasswd .htpasswd $username\n")|| die "cannot open DIR!\n";
print DIR "New password: $password\n";
print DIR "Re-type new password: $confirm";
close (DIR);

However, these codes only allow me to add a new user but I can't pass the
password and confirmed password to the UNIX shall.  Could you
please tell me how I should change my codes so that I can make perl and
shall command work interactively?

Thank you very much for your time and help in advance!!!

Sincerely,
Elaine Lu
Toronto, ON.





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

Date: Tue, 9 Dec 1997 08:50:06 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Bosch Patrick <bosch@goweb.lu>
Subject: Re: How to get keyword
Message-Id: <Pine.GSO.3.96.971209083914.26951I-100000@user2.teleport.com>

On Mon, 8 Dec 1997, Bosch Patrick wrote:

> I have a web server and I want that the users of this server can get a
> keyword.  

I don't know what you mean by a keyword (maybe password?) but that seems
to be a reasonable desire.

> I have already a lot of perl cgi programs running on this server.

That's interesting, but irrelevant. :-)

> The server should call one of these programms and this programm should
> get the keyword from a daemon.

That sounds like a plan.

> On startup the daemon should ask for the
> keyword and identify the caller of daemon by uid and pid. 

Wait - does the daemon give or get the keyword? Or when you say it should
"ask for the keyword", whom does it ask? By the "caller" of the daemon, do
you mean the process which launches the daemon process?

> The problem is that I don't if this is possible and how to realize it. 

I don't know whether it's possible, either, but there's nothing
Perl-specific about this task. That is, you could do what you described in
Perl or in any other reasonably-competent language. If you want to do this
in Perl, though, it does sound as if you want to use some of the
techniques documented in the perlipc manpage. Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 09 Dec 1997 15:08:06 GMT
From: Yuan Tremblay <yuan@yuan.yuan>
Subject: looking 4 WIN95 modules/scripts that work, is that thinkable?
Message-Id: <348D5E78.3A83@yuan.yuan>

Hi,

i see a bunch of references to sites with win32 modules, those won't
execute on my win95 environment:

------------
D:\perl\bin>perl -e "use IPC::Open3;"
Can't call method "import" in empty package "IPC::Open3" at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
------------

I try to build scripts that will be able to use "INLINE" or "<<" like
commands as input to a PIPEd program which expects input from STDIN


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

Date: Tue, 9 Dec 1997 09:00:14 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "canaan.co.il;edris1"@hotmail.com
Subject: Re: multipile comments lines .
Message-Id: <Pine.GSO.3.96.971209085523.26951L-100000@user2.teleport.com>

On Tue, 9 Dec 1997, Edris Abzakh wrote:

> I was wondering if there is any way to turn a few lines of perl to 
> comments and that without using the '#' char before every line ?

There's a way to do just about _anything_ in Perl. But the preferred way
to make comments is to mark the comment text with the # character. There's
no good reason not to use this method in most cases. (If your text editor
won't let you easily place or remove pound signs, you should get a better
one - or do the editing with Perl - or both.) 

One common method is to (ab)use POD markup. See the perlpod manpage for
details.

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 09 Dec 1997 15:34:17 GMT
From: graham@webworks.ca (Graham Wile)
Subject: Need documentation on WORD_BASIC ole module
Message-Id: <MPG.ef73ce98514b30c989680@moose.webworks.ca>

        I have found a reference that gives a parameter list for 
the perl WORD_BASIC module functions:

		http://home.ljusdal.se/perl/ole/Word_Basic.htm

The problem is, I cannot find real documentation, with examples. 
I found some examples for the Excel part, but I need something 
for Word to get me started. 

For eaxample, I would like to know how to call Word from a perl 
script, create a new document, and save it as a file. Then 
maybe more advanced stuff. To do that I will need examples on 
how to use the Insert, FileNew, etc. methods in a Perl context 
from a perl script.

Is there anyone there who can point me in the right direction? 
Any help would be greatly appreciated. 

                                                                                                
Thanks


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

Date: Tue, 9 Dec 1997 17:07:27 GMT
From: Jacqui Caren <Jacqui.Caren@ig.co.uk>
Subject: Re: Perl Overhead
Message-Id: <EKxM8G.EwB@ig.co.uk>

In article <comdog-ya02408000R0212971634340001@news.panix.com>,
brian d foy <comdog@computerdog.com> wrote:
>In article <3484735C.9EADDDBB@DotRose.com>, Henry Hartley <henry@DotRose.com> wrote:
>
>[CF == Cold Fusion]
>
>>One of the arguments used to recomment CF is
>>that there is one CF process running on the server that handles all the
>>requests while Perl starts a new process for each script that runs.

Untrue.
CGI TENDS to have a per process overhead - it is not a perl problem.

I say TENDS as some servers (such as those written in perl) may not
need to fork/exec/spawn perl scripts.

>you could do that with Perl using mod_perl and the Apache-like servers
>or FastCGI.

or CGI::MiniServer or (thanks randall :-) the HTTP::* modules.

See randalls (upcoming?) webtechniques article on this very subject!

Other issues such as application requirements, database connections
caches, flexibility, reliability, scalability, platform independance
etc will afffect your final decision. CF is a nice template engine,
it is not a programming language. There is a big difference between
the two technologies.

Jacqui
-- 
Jacqui Caren                    Email: Jacqui.Caren@ig.co.uk
Paul Ingram Group               Fax: +44 1483 419 419
140A High Street                Phone: +44 1483 424 424
Godalming GU7 1AB United Kingdom



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

Date: 9 Dec 1997 10:00:52 -0600
From: jesten@earth.execpc.com (Jim Esten)
Subject: Re: PERL<-->databases ???(newbie)
Message-Id: <66jpvk$n2$1@earth.execpc.com>

Damir Boraska (dboraska@jagor.srce.hr) wrote:
: HI there..I hope that there should be someone outhere who will help me with
: this *problem*...
: I'm using perl just ocasionally,so my knowledge of it is not really  
: impressive..however I find perl great for writing cgi scripts.
: I need to write web form-data into a database,and also to offer a search
: of the same database...
: Now here it comes: I have NO experiences with anything like that,so I'd   
: appreciate if someone could tell me how to do it...and what to use.
: Database fields should be: author/title/volume/issue/kkeywords...
: and serach should be done in the same categories....THANX!!!
: P.S. I use Unix!!!

Grab yourself a copy of Shishir Gundavarum's CGI Programming on the
World Wide Web and check out his Sprite.pm module.  Gives you SQL-ish
control over flat file "databases".  Several months ago, I offered up
my little in house bug tracker called BugBase as an example of a 
Sprite.pm based application.  Offer still stands.  It ain't rocket
science and some of it ain't even pretty, but it is a functional
example... at least useful as a learning tool.

Jim Esten
WebDynamic
http://wdynamic.com  jesten@wdynamic.com
A

B
Jim
-- 
Jim Esten
WebDynamic
jesten@wdynamic.com  http://wdynamic.com


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

Date: Mon, 8 Dec 1997 04:20:06 -0600
From: Jerry Lineberry <jerryl@connecti.com>
Subject: Printing to file..
Message-Id: <Pine.GSO.3.95.971208034706.13184A-100000@mercury>

Hello,
	I've been trying to figure out how to print to a file. I'm new to
perl programming and I find it really easy to create scripts, but I have
not been able to print to a file. (So people tried help me out when I
accidently posted to comp.lang.perl). However, I'm still having a problem.

Here's what I want to do. I have a file named str.txt that contains about
73 lines with a domain name followed by 3 usernames. 

----str.txt----
kingkong.com	jerryl freddy tommy
goofball.com	jerryl freddy tommy
jibberish jibberish jibberish
(...)
pooh.com	jerryl freddy tommy
----str.txt----

If I run the following script, it prints to my terminal the desired
results:

----terminal print----
#!/usr/bin/perl -w

{
open(FN, "str.txt");
while (<FN>) {
	/jerryl/;
	print $`."\n";
	}
close(FN);
}
----terminal print----

The results look something like:

kingkong.com
goofball.com
[...]
pooh.com

The script removes all usernames since all lines with users contain
"jerryl". It also removes lines that have jibberish because "jerryl" is
not on those lines. This is my desired results, which I want to write to a
file called "result".

If I try to open a file and print to it like this:

{
open(FN, "str.txt");
while (<FN>) {
	/jerryl/;
	$all = $`."\n";
	}
open(FN, ">result");
print FN $all;
close(FN);
}

I only get the very first domain name in the "result" file.
----result----
kingkong.com
----result----

The weird part is if I run the following I get the last domain name only:
  
{
open(FN, "str.txt");
while (<FN>) {
	/jerryl/;
	$all = $`."\n";
	# If I open below as <FN> perl takes a very long time to run this script!
	# Why do I get the correct response if I comment the open command? 
	# When I print to "result" I get only the very last domainname.
open(STDOUT, ">result");
print $all;
	}
close(FN);
}

If you can explain how I should go about getting the desired results, I'd
really appreciate it. I believe that I am getting a grasp on writing these
scrpts. I am just stuck on printing to an open file.

Thanks for any help.
-Jerry
---
Jerry Lineberry
San Antonio, Texas
(210) 746-1787



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

Date: Tue, 09 Dec 1997 16:37:04 GMT
From: Robin Hughes <rhughes@bbn.com>
Subject: Re: Printing to file..
Message-Id: <348D72B2.5E7EC59A@bbn.com>



Jerry Lineberry wrote:

> Hello,
>         I've been trying to figure out how to print to a file. I'm new to
> perl programming and I find it really easy to create scripts, but I have
> not been able to print to a file. (So people tried help me out when I
> accidently posted to comp.lang.perl). However, I'm still having a problem.
>
> Here's what I want to do. I have a file named str.txt that contains about
> 73 lines with a domain name followed by 3 usernames.
>
> ----str.txt----
> kingkong.com    jerryl freddy tommy
> goofball.com    jerryl freddy tommy
> jibberish jibberish jibberish
> (...)
> pooh.com        jerryl freddy tommy
> ----str.txt----
>
> If I run the following script, it prints to my terminal the desired
> results:
>
> ----terminal print----
> #!/usr/bin/perl -w
>
> {
> open(FN, "str.txt");
> while (<FN>) {
>         /jerryl/;
>         print $`."\n";
>         }
> close(FN);
> }
> ----terminal print----
>
> The results look something like:
>
> kingkong.com
> goofball.com
> [...]
> pooh.com
>
> The script removes all usernames since all lines with users contain
> "jerryl". It also removes lines that have jibberish because "jerryl" is
> not on those lines. This is my desired results, which I want to write to a
> file called "result".
>
> If I try to open a file and print to it like this:
>
> {
> open(FN, "str.txt");
> while (<FN>) {
>         /jerryl/;
>         $all = $`."\n";
>         }
> open(FN, ">result");
> print FN $all;
> close(FN);
> }
>
> I only get the very first domain name in the "result" file.
> ----result----
> kingkong.com
> ----result----
>
> The weird part is if I run the following I get the last domain name only:
>
> {
> open(FN, "str.txt");
> while (<FN>) {
>         /jerryl/;
>         $all = $`."\n";
>         # If I open below as <FN> perl takes a very long time to run this script!
>         # Why do I get the correct response if I comment the open command?
>         # When I print to "result" I get only the very last domainname.
> open(STDOUT, ">result");
> print $all;
>         }
> close(FN);
> }
>
> If you can explain how I should go about getting the desired results, I'd
> really appreciate it. I believe that I am getting a grasp on writing these
> scrpts. I am just stuck on printing to an open file.
>
> Thanks for any help.
> -Jerry
> ---
> Jerry Lineberry
> San Antonio, Texas
> (210) 746-1787

There are several problems here.  The first is that instead of
    $all = $`."\n";
You need
   $all .= $`."\n";
You are resetting $all each time rather than concatenation your new string to the old
one.

Second, since you may have input lines that don't match the pattern like:
pooh.com      freddy tommy franky
you need to check if you have a successful match before you concatenate.  Otherwise
you will concatenate the last thing $` evaluated to, so you'd get an output line
duplicated.

Third, $` is not appropriate here, because what if the input string was:
pooh.com        freddy jerryl tommy
Then you $` would evaluate to "pooh.com   freddy".  Instead use something like:

   if (m/(\S+)\s+.*jerry1.*/) {  #pick off the first token and save as $1
      $all .= $1."\n";

Hope this helps.





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

Date: Tue, 09 Dec 1997 16:30:24 +0000
From: Guy Rixon <gtr@ast.cam.ac.uk>
Subject: Problem with Sys::Syslog
Message-Id: <348D7220.17C6@ast.cam.ac.uk>

I have a problem getting SysSyslog to work in perl 5.003 on Solaris 2.5.

I get this error message:

Undefined subroutine &Sys::Syslog::hostname called at
        /usr/local/lib/perl5/Sys/Syslog.pm line 92 (#1)
    (F) The subroutine indicated hasn't been defined, or if it was, it
    has since been undefined.
    
Uncaught exception from user code:
        Undefined subroutine &Sys::Syslog::hostname called at
/usr/local/lib/perl5/Sys/Syslog.pm line 92.
        require Sys/Syslog.pm called at talk_log_server line 108
        main::BEGIN called at /usr/local/lib/perl5/Sys/Syslog.pm line 0
        eval {...} called at /usr/local/lib/perl5/Sys/Syslog.pm line 0
BEGIN failed--compilation aborted at talk_log_server line 108.

in a perl script that begins:

  use English;
  use diagnostics;
  use FileHandle;
  use Sys::Syslog;
  use Time::Local;

Is there something special that has to be installed or configured
to use syslog?  Do I need to upgrade to perl 5.004 to get a bug fix?

Thanks,

Guy Rixon,				gtr@ast.cam.ac.uk 
Software Engineering Group,		Tel: +44-1223-374000
Royal Greenwich Observatory 		Fax: +44-1223-374700


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

Date: Tue, 09 Dec 1997 10:31:58 -0600
From: Carolyn Vo <carolynv@huntsville.sgi.com>
Subject: questions on counters and printing form variables
Message-Id: <348D727E.167E@huntsville.sgi.com>

Hi, everyone,

I have some questions that are basic ones (I'm still getting the hang of
CGI scripts and Perl):

1) I would like to include a counter in my web page. I have access to a
counter script, but I don't know what to do to include it in my HTML
document. What should I do to activate the script when the page is
accessed?

2) I would like to print my form variables in my own order instead of
the sorted order that "foreach (sort keys $in)" does. How can I do this?
I know that I should say something like "foreach ('lastname',
firstname', ....)". 

Thanks a lot!
Carolyn Vo
-- 
*************************************
Carolyn Vo
Systems Engineer Coop
1500 Perimeter Pkwy, Suite 100 
Huntsville, AL  35806
(205)864-3435
FAX: (205)830-5438 
EMAIL:  carolynv@huntsville.sgi.com
*************************************


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

Date: Tue, 9 Dec 1997 09:35:15 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Carolyn Vo <carolynv@huntsville.sgi.com>
Subject: Re: questions on counters and printing form variables
Message-Id: <Pine.GSO.3.96.971209093253.26951U-100000@user2.teleport.com>

On Tue, 9 Dec 1997, Carolyn Vo wrote:

> 1) I would like to include a counter in my web page. I have access to a
> counter script, but I don't know what to do to include it in my HTML
> document. What should I do to activate the script when the page is
> accessed?

The people in a newsgroup about HTML (or CGI) should be able to help you
to get the answers, although they'd prefer it if you found the answer in
the appropriate docs and FAQs before you post.

> 2) I would like to print my form variables in my own order instead of
> the sorted order that "foreach (sort keys $in)" does. How can I do this?

There's an entry in the Perl FAQ about sorting things in any order you
desire. Of course, if you already know the items and the order you want,
you could simply list them...

> I know that I should say something like "foreach ('lastname',
> firstname', ....)". 

 ...yes. Just like that.

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 9 Dec 1997 17:34:26 GMT
From: Alex Tang <altitude@ren.us.itd.umich.edu>
Subject: Re: Shared libraries on IRIX?
Message-Id: <66jvf2$dap$1@newbabylon.rs.itd.umich.edu>

Honza Pazdziora <adelton@fi.muni.cz> wrote:
: Alex Tang <altitude@ren.us.itd.umich.edu> writes:

: [...]

: > Can't load '/local/lib/perl5/site_perl/IP32-irix/auto/Ldapc/Ldapc.so' for
: > module Ldapc:  9986:/usr/bin/perl: rld: Fatal Error: cannot successfully
: > map soname 'libldap10.so' under any of the filenames
: > /usr/lib32/libldap10.so:/lib32/libldap10.so:/usr/libn32/libldap10.so:/libn32/libldap10.so:  at /local/lib/perl5/IP32-irix/5.00404/DynaLoader.pm line 166.
: >  at /local/lib/perl5/site_perl/Ldapp.pm line 207
: > BEGIN failed--compilation aborted at ./test.pl line 2.
: > 
: > 
: > But the shared library is located in /usr/lib32 (which is in the path that 
: > was searched.
: > 
: > gromit% ls -al /usr/lib32/libldap10.so
: > -rwxr-xr-x    1 root     sys       375804 Dec  8 17:40 /usr/lib32/libldap10.so*

: I would guess that the /usr/lib32/libldap10.so is corrupt. Is it
: loadable from other programs (I mean, do other programs work with it)?
: You should ask your root to check that.

Hi there.

Thanks for your response.

I'm root. :)  I did check, and the library is accessible from other
applications.

Any other takers?  

Thanks again.

 ...alex...


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

Date: Tue, 9 Dec 1997 15:26:09 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Sorting huge array
Message-Id: <EKxHJL.FIt@world.std.com>

Pontus.Berglund@se.adsanker.com (Pontus Berglund) writes:
>This has brought up another problem though. The list is really a list
>of lists, which I have to initialize like this:

>@arr = ( [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0,
>0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]);

>Is there a more flexible way to do this? I've tried playing around
>with the x operator, but I haven't got it to work.

You could say:

  @arr = ( [0, 0, 0] ) x 10;

(if the expression to the left of the "x" operator is a list, and the
result of the "x" operator is a list as well, the operator returns a
list with the left operand repated the number of times specified by
the right operand.)

or:

  for (1 .. 10) {
    push @arr, [0, 0, 0];
  }

or

  for($elem = 0; $elem < 10; $elem++) {
     push @arr, [0, 0, 0];
  }

(The for(LIST) is visually less cluttered will use less memory for
small numbers, but can can goble up large amounts of memory if the
".." opeator needs to create a huge list. 


-- 
Andrew Langmead


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

Date: Tue, 09 Dec 1997 16:07:27 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Sorting huge array
Message-Id: <348f6930.13676379@news.tornado.be>

Pontus.Berglund@se.adsanker.com (Pontus Berglund) wrote:

>This has brought up another problem though. The list is really a list
>of lists, which I have to initialize like this:
>
>@arr = ( [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0,
>0], [0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]);

Let me try:

	@arr = ([(0) x 3]) x 10;

Nope, that doesn't work: it fills an array with 10 times the SAME
REFERENCE.

	$arr[1][2] = 123;
	print $arr[3][2];

>	123

OK, this then:

	@arr=();
	for ($j=0; $j<10; $j++) {
		push @arr,[(0) x 3];
	}

	$arr[1][2] = 123;
	print $arr[3][2];

>	0

Right.

HTH,
Bart.


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

Date: Tue, 09 Dec 1997 16:05:26 +0000
From: Andrew Wood <andrew.wood@cableol.co.uk>
Subject: using PERL with Personal Web server under 95
Message-Id: <348D6C46.918A6505@cableol.co.uk>

I have installed Front Page on my Windows 95 machine and have PERL on
it.

I have changed the first line of my cgi script to reflect the new
location of perl from its unix form to its Windows form.

I am still getting HTTP/1.0 500 Server errors trying to run the code.

Does anybody have an answer to this problem as the page that Micorsoft
say too look at doesnt exist, which is nothing unusual for them.

Regards

Andrew Wood



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

Date: Tue, 9 Dec 1997 09:32:34 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Andrew Wood <andrew.wood@cableol.co.uk>
Subject: Re: using PERL with Personal Web server under 95
Message-Id: <Pine.GSO.3.96.971209093201.26951T-100000@user2.teleport.com>

On Tue, 9 Dec 1997, Andrew Wood wrote:

> I am still getting HTTP/1.0 500 Server errors trying to run the code.

That's a server error. Have you tried asking in a newsgroup about servers?

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN. Hope this helps!

   http://www.perl.com/CPAN/
   http://www.perl.org/CPAN/
   http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
   http://www.perl.org/CPAN/doc/manual/html/pod/

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 9 Dec 1997 08:54:55 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Josef Gergetz <*NO.SPAM*.josef.gergetz@*NO.SPAM*.siemens.at>
Subject: Re: Which http-server ??
Message-Id: <Pine.GSO.3.96.971209085349.26951K-100000@user2.teleport.com>

On Tue, 9 Dec 1997, Josef Gergetz wrote:

> Can anybody tell me, which Server I should use ?

Yes, and those people who like to answer questions about servers usually
read newsgroups about servers in the hopes that your questions about
servers will be posted there with the other questions about servers. This
newsgroup is about perl. Thanks!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Tue, 09 Dec 1997 15:55:29 GMT
From: sdinitto@kronos.com (Scott DiNitto)
Subject: Re: Wildcards
Message-Id: <348d68cb.320888112@news>

On Mon, 08 Dec 1997 15:28:40 GMT, sdinitto@kronos.com (Scott DiNitto)
wrote:

I found the answer to my problem. Incorporating this code into my
script allows me to invoke any wildcard to the command line option.
Consider this:
ARG.pl

#!/bin/perl

$x = 0;
while ($ARGV[0]){

    print "$x : $ARGV[$x]\n";
    if ($ARGV[$x] eq ""){
        goto end;
    };
    $x++;
};

end:

The end result will allow you to do "perl ARG.pl *" and will give
every filename in the directory. Alternativley, a "perl ARG.pl *.txt"
will give me all the .txt files in the directory. 

I am still  an uneducated amature, that's why this code looks, well,
amature.

SD


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

Date: Tue, 9 Dec 1997 09:12:38 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Scott DiNitto <sdinitto@kronos.com>
Subject: Re: Wildcards
Message-Id: <Pine.GSO.3.96.971209090732.26951P-100000@user2.teleport.com>

On Tue, 9 Dec 1997, Scott DiNitto wrote:

> #!/bin/perl
> 
> $x = 0;
> while ($ARGV[0]){
> 
>     print "$x : $ARGV[$x]\n";
>     if ($ARGV[$x] eq ""){
>         goto end;

[Urk]

>     };
>     $x++;
> };
> 
> end:

That's a poor way to do this, since it fails to allow for empty arguments. 
Maybe you could use this instead. 

    print map "$_ : $ARGV[$_]\n", 0..$#ARGV;

> The end result will allow you to do "perl ARG.pl *" and will give
> every filename in the directory. Alternativley, a "perl ARG.pl *.txt"
> will give me all the .txt files in the directory. 

Yes, although you could do that with /bin/echo as well. :-)

    /bin/echo *.txt

> I am still an uneducated amature, that's why this code looks, well,
> amature. 

We try to be forgiving of "amatures" around here. Well, we try, and
sometimes we fail. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

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

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