[7471] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1098 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 29 15:19:09 1997

Date: Mon, 29 Sep 97 12:00:28 -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           Mon, 29 Sep 1997     Volume: 8 Number: 1098

Today's topics:
     Re: Anyone ever written to a GIF file from perl (Ken Williams)
     Re: Columns in Perl <yash@teczar.com>
     couldn't spawn child process <david@gilmartin.uk.com>
     Re: Die and the Web (Charles DeRykus)
     Embed perl and memory leaks.. <michael@metal.iinet.net.au>
     Hash of subroutine calls (Daveotlc)
     Re: Hash of subroutine calls (Greg Bacon)
     Re: How do I change group (GID) in perl (Jeremy D. Zawodny)
     Re: Java CGI Post to Perl Script (Peter)
     Re: Java CGI Post to Perl Script (Peter)
     Re: logic question . . . <yash@teczar.com>
     Re: logic question . . . <rootbeer@teleport.com>
     Re: Need help accessing tty modem devices within perl!! (Pierre Asselin)
     New Perl syntax idea <chris@ixlabs.com>
     Re: New Perl syntax idea (Greg Bacon)
     Re: Newbie ques: How to concatenate two strings? (Faust Gertz)
     Re: Perl4 is *not* Y2K (was Re: Y2K) (I R A Aggie)
     Re: Perl4 is *not* Y2K (was Re: Y2K) (I R A Aggie)
     Re: Problem of Perl in FrontPage (Jared Evans)
     Problem with Perl on AIX (John Barnes)
     Reading each word from a file <nrana@aludra.usc.edu>
     Re: Reading each word from a file (Greg Bacon)
     Re: Syntax  on assignment and undef (Jason Gloudon)
     Re: syntax <rootbeer@teleport.com>
     Re: syntax (John L. Allen)
     Re: unlink & rename <Moyse_Faurie@msn.com>
     write to variables <dsimon@dls.net>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 29 Sep 1997 13:55:40 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: Anyone ever written to a GIF file from perl
Message-Id: <ken-2909971355400001@news.swarthmore.edu>

Hi-

Yup, I've done this before, and I have zero expertise on the file format
of GIF files.  I used GD.pm, which probably stands for Graphics Drawing or
something like that.  But definitely investigate this package, it will
make your work much easier if you want to create GIFs from inside a Perl
script.

In article <EH9o6y.37J.C.amo@bath.ac.uk>, ab6rah@bath.ac.uk (R A Hart) wrote:

>I was wondering if anybody has any example code to write a GIF file (or 
>something that most browsers can read) from say a 2-d array of colourvalues.
>
>It needn't be too complex (i.e. I'll only want to do single images, 
>256-colours, and only the control blocks necessary to get the image onto 
>the screen.)

-Ken Williams
 The Math Forum
 ken@forum.swarthmore.edu


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

Date: Mon, 29 Sep 1997 14:21:34 -0400
From: Yash Khemani <yash@teczar.com>
To: Dean Dixon <ddean@aracnet.net>
Subject: Re: Columns in Perl
Message-Id: <342FF1AE.F8507014@teczar.com>

Dean Dixon wrote:
> 
> You know how in awk you can use NF to get the number or fields or
> columns
> How can I do this in Perl

i assume you mean "how do i get the number of fields in a list/array?"
for list @list, $#list indicates the field number of the last element
in @list; the field number for the first element is 0.  so for

@list = ('a','b','c','d');

do

print "$#list\n";

and you will see that $#list in this case is 3.

does this answer your question?

cheers!
yash


> Help is much appreciated
> Dean


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

Date: 28 Sep 97 11:51:39 GMT
From: "DAVID GILMARTIN" <david@gilmartin.uk.com>
Subject: couldn't spawn child process
Message-Id: <01bccc05$61af1c20$1c053cc3@surgery.powernet.co.uk>

[Sun Sep 28 12:55:59 1997] access to
/ftp/webs/gilmartin.uk.com/summerhill/guestbook.cgi failed for
ttym1b.powernet.co.uk, reason: couldn't spawn child process

what does "couldn't spawn child process" mean



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

Date: Mon, 29 Sep 1997 17:12:26 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Die and the Web
Message-Id: <EHA54r.Gnu@bcstec.ca.boeing.com>

In article <342faa8a.3392555@news.magna.com.au>,
Jon Hedley <jhedley@REMOVEmustangpcs.com> wrote:
 > Greetings
 > 
 > All of the programming I do in Perl is for output to Web Browsers. I
 > cannot access error logs for my server. Therefore, die is of little
 > help, and I have been getting around this by making my own sub for
 > each program that prints the contents of $! and shuts down the
 > program. Is there a way that I can set die to output to STDOUT rather
 > than the error log?
 > 

One possibility:

use CGI::Carp qw/fatalsToBrowser/;


HTH,
--
Charles DeRykus



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

Date: 26 Sep 1997 17:49:54 +0800
From: Michael O'Reilly <michael@metal.iinet.net.au>
Subject: Embed perl and memory leaks..
Message-Id: <x7afh01k1p.fsf@metal.iinet.net.au>


Is it just me, or do embeded perl interpreters leak memory like
crazy??? 

Taking the trival C program from the perlembed man page, and feeding it a
simple script like
	$a =  1 + 2;
	print "$a $a\n";
seems to leak memory. In fact, EVERYTHING I do with it leaks large
amounts of ram. 

I'm linking against dmalloc, but even just simple counting of the
calls to malloc() and free() tell the story. 32,000 calls to malloc,
11,000 calls to free. 

Umm. What's going on here??? :)

Michael.


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

Date: 29 Sep 1997 16:57:51 GMT
From: daveotlc@aol.com (Daveotlc)
Subject: Hash of subroutine calls
Message-Id: <19970929165701.MAA29298@ladder01.news.aol.com>

I'm building a generalized scanner and want to plug in language specific
code without changing the base script.  My first guess was that I could
require a script (for each language) containing something like this.

$this_language = "Visual Basic";
$lang_routine{"Visual Basic"} =
	{		}
	. . . stuff. . .
	};

Then in the standard script, I could invoke the language plug-in with 

	$lang_routine{$this_language} ($data,$lang_state,$comment_sw);

where $data is the stuff to be checked, $lang_state is the state of the
language plug-in according to what it has already seen, and $comment_sw is
a representative control variable for internal processing.

I welcome any tips that could make this work.

         Thanks,
         Dave Olson
         daveotlc@aol.com


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

Date: 29 Sep 1997 18:00:44 GMT
From: gbacon@adtran.com (Greg Bacon)
To: daveotlc@aol.com (Daveotlc)
Subject: Re: Hash of subroutine calls
Message-Id: <60oqcc$lj3$1@info.uah.edu>

[Posted and mailed]

In article <19970929165701.MAA29298@ladder01.news.aol.com>,
	daveotlc@aol.com (Daveotlc) writes:
: Then in the standard script, I could invoke the language plug-in with 
: 
: 	$lang_routine{$this_language} ($data,$lang_state,$comment_sw);

You can do what you want, but you're syntax is just a bit off.  Use

    $lang_routine{$lang}->(@args);

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Mon, 29 Sep 1997 17:11:30 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: How do I change group (GID) in perl
Message-Id: <3430e12f.1800088@igate.hst.moc.com>

[cc'd automagically to original author]

On Mon, 29 Sep 1997 09:36:41 -0700, Chuck Stein <mirror@scruznet.com>
wrote:

>Greetings,
>
>How can I change the group ID (GID) inside a perl
>script such that I can delete files of the new group
>that are writeable?  Assume I am changing to a group
>that the calling user is part of (but not their
>default group).

Check out the $( and $) entries in the perlvar man page.

Jeremy
-- 
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio

http://www.marathon.com/

Unless explicitly stated, these are my opinions only--not those of my employer.


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

Date: Mon, 29 Sep 1997 16:58:04 GMT
From: peterpan@mailexcite.com (Peter)
Subject: Re: Java CGI Post to Perl Script
Message-Id: <342fddd8.1081840@news.hk.linkage.net>

Hello Brian,

	I have checked that FAQ before. It didn't help.

comdog@computerdog.com (brian d foy) wrote:

>In article <342e81f9.564528@news.hk.linkage.net>, peterpan@mailexcite.com (Peter) wrote:
>
>>I write a Java applet to POST some data to a server
>>script and that script will send back what I post to it. When I use a
>>compiled C script, all things work fine. but when I use a PERL script
>>to replace that C script. I encounter a "Server Error 500" IO
>>exception that produce from the server.  Anybody know what's wrong?
>
>it's very difficult to tell from the information you gave, but 
>you can check the "Idiot's Guide to Solving Perl CGI problems" [1]
>
>
>[1]
><URL:http://language.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html>
>
>-- 
>brian d foy                                  <comdog@computerdog.com>
>NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
>CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>



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

Date: Mon, 29 Sep 1997 16:58:55 GMT
From: peterpan@mailexcite.com (Peter)
Subject: Re: Java CGI Post to Perl Script
Message-Id: <3430de24.1158484@news.hk.linkage.net>

Hello Ben,

	I have checked that Guides and FAQ. It didn't help.

ben@reser.org (Ben Reser) wrote:

>You might want to refer to the following references to help you:
>
>The Idiot's Guide to Solving Perl CGI Problems
>http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html
>
>Perl CGI Programming FAQ 
>http://www.perl.com/CPAN-local/doc/FAQs/cgi/perl-cgi-faq.html
>
>On Sun, 28 Sep 1997 16:13:46 GMT, peterpan@mailexcite.com (Peter)
>wrote:
>
>>Hello All,
>>
>>I write a Java applet to POST some data to a server
>>script and that script will send back what I post to it. When I use a
>>compiled C script, all things work fine. but when I use a PERL script
>>to replace that C script. I encounter a "Server Error 500" IO
>>exception that produce from the server.  Anybody know what's wrong?
>> I have tested my script under debug mode and find it ok. The
>>following is my script:
>>
>>#!/usr/local/bin/perl
>>
>>use CGI qw(:standard);
>>
>>$query = new CGI;
>>
>>$yourname = $query->param('name');
>>$youremail = $query->param('email');
>>
>>print header();
>>print start_html();
>>print $yourname;
>>print $youremail;
>>print end_html();
>
>
>************************* IMPORTANT *************************
>Why the new email address you ask?
>Simple, I'm attempting to simplify the way I filter my mail.
>Please direct all personal mail to ben@reser.org
>Not directing personal mail to this address may cause
>delays in me reading your mail or may even get it deleted.
>************************ IMPORTANT *************************
>
>---
>Ben Reser <ben@reser.org>
>http://ben.reser.org
>	
>-----BEGIN GEEK CODE BLOCK-----
>Version: 3.1
>GCS d-(+)@ s:- a-- C++++$ UBVC++++(++)$ P+++$>++++ L- !E---- W@ N(+)>++ o? K--? w++$@>+++ !O---- !M V PS+(++)@>+++ PE++(+++)@ Y+(++)@ PGP+(++)>+++ t+()@ 5 X !R tv-(+)@>-- b+(++)>+++ DI++ D G e h++ r-()>+++ y? 
>------END GEEK CODE BLOCK------ 



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

Date: Mon, 29 Sep 1997 14:11:58 -0400
From: Yash Khemani <yash@teczar.com>
To: Guy Matz <gmatz@spacelab.net>
Subject: Re: logic question . . .
Message-Id: <342FEF6D.1F2208C8@teczar.com>

methinks it's simpler to stickt to:

if ( (expr0) || (expr1) ...) {
# whatever
}

but you could do what i've done in the following example.  again, the
above
is simpler to understand, but if you make the following part of your
standard
coding practice, it should make sense when you look at it 6 weeks later
:-).

# as an example:

my $param = $ARGV[0];
my @options = ('sun','digital','sgi');

if (in($param,@options)) {
    print "$param\n";
    # or do whatever
};

sub in {
# check to see if first param passed in, $param, is found in remaining
params
# passed in, @options.  once found, return with value 1.
    my ($param,@options) = @_;
    foreach (@options) {
	if ( ($param eq $_) && ($param == $_) ) {
	    return 1;
	};
    };
};


cheers!
yash


Guy Matz wrote:
> 
> anyone have have a slick perl way to do this:
> 
> if expression = this or that
> then . . .
> 
> without having to say:
> 
> if expression = this or expression = that
> then . . .
> 
> thanks,
> guy
> 
> --
> -----------------------------------------------
> gmatz@matz.spacelab.net
> Guy Matz
> Systems Administrator @ matz.spacelab.net
> 
> "That's weird, it's like something out of that twilighty show about that
> zone."
>                                         - homer


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

Date: Mon, 29 Sep 1997 11:34:07 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Guy Matz <gmatz@spacelab.net>
Subject: Re: logic question . . .
Message-Id: <Pine.GSO.3.96.970929111214.12373G-100000@usertest.teleport.com>

On Sun, 28 Sep 1997, Guy Matz wrote:

> anyone have have a slick perl way to do this:
> 
> if expression = this or that
> then . . .
> 
> without having to say:
> 
> if expression = this or expression = that
> then . . .

I think you're asking whether there's a good way to save a temporary value
to use in more than one part of an expression. I often use this kind of
code. 

    {
	my $temp;
	if ( ($temp = &something) == $a or $temp == $b ) { ... }
    }

Probably not so slick as you had hoped, but there it is. Here's another
way which may seem more or less slick than that last one.

    {
	my %good = map { $_, 1 } 
		qw/foo baz bar/;	# List of good values
	if ($good{ &something }) { ... }
    }

Enjoy!

-- 
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: Mon, 29 Sep 1997 17:37:15 GMT
From: lpa@netcom.com (Pierre Asselin)
Subject: Re: Need help accessing tty modem devices within perl!!!
Message-Id: <lpaEHA6A3.L3J@netcom.com>

"Nick Reitman" <nreit00@mail.gpbx.net> writes:

>Is there anyway to use the open command to open a connection to a modem. I
>need to write a program that send some characters to the modem like
>at&b0
>atz
>at&b1
>when I try a command like
>open (MODEM, ">/dev/ttyA00");
>the program stops.
>If anyone can help I would really apprreciate it!

Yes, the open blocks.  It is waiting for the modem to assert
carrier-detect, and the modem won't do that until it answers
an incoming phone call from another modem.  You're writing
a modem-answering program, not a dialout program!

If you were writing in C, the dialout sequence would be:

    1) open /dev/ttytA00 with the O_NONBLOCK flag.
       The open returns immediately with a valid file descriptor.
       The descriptor isn't good for read() or write()'s yet,
       but it's good for ioctl().
    2) Do an ioctl() on the file descriptor to set the C_LOCAL
       flag.  This tells the tty device driver to ignore the
       status of carrier-detect.  You can now read() and write()
       to the descriptor.
    3) Chat with the modem to make it dial out.
    4) When you read the modem's CONNECT string, you can assume
       the modem is asserting carridr-detect (if the modem is
       configured right).  The C_LOCAL is no longer needed,
       so do another ioctl() to reset it.  From now on you'll get
       a SIGHUP if the modems lose connection.
    5) Talk to the remote system.  close() the descriptor
       when you're done.

I think you can do all this in perl.  At step 1, you'll need sysopen()
instead of open().

One more thing.  You can't have a getty on the modem port.  The getty
is doing a blocking open() like your original script was.  As soon as
you set C_LOCAL, the getty will wake up thinking somebody else dialed
in and will compete with you for I/O.  If your system runs a uugetty,
you can lock the modem port before setting C_LOCAL.  This usually
involves creating a lock file in /var/spool/locks or /etc/locks or
other.  The uugetty will wake up, see the lock file and leave the modem
port alone.  I understand modern systems have better arbitration
mechanisms than this lock file nonsense, but my machine's a
dinosaur...

-- 
--Pierre Asselin, Westminster, Colorado
  lpa@netcom.com
  pa@verano.sba.ca.us


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

Date: Mon, 29 Sep 1997 10:36:59 -0700
From: Chris Schoenfeld <chris@ixlabs.com>
Subject: New Perl syntax idea
Message-Id: <342FE73B.41C2@ixlabs.com>

I haven't spent 2 minutes thinking about the pros and cons of this but -
hey, I'll throw it out there.

How about aliasing 'method' to 'sub' and passing the object reference
through a magic variable when 'method' is used?


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

Date: 29 Sep 1997 18:22:49 GMT
From: gbacon@adtran.com (Greg Bacon)
Subject: Re: New Perl syntax idea
Message-Id: <60orlp$lj3$3@info.uah.edu>

In article <342FE73B.41C2@ixlabs.com>,
	Chris Schoenfeld <chris@ixlabs.com> writes:
: How about aliasing 'method' to 'sub' and passing the object reference
: through a magic variable when 'method' is used?

What potential benefits do you see for such an addition?

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Mon, 29 Sep 1997 18:52:04 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Newbie ques: How to concatenate two strings?
Message-Id: <342ff41a.1512909@news.wwa.com>

Joseph <jglosz@san.rr.com> wrote:

> Is it something as simple as
>:$value = $name + $value;

so Jeff Gostin (jgostin@shell2.ba.best.com) wrote:

>From another relative newbie, here's the easy way:
>
>$value = $name . $value;

and then Tad McClellan <tadmc@flash.net> wrote:

>or
>
>   $value = "$name$value"; # this is called 'interpolation' but it
>                           # has the same effect if used as shown

As long as we are playing this game, why not add

$value = join ('', $name, $value);

to the list?

Now let's rank each answer for the various types of efficiency listed
in the Camel book.  :-)  While Tad thinks his interpolation solution
will win for Maintainer Efficiency , I think it might win for
Programmer Efficiency and that Jeff's solution is a strong contender
for Maintainer Efficiency.  In cases like these, does 'join' at least
win for Time Efficiency even if it loses for Programmer and Maintainer
Efficiency?


Streben nach Wahrheit

Faust Gertz
Philosopher at Large



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

Date: Mon, 29 Sep 1997 13:21:56 -0400
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl4 is *not* Y2K (was Re: Y2K)
Message-Id: <-2909971321560001@aggie.coaps.fsu.edu>

In article <342FA53B.6341C9DA@absyss.fr>, Doug Seay <seay@absyss.fr> wrote:

To clarify:

+ Perl4 has security holes (many of which weren't know 3
+ years ago) that have been fixed. 

 ...in Perl5 -- but *never* fixed in Perl4. Perl4 is CERTifiably INsecure.

+ Yes, one can use Perl4, but "can" doesn't imply "should".

Could one write a script that invokes perl4, removes it, and then itself?

James - now _that_ would be a useful perl4 program... :)

-- 
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: Mon, 29 Sep 1997 13:25:43 -0400
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl4 is *not* Y2K (was Re: Y2K)
Message-Id: <-2909971325430001@aggie.coaps.fsu.edu>

In article <8c7mc06vdt.fsf@gadget.cscaper.com>, Randal Schwartz
<merlyn@stonehenge.com> wrote:

+ Dead means that there's a CERT warning out on *all* versions of Perl
+ prior to 5.004.  If you have *any* Perl code that runs on behalf of
+ others (such as CGI), you *are* vulnerable on all prior releases, and
+ ready-to-run automated breakin toolkits are already being circulated
+ amongst the youngsters that would love to hijack your web site.

So, you're saying that I should remove the perl4 that our vendor
so thoughtfully included with their system software?

Crimmy. And I *know* we have perl4 programs lying around.

James

-- 
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: 29 Sep 1997 17:49:19 GMT
From: jared@node6.frontiernet.net (Jared Evans)
Subject: Re: Problem of Perl in FrontPage
Message-Id: <60opmv$1nb8$1@node6.frontiernet.net>

In article <342FB442.E29ADD4E@helsinki.fi>,
Jari Vanha-Eskola  <Jari.Vanha-Eskola@helsinki.fi> wrote:
>Instead I have to use URL's like
>http://server/cgi-bin/perl.exe?script.pl
>to run them. I've tried everything I know to get the associations to work, but to
>no avail. Has anybody managed to get them to work with Win95&FP PWS? Please let me
>know, if so!

This is a serious security hole.  I suggest you try setting up the association.
You'll eventually get it to work.  Move the perl.exe to a different directory 
off the web.


-- 
Jared Evans      Manufacturing Technology Analyst/Developer @ The Gleason Works
http://www.frontiernet.net/~jared


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

Date: Mon, 29 Sep 1997 18:02:22 GMT
From: jbarnes@dnai.com (John Barnes)
Subject: Problem with Perl on AIX
Message-Id: <342fec89.2580838@news.dnai.com>

Hello

I'm having a problem running socket perl scripts under AIX 4.1.2.  I
keep getting the error message can't find symbol inet_aton.  I
installed the binary's that I down loaded from www-frec.bull.com.
It looks like perl is installed correctly because everything else
works.  The script seems to work fine on A HPUX box that I have here.
Any one have an idea on what I could try next, thanks.


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

Date: 29 Sep 1997 10:30:53 -0700
From: Nadeem Rana <nrana@aludra.usc.edu>
Subject: Reading each word from a file
Message-Id: <Pine.SV4.3.94.970929102740.21775G-100000@aludra.usc.edu>

Could anyone let me know how to read each owrd from a file? I have a file
with meanings of medical temrs and the syntax is like this

	
Word1: the meaning is here 
	can be multiple lines meanings...


Word2: meaning of this word goes here (might have 3 or 4 lines meaning)


What i need to do is to generate a separate file for each word and the
name of the file will be the word and the contents of that file will be
its meaning. So if i have 100 words then there will be 100 files as a
result.

Thanks
Nadeem



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

Date: 29 Sep 1997 18:20:23 GMT
From: gbacon@adtran.com (Greg Bacon)
To: Nadeem Rana <nrana@aludra.usc.edu>
Subject: Re: Reading each word from a file
Message-Id: <60orh7$lj3$2@info.uah.edu>

[Posted and mailed]

In article <Pine.SV4.3.94.970929102740.21775G-100000@aludra.usc.edu>,
	Nadeem Rana <nrana@aludra.usc.edu> writes:
: Could anyone let me know how to read each owrd from a file? I have a file
: with meanings of medical temrs and the syntax is like this
:
: Word1: the meaning is here
: 	can be multiple lines meanings...
:
: What i need to do is to generate a separate file for each word and the
: name of the file will be the word and the contents of that file will be
: its meaning. So if i have 100 words then there will be 100 files as a
: result.

    #! /usr/bin/perl -w

    sub usage { "Usage: $0 <word file>\n" }

    sub write_word {
        my $word = shift;
        my $def  = shift;

        open WORD, ">$word" or die "$0: failed open >$word: $!\n";

        $def =~ s/\s+/ /g;
        print WORD $def, "\n";

        close WORD;
    }

    $0 =~ s!^.*/!!;

    my $words = shift || die usage;

    my $last_word = '';
    my $last_def  = '';

    open WORDS, $words or die "$0: failed open $words: $!\n";
    while (<WORDS>) {
        chomp;

        next unless /\S/;

        if (/^([^:]+):\s*(.*)/) {
            write_word $last_word, $last_def if $last_word;

            $last_word = $1;
            $last_def  = $2;
        }
        elsif ($last_word) {
            $last_def .= " $_";
        }
        else {
            die "$0: format error at $words line $.\n";
        }
    }
    write_word $last_word, $last_def if $last_word;

    close WORDS;

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 29 Sep 1997 18:47:08 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: Syntax  on assignment and undef
Message-Id: <60ot3c$jk2$1@daily.bbnplanet.com>

Eike Grote (eike.grote@theo.phy.uni-bayreuth.de) wrote:
: Hi,

: Helmut Jarausch wrote:
: > 
: > Hi, please explain the following behaviour of Perl!
: > 
: > sub List  { return (1,2); }
: > sub Empty { return (); }
: > sub Undef { return undef; }
: > 
: > my ($a,$b);
: > 
: > print "OK\n"  if ($a,$b)= List;        # prints OK as expected
: > print "Fail\n"  unless ($a,$b)= Empty; # prints Fail as expected
: > 
: > BUT
: > print "OK\n"  if ($a,$b)= Undef;       # prints OK quite unexpectedly


Interesting sideline here.
This compiles and does absolutely nothing.

() = (1,23);


Jason Gloudon


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

Date: Mon, 29 Sep 1997 11:49:24 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Per Kistler <kistler@inf.ethz.ch>
Subject: Re: syntax
Message-Id: <Pine.GSO.3.96.970929114202.12373H-100000@usertest.teleport.com>

On Mon, 29 Sep 1997, Per Kistler wrote:

> Subject: syntax

It would be nicer to use a more-descriptive subject line, since many
questions are about syntax. :-)

> Where does the unless go:
> 
> $a = 'foo' unless $b;

Right there. :-)

> when I write it like:
> 
> $a = <<EOF;
> foo
> EOF

With here docs, the <<"EOF" token is a "unit". So you can do this.

    $a = <<"EOF" unless $b;
blah blah blah
EOF

Or this.

    $a = <<"EOF" ^ <<"EOF";
string one
EOF
string two
EOF

You can even do things like this.

    @list = map { local($_) = $_; s/#.*//; split } <<"MARK";
	foo bar 	# Comments can go here!
	baz blah
MARK

That is similar to qw//, but allows comments. Have fun with it!

-- 
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: 29 Sep 1997 14:42:43 -0400
From: allen@gateway.grumman.com (John L. Allen)
Subject: Re: syntax
Message-Id: <60osr3$ooh@gateway.grumman.com>

In article <34304766.D02FEE34@inf.ethz.ch>,
Per Kistler  <kistler@inf.ethz.ch> wrote:
>Hi All
>
>Where does the unless go:
>
>$a = 'foo' unless $b;
>
>when I write it like:
>
>$a = <<EOF;
>foo
>EOF

Anywhere you want!

$a = <<EOF unless $b;
foo
EOF

-or-

$a = <<EOF
foo
EOF
unless $b;

TMTOWTDI

John.
-- 
_/JohnL\_allen@gateway.grumman.com <Sun>: 9.5 billion pounds per sec to energy
~\Allen/~Fax: 516-575-7428    <Universe>: 1e22 stars = 22 solar masses per sec


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

Date: Mon, 29 Sep 1997 11:44:09 -0700
From: "Moyse_Faurie" <Moyse_Faurie@msn.com>
Subject: Re: unlink & rename
Message-Id: <01bccd10$2eea2940$8d4efac2@moysecla>


Hello
Maybe is it a problem of rights (for exemple, on
a Unix station): Most Http servers give
the user nobody for applications, so you should
verify the rights
Hope it helps, Timothee



Omar zalouq <opx1@rocketmail.com> a icrit dans l'article
<01bccb87$6058ff40$LocalHost@random>...
> Hi,
> 
> part of my script is as follows:
> 
> unlink ("man.txt");
> rename ("temp.txt", "man.txt");
> 
> when it is executed from xterm everything goes fine,
> but when the script is executed from netscape, It fails to do the above
> actions,but does not give any errors, hhmmmmm.....
> 
> thanx for your help!!
> pls mailto: no@earthling.net
> 
> 


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

Date: Mon, 29 Sep 1997 14:15:26 -0500
From: Doug Simon <dsimon@dls.net>
Subject: write to variables
Message-Id: <342FFE4E.180E@dls.net>

I am trying to capture the output of:

write;

in a variable.

I have tried redirecting STDOUT to a file, and then reading the file:

open(STDOUT,">$foo");
write;

This works fine, but I can not get regular STDOUT back!!  I have tried
nerly everything!  Please help.

1) How do I get STDOUT back?
	or
2) Is there a better way to do this?

Thanks,

-Doug
dsimon@dls.net


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

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

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