[6486] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 111 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 13 16:37:59 1997

Date: Thu, 13 Mar 97 13:00:20 -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           Thu, 13 Mar 1997     Volume: 8 Number: 111

Today's topics:
     Awk is better than Perl? <randall.hron@paranet.com>
     Re: Basic I/O and 'if vs unless' questions <tchrist@mox.perl.com>
     Re: Elegant way to strip spaces off the ^ and $ of a va (Jeffrey)
     Re: Elegant way to strip spaces off the ^ and $ of a va <rra@cs.stanford.edu>
     Re: File path separators <tchrist@mox.perl.com>
     Re: File path separators <tchrist@mox.perl.com>
     Re: how to delete last line in .txt.file (Tad McClellan)
     How to use a scalar to hold a FILEHANDLE (?) (James L. McGill)
     Re: Is possible in perl run a string like a piece of pr (Jan Schipmolder)
     Re: Numeric function (William R. Somsky)
     parse html files to ascii db..... jpooser@gsd.harvard.edu
     perl, java programmers wanted <walston1@walston1.com>
     Re: Problems with search engine. Please help (A. Deckers)
     Quick answers to Perl Q's ( was Re: 3 Easy questions.) (Tad McClellan)
     Re: Quick answers to Perl Q's ( was Re: 3 Easy question <wkuhn@uconect.net>
     Re: Resolving variables in print statement? <tchrist@mox.perl.com>
     Re: Signal catching with alarm (David DeSimone)
     Re: Standard "Reaper" procedure doesn't work on Solaris (Casper H.S. Dik - Network Security Engineer)
     suggestion for perltoot <msouth@shodor.org>
     Re: syntax correction (Mik Firestone)
     Re: syntax correction <...petri.backstrom@icl.fi>
     Re: syntax correction (Tad McClellan)
     Re: Why are my rand() values so tiny? (David DeSimone)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 13 Mar 1997 13:30:00 -0500
From: "Randall W. Hron" <randall.hron@paranet.com>
Subject: Awk is better than Perl?
Message-Id: <332847A8.1A1@paranet.com>

The new Perl FAQ is great, but it gives an answer I don't want.
Here's the FAQ question and answer:

I put a pattern into $/ but it didn't work. What's wrong?

$/ must be a string, not a pattern. Awk has to be better for something.
:-) 

Here is the problem.  I have a text file (or a process output)
that looks like:

1  hi (there)
  hello
    how are you == good
19 this is a new 
  paragraph.
0  Here is another
   paragraph: 
  that has [more]
   lines.

I want to break the text into paragraphs.  I wanted to
use a line beginning with a number as the paragraph delimeter,
but the FAQ says $/ must be a string.  Anyone know a clever way
to split multi-line text so the input above would be three lines
and beginning with the whatever comes after the number in the
first column?

-- 
Randall W. Hron
mailto:randall.hron@paranet.com


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

Date: 13 Mar 1997 18:15:49 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Basic I/O and 'if vs unless' questions
Message-Id: <5g9g8l$l22$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Russ Allbery <rra@cs.stanford.edu> writes:
:Because, due to a design decision made eons ago, Unix commands return 0 if
:they succeed and non-zero on failure.  The C library call system()
:preserves this behavior, which is then preserved by Perl.  So system() in
:Perl will return 0 (false) if the command succeeded and non-zero (true) if
:it failed.

I strongly suspect that the reason for that decision was that it is more
interesting (read: useful) to have several kinds of failure return values
than it is to have several kinds of success return values.

While it could well be argued that for varying success stories, we
always have stdout, then it would probably also be argued that for
varying failure stories, we have stderr.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    echo "I can't find the O_* constant definitions!  You got problems."
            --The Configure script from the v5.0 perl distribution


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

Date: 13 Mar 1997 18:37:14 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: Les Peters <lpeters@aol.net>
Subject: Re: Elegant way to strip spaces off the ^ and $ of a variable containing a sentence.
Message-Id: <JFRIEDL.97Mar14033714@tubby.nff.ncl.omron.co.jp>


[mail and post]

Les Peters <lpeters@aol.net> wrote:
|> > $variable = "    jklsd jslkjsd   ";
|> > I want to strip off all the spaces before and after the string above so
|> > the resulting string should look like:
|> >     $variable = "jklsd jslkjsd";
|
|> $var =~ s/^\s+(\S.*\S)\s+$/\1/;

I think that falls into the "cute" category, not elegant.
Also, it requires both leading and trailing spaces, *and* two non-space
characters, so I'm guessing it won't work on "this " or " that" or " x ".

Also, \1 in a *regex* (the left hand part) is a backreference, but in a
string (i.e. the substution text) it's an octal escape for the Control-A
character (if you're speaking ASCII, that is). (You meant to use $1.)

Perhaps it's also boring, but I'd call the following "elegant":
	$variable =~ s/^\s+//;
	$variable =~ s/\s+$//;

Jeffrey
----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@ora.com> Omron Corp, Nagaokakyo, Kyoto 617 Japan
See my Jap<->Eng dictionary at http://www.wg.omron.co.jp/cgi-bin/j-e
O'Reilly's Regular Expression book: http://enterprise.ic.gc.ca/~jfriedl/regex/


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

Date: 13 Mar 1997 12:16:08 -0800
From: Russ Allbery <rra@cs.stanford.edu>
Subject: Re: Elegant way to strip spaces off the ^ and $ of a variable containing a sentence.
Message-Id: <qum7mjbr1iv.fsf@cyclone.stanford.edu>

Tom Christiansen <tchrist@mox.perl.com> writes:

> In comp.lang.perl.misc, abigail@ny.fnx.com writes:

>> Elegant you said... Here's a way without using ()'s in the regex, or
>> having to type the variable twice. And it's easy to add more variables.

>> map {s/^\s+//; s/\s+$//;} $variable;

> No, that's a bad way.  You ignored the return value of the function.
> Map is a filter function.  It seems far less deceptive to write

>     for ($variable) {
> 	s/^\s+//; 
> 	s/\s+$//;
>     } 

This has gone back and forth in other fora as well, and I disagree with
Tom on this score.  It's purely a stylistic difference, and it's rooted as
far as I can tell in a C vs. LISP mentality.

To me, map has two interpretations; it can either be used as a filter
function as you mention above or it can be used to apply a block of code
to every element of an array.  It lets one put the code block closer to
the beginning of the line, which I think makes for clearer code since it's
closer to the way English is written (do _this_ to _that_).

This is very much an issue of how code reads.  I agree, for example, that
using grep in a void context is bad, but that's because grep is mentally
connected to "returns the result of a search" in most people's minds.
map, on the other hand, is mentally connected to "apply this function to
this array" in a lot of people's minds, and that makes perfect sense in a
void context.

Programmers ignore return values constantly.  The return value of print is
regularly annoyed, for example.

-- 
Russ Allbery (rra@cs.stanford.edu)      <URL:http://www.eyrie.org/~eagle/>


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

Date: 13 Mar 1997 18:18:30 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: File path separators
Message-Id: <5g9gdm$l22$3@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    jbaagoe@planete.net (Johannes Baagoe) writes:
:sources I have seen simply say someting like $path = "$dir/$file", this
:is 1. Unix-dependent, 2. wrong if $dir already contains a trailing
:slash.

Wrong is probably too strongly worded.  POSIX says duplicate slashes
are irrelevant.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


There's going to be no serious problem after this.  --Ken Thompson


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

Date: 13 Mar 1997 18:19:24 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: File path separators
Message-Id: <5g9gfc$l22$4@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    jbaagoe@planete.net (Johannes Baagoe) writes:
:Would it be a good idea to include a routine that does this in
:File::Basename? I could attempt to write one for the architectures
:already provided for (Unix, MS-DOS, MacOS and VMS) by inspecting the
:existing source and assuming it is right, but I have no way to test on
:VMS. Is it worth the trouble? Has somebody else already done it?

If you do do so, please use slash for WinDOS, not backslash.

--tom

-- 
	Tom Christiansen	tchrist@jhereg.perl.com


    "A good messenger expects to get shot." --Larry Wall


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

Date: Thu, 13 Mar 1997 07:04:05 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: how to delete last line in .txt.file
Message-Id: <50u8g5.dl.ln@localhost>

Tom Boeken (boeken@rdc.nl) wrote:
: Can someone point out to me how to 
  ^^^^^^^^^^^

Yes. *You* can!


: delete the last line in a plain
             ^^^^^^^^^

Golly. I don't know. Guess I'll have to resort to looking in the
free documentation that is included with the perl distribution:

grep 'last line' *.pod

perlfunc.pod:    # insert dashes just before last line of last file

So, modify the code given there to not print the line, rather than
add a line before the last line...


Or, for a one-liner:

perl -pe 'exit if eof'  filename


: text file from a Perl-script?
: thanks!


Uh huh.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 13 Mar 1997 07:27:06 -0600
From: fishbowl@fotd.netcomi.com (James L. McGill)
Subject: How to use a scalar to hold a FILEHANDLE (?)
Message-Id: <5g8vba$plv@fotd.netcomi.com>

Every time I open a file, I do something like:

#---------------------------------------------------------------

use DB_File;
use Fcntl;


$tied_domain= tie %db_domain, DB_File, "domain.db", O_RDWR|O_CREAT, 0600, $DB_HASH;
&FatalExit (__FILE__ .",". __LINE__." $!" ) unless $tied_domain;

$filedes = $tied_domain->fd ;
$fhopen_domain= open( DOMAIN_FH, "+<&=$filedes" );
&FatalExit (__FILE__ .",". __LINE__." $!" ) unless $fhopen_domain ;

$retries = 60;  # Time out if you can't get a lock by now.
while( $retries-- ){
    $lock_domain = flock (DOMAIN_FH, LOCK_EX | LOCK_NB) ;
    last if( $lock_domain );
    sleep (1) ;
}

&FatalExit (__FILE__ .",". __LINE__." $!" ) unless $lock_domain ;

print "Hooray, you are safe!\n";

sub LOCK_SH { 1 }
sub LOCK_EX { 2 }
sub LOCK_NB { 4 }
sub LOCK_UN { 8 }


#---------------------------------------------------------------

But I would like the locking operation to be a function.

To complicate things, I often work across NFS where I will
take the filename and create a representative file and lock 
it instead.  I would also like to make that a function.  But
I do not know how to make a variable work in the place of a
filehandle.  

I imagine most of you deal with this issue.  Can you help me
by giving insight?  Thanks!

--
g-r-a-t-e-f-u-l-l-y---[   email:<fishbowl@conservatory.com>   ]---l-i-v-i-n-g
d-e-a-d-i-c-a-t-e-d---[ http://www.conservatory.com/~fishbowl ]-----l-i-g-h-t
Chicken Little only has to be right once.


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

Date: 13 Mar 1997 18:26:39 GMT
From: schip@lmsc.lockheed.com (Jan Schipmolder)
Subject: Re: Is possible in perl run a string like a piece of program?
Message-Id: <5g9gsv$avh@butch.lmsc.lockheed.com>

Maurizio Belluati (Maurizio.Belluati@cselt.stet.it) wrote:
: Hello,
: 
: We've a perl application that need to read math functions stored (like
: strings) in a file. After read the function we need to process it. So a


-----cuthere-----
$x = '$y = 3 + sin(4)';
eval $x;
print "y = $y\n";
-----cuthere-----

works for me.

--
jan.b.schipmolder@lmco.com


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

Date: 13 Mar 1997 19:46:45 GMT
From: somsky@dirac.phys.washington.edu (William R. Somsky)
Subject: Re: Numeric function
Message-Id: <5g9lj5$k7c@nntp1.u.washington.edu>

In comp.lang.perl.misc, 
gml4410@ggr.co.uk (Lack Mr G M) writes:
>|>        warn "not a decimal number" unless /^[+-]?\d+\.?\d*$/
>                                                    ^^^
>   Surely  should be \d*?  

In article <5g99b9$g9m$1@csnews.cs.colorado.edu>,
Tom Christiansen  <tchrist@mox.perl.com> replied:

> Ah, so the null string is a valid number, eh?  I think not.
> 
>     /
> 	^		# start of string
> 	    [+-]?	# maybe a sign
> 	    \d*		# maybe some digits
> 	    \.?		# maybe a dot
> 	    \d*		# maybe some digits
> 	$		# end of string
>     /x
> 
> All those maybes add up to a big fat nothing, and you lose.  Bad idea.  
> 
> See p127 of `Mastering Regular Expressions' from ORA by Jeffrey Freidl,
> which treats with this precise topic.

Yep.  The simple \d+ -> \d* transformation won't do what you want.
If you want .2 to be acceptable, then what you'll want is something like:

    warn "not a decimal number" unless /^[+-]?(\d+\.?\d*|\.\d+)$/

________________________________________________________________________
Dr. William R. Somsky			      somsky@phys.washington.edu
Department of Physics, Box 351560		 B432 Physics-Astro Bldg
Univ. of Washington, Seattle WA 98195-1560		    206/616-2954


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

Date: Thu, 13 Mar 1997 14:41:13 +0000
From: jpooser@gsd.harvard.edu
Subject: parse html files to ascii db.....
Message-Id: <33281208.315C@gsd.harvard.edu>

I'm working on a script that looks in the current directory and all
subdirectories for files ending in *.htm or *.html, reads these files
in, extracts certain information, and writes the results out into a
flat, tab delimited database (ascii file).

Are there any public domain libraries/scripts out there that I might be
able to use (all or parts of)- I hate to re-invent the wheel- 

Some issues I'm having are:


1.) I'm using the Open File Handle and an if loop to look for
regexpression(s):


$test_file =  "index.htm";

open(FILE,"$test_file") || die "cannot open $test_file for reading";

while (<FILE>) {
	if ( m:<TITLE>(.*)</TITLE>:xsgi ) {

   print "title: $1\n";

	}
}

 but it doesn't work if the html has a \n in the tile.  What's a better
way?


2.) what's a good way to perform an operation on files in the current
directory and all subdirectories?


3.) There's gotta be someone who's already done this type of
stuff...?.....


Please respond directly:

jpooser@gsd.harvard.edu

Thanks-


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

Date: Thu, 13 Mar 1997 15:06:45 -0500
From: "John N. Walston" <walston1@walston1.com>
Subject: perl, java programmers wanted
Message-Id: <33285E55.360F@walston1.com>

hi gang,

a headhunter friend of mine is searching for talented programmers for an 
expanding internet company.....They are looking for people that can 
program java and perl.

if you are interested, send me your name and telephone number where you 
  can be reached....I'm not promising you a job, but who knows...

john walston
walston1@voicenet.com
http://walston1.com/


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

Date: 13 Mar 1997 18:24:55 GMT
From: Alain.Deckers@man.ac.uk (A. Deckers)
Subject: Re: Problems with search engine. Please help
Message-Id: <slrn5ighjo.prb.Alain.Deckers@nessie.mcc.ac.uk>

In <01bc2e50$f74b4d60$0681efc2@sonderby>,
	Peter Sxnderby <sonderby@vip.cybercity.dk> wrote:
>Hi there..
>
>I4m working with a search engine which has to search a plain txt file. in
>the format:
>
>Filename |  filearea | description
>
>I have two problems
>
>1. When I get the search result the script cuts off the last letter. (eg.
>ZIP becomes .ZI) ???? 
>
>2 I would like to choose between 8 different txt files to search. I have
>found a Perl script at http:www.technotrade.com which I have rewritten, but
>i can4t implement the part concerning this problem..
>
>Please take a look at http://www.oc.dk 
>
>Here goes my script.  
>
>
>Please reply in email sonderby@vip.cybercity.dk
>
>-- 
>Regards. Peter Sxnderby
>Homepage at --> http://www.oc.dk
>
>
>begin 600 opg.cgi
>M(R$O8FEN+W!E<FP*(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C
>M(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,C(R,*"B,@("1L:6YK
[...]

1. comp.lang.perl.misc is not a free consulting service. It's a group
where people help each other out, by donating their time and experience.
If you want to get an answer to your question it's your responsibility to
state your problem clearly and succintly in your post. Don't expect
people to go chasing around the web to find what your problem is. If you
want a consultant, say so and they will send you their rates.

2. If you expect people to donate their time to answer your question, you
can also donate some of your time to read the group. :-)

3. Don't post encoded files to this group, because a) this group is not
intended to carry such traffic, and b) it makes more work for anyone who
might feel inclined to answer your question (they have to decode the
stuff).

In short, if you have a specific, Perl-related question, feel free to
post it to comp.lang.perl.misc together with the *relevant* code and
diagnostic information, and then only after you have read the FAQ (see
URL below). Otherwise, you're wasting your time.

HTH,
-- 
Alain.Deckers@man.ac.uk          <URL:http://www.man.ac.uk/%7Embzalgd/>
Perl information: <URL:http://www.perl.com/perl/>
        Perl FAQ: <URL:http://www.perl.com/perl/faq/>
   Perl software: <URL:http://www.perl.com/CPAN/>


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

Date: Thu, 13 Mar 1997 12:00:25 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Quick answers to Perl Q's ( was Re: 3 Easy questions.)
Message-Id: <pbf9g5.572.ln@localhost>


Nick Curtis (nick@batfink.demon.co.uk) wrote:

[
  Nick,

  This is in _no way_ an attack on you.

  It is not even *to* you. It is to all members of the c.l.p.m community.

  I just gotta let it out, and your's is a good example.

  Hope you don't mind.

  I will, by the way, eventually get to answering all your questions,
  after the sermon ;-)

]


: OK, I have three little posers that I need to ask. 
                                 ^^^^^^^^^^^^^^^^^^

I don't really think you _need_ to ask them here though...

As this is your first posting to the newsgroup, all you really need to
do is wait for the autoFAQ to be emailed to you. When you get it,
you will have a list of several ways to try and answer your question
*faster* than posting.

Please read it, and keep it around, when it gets there.



: 1. How do you change a string to be either all caps or all non-caps?
                                                 ^^^^
                                                 ^^^^


There is a wealth of *free* information that is *included* with
the perl distribution. These are called POD (Plain Old Documentation)
files. They have a .pod filename extension.


Go find where the .pod files are on your system.


if (they are not on your system)
   if (sysadmin installs them)
      print "Thanks a lot for making this invaluable resource available\n";
   else
      ask SYSADMIN your perl questions, 'til *they* get tired of it.
      then (sysadmin installs them)  ;-)

(ask him/her for the new Perl FAQs too! )


But you really don't want to be waiting around for the sysadmin to
break down.

Because by then you will have wasted _your_ time. Searching
the docs is most often *faster* than composing a Usenet posting...

Because by then you will have wasted _our_ time, answering a question
that has been answered *many* times before. (That's why the answers
have been put into the docs!).


So, you just can't continue doing _productive_ perl programming until
you get access to this wealth...

Get your own personal copy until the sysadmin comes gets around to
installing them.


See http://www.perl.com to become information rich, and impress your
friends and boss with how quickly you overcome Perl programming
tasks !

--------

When I take that search term from your own wording above and look for
it:

grep caps *.pod

I find:

-------------
perldiag.pod:encapsulation of objects.  See L<perlobj>.
perlfunc.pod:    @nums = @caps = ();
perlfunc.pod:   push @caps, uc($_);
perlfunc.pod:                   $caps[$a] cmp $caps[$b]
perlmod.pod: $no_caps_here    function scope my() or local() variables
perlref.pod:encapsulation without a very good reason.  Perl does not enforce
perlref.pod:encapsulation.  We are not totalitarians here.  We do expect some basic
perlstyle.pod:    $no_caps_here    function scope my() or local() variables
perlsub.pod:encapsulated into a small pill that's easy to swallow.
-------------


Those perfunc ones look like they might be talking about upper case...


-------------
    # same thing, but much more efficiently;
    # we'll build auxiliary indices instead
    # for speed
    @nums = @caps = ();
    for (@old) {
        push @nums, /=(\d+)/;
        push @caps, uc($_);
-------------
                    ^^
                    ^^

So then you go look up uc() to see what it does.


**************************************************************
And there you go. In about, what?,  60-180 *seconds* you have the answer!
                                    ^^^^^^^^^^^^^^^^

Now that's what I would call productivity!
**************************************************************

Your Boss will love you (and give you a big raise, (LOL)).

Your Friends will whisper to each other "That Nick is a real whiz
at Perl programming. I wonder how he knows so much?".

Your Family will be so proud of you.

*You* will be able to increase your stock in the Three Virtues
of a Programmer (according to Larry Wall):


1) Impatience

   You want the answer *now*. You don't want to have to spend 5
   minutes writing up a posting, when you can get the answer
   in less time by just having this documentation around.

2) Laziness

   You don't want to have to spend 2 hours figuring out "how to
   split on commas except when they are in double quotes" (for
   example). You want to just find out about, and then use ;-),
   the solution given by Jeffrey Friedl in the new FAQ part 4.

3) Hubris

   You will whisper to yourself "I sure am a real whiz
   at Perl programming. I know how I know so much."  ;-)




: 2. How do you truncate a string, or get a substring?
                                            ^^^^^^^^^
                                            ^^^^^^^^^


grep substring perlfunc.pod

finds four lines:

variable to--but don't do that).  If the substring is not found, returns
created from each matching substring in the delimiter.
Extracts a substring out of EXPR and returns it.  First character is at
Here's a subroutine that does substring:


Boy that third line sure does look promising, don't you think?

So, you go read that part of perlfunc.pod.


**************************************************************
And there you go. In about, what?,  60-180 *seconds* you have the answer!
                                    ^^^^^^^^^^^^^^^^

Now that's what I would call productivity!
**************************************************************


: 3. How do I get a list of all environment variables sent from a web
                                ^^^^^^^^^^^^^^^^^^^^
                                ^^^^^^^^^^^^^^^^^^^^
: browser???


grep 'environment variable' *pod

finds eight lines. But none of them look very helpful  ;-(

hmmm ...

grep environment *pod

finds eighteen lines. Three that look helpful:

------
perlfunc.pod:calls in the program.  The following prints out your environment like
perlfunc.pod:to print your environment:
perlvar.pod:The hash %ENV contains your current environment.  Setting a
------

So, you go read about it in perlfunc.pod. There you find code
that does it!

-------
    while (($key,$value) = each %ENV) {
        print "$key=$value\n";
    }
-------


**************************************************************
And there you go. In about, what?,  60-180 *seconds* you have the answer!
                                    ^^^^^^^^^^^^^^^^

Now that's what I would call productivity!
**************************************************************


So, just searching for *your own words* taken from your question,
leads to all three answers in about 5-10 minutes.

Wanna write 'em up, post 'em, and wait hours (days?, forever?),
for *someone else* to look them up for you?

Do that a few times and folks will begin to ignore all your questions...



: I tried 

: foreach $key (sort keys(%ENV)) {print "$key = $ENV($key)\n};
                                                    ^^^^^^
 ... {print "$key = $ENV{$key}\n};
                       ^    ^



: but with perlIS.dll it only shows    PERLXS = PERLIS.DLL

: Help much appreciated.
  ^^^^^^^^^^^^^^^^^^^^^

If your _truly_ are appreciative, you'll expend a little of your
own effort before asking others to expend effort for you.


: NickC (told you it was quick and easy!!!!).
                         ^^^^^^^^^^^^^^

hours (days?, forever?) doesn't seem very quick to me, compared to
5-10 minutes...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Thu, 13 Mar 1997 13:52:47 -0500
From: Bill Kuhn <wkuhn@uconect.net>
To: Tad McClellan <tadmc@flash.net>
Subject: Re: Quick answers to Perl Q's ( was Re: 3 Easy questions.)
Message-Id: <33284CFF.27CC78F4@uconect.net>

Tad,

Where do I learn more about that "grep" thing you keep talking about?

:-)

-- 
Bill Kuhn
Chief Developer
Wired Markets, Inc.
http://www.buyersindex.com


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

Date: 13 Mar 1997 18:25:41 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Resolving variables in print statement?
Message-Id: <5g9gr5$l22$5@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    sghose@tiger.lsu.edu (Subesh  Ghose) writes:
:  I am having trouble resolving the variable in my print statement. Here
:are the lines of code:
:
:$outfile = 'g:\\htmldoc\\dc\\docs\\wkreport\\wkreport.htm';
:open (OUTFILE, ">$outfile") || die "Couldn't open #!\n";
:print OUTFILE '<dt>Report week ending <a href="/wkreprt/$week.htm">$date</a>';
:                                                        ^^^^^^^^^  ^^^^^
:
:  I cannot get these variables to resolve. Is my syntax correct for the
:print line? Any help is appreciated.

0)  Get the FAQ.  http://www.perl.com/perl/faq/

1)  Quit using backslashes instead of forward ones in path names.  You'll
    just hate yourself for it later.  Trust me.  Yes, I don't you're running
    under bastard operating system from hell.  Doesn't matter.  Just use 
    forward slashes.  Here's a FAQ about it:

	Question:
	    Why can't I use "C:\temp\foo" in DOS paths?  
	    What doesn't `C:\temp\foo.exe` work?

	Answer: 
	    Whoops!  You just put a tab and a formfeed into that filename!
	    Remember that within double quoted strings ("like\this"), the
	    backslash is an escape character.  The full list of these is
	    in L<perlop/Quote and Quote-like Operators>.  Unsurprisingly,
	    you don't have a file called "c:(tab)emp(formfeed)oo" or
	    "c:(tab)emp(formfeed)oo.exe" on your DOS filesystem.

	    Either single-quote your strings, or (preferably) use forward
	    slashes.  Since all DOS and Windows versions since something
	    like MS-DOS 2.0 or so have treated C</> and C<\> the same
	    in a path, you might as well use the one that doesn't clash
	    with Perl -- or the POSIX shell, ANSI C and C++, awk, Tcl,
	    Java, or Python, just to mention a few.

2)  Quit using single quotes instead of double ones to do interpolation.
    Oh, you have double quotes in the string already?  That's what qq()
    is for.  See the perlop man page.

3)  While we're on the subject, please scan through some of the manpages
    included with the Perl distribution.  They have enough examples of
    this kind of thing to make it clear what's the problem.

4)  You might want to pick up one or two of the 4- or 5-camel rated books
    from http://www.perl.com/perl/critiques/

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


There's going to be no serious problem after this.  --Ken Thompson


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

Date: 13 Mar 1997 12:25:27 -0600
From: fox@convex.com (David DeSimone)
Subject: Re: Signal catching with alarm
Message-Id: <5g9gqn$cip@mikey.convex.com>

In <01bc2e99$7d00a700$1fc270ce@ras_schramm.scripps.com> "Rich Schramm" <schramm@one.net> writes:

> It appears that my signal catching code is not functioning.  [...]
> Similar code used for the ALRM sig seems to have no effect.

>  sleep 10; # for testing signal

Sorry, this won't work.

>From sleep(3):

     The sleep routine uses the SIGALRM signal, thus temporarily
     redefining the existing SIGALRM signal handler and tem-
     porarily unblocking SIGALRM.  If a SIGALRM is pending on
     entry, sleep() will return immediately with the pended sig-
     nal discarded.

Thus, sleep() is incompatible with alarm().



-- 
David DeSimone      | "There is no reason for any individual to have a
fox@convex.hp.com   |  computer in their home." -- Ken Olson, President of
 If I said it, it   |         DEC, World Future Society Convention, 1977
 must be my opinion |  PGP: 5B 47 34 9F 3B 9A B0 0D  AB A6 15 F1 BB BE 8C 44


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

Date: 13 Mar 1997 17:34:25 GMT
From: Casper.Dik@Holland.Sun.COM (Casper H.S. Dik - Network Security Engineer)
Subject: Re: Standard "Reaper" procedure doesn't work on Solaris.
Message-Id: <casper.858274639@uk-usenet.uk.sun.com>
Keywords: fork, reaper, ipc

gideon@csarc.otago.ac.nz (Gideon King) writes:

>Does anyone have any suggestions about how to solve this problem?


$SIG{'CHILD'} = 'IGNORE';

works fine on System V.


hasn't perl been fixed to use safe signals on platforms that support it?

Also, note that you can get only SIGCHLD for multiple child processes.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.


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

Date: Thu, 13 Mar 1997 14:32:26 -0800
From: "Michael J. South" <msouth@shodor.org>
Subject: suggestion for perltoot
Message-Id: <3328807A.41C6@shodor.org>

I'm trying to learn how to use the OOP stuff in perl5, using perltoot as
a start.  I typed in the Person.pm with the two-argument bless version
of new, and created the Employee.pm as suggested:

package Employee;
use Person;
@ISA = ("Person");
1;

And it works fine--I can do:

#!/usr/bin/perl
use Employee;

my $slave = Employee->new();


I then created a file called GDM.pm:

package GDM;
use GD;
@ISA = ("GD");
1;


and tried to use it in a program:

#!/usr/bin/perl
use GDM;

my $im = GDM::Image->new();

This give me the message that I am trying to call method "new" in an
empty package "GDM::Image".  I looked in perldiag, read perlref and
perlobj, but I"m not seeing the problem.  

If whatever I'm missing could be explained in a couple of lines in
perltoot, I think it would be helpful.  My understanding was that GDM
would "inherit" whatever GD had, and that this would imply that there
would be a GDM::Image with a new defined in it just like
GD::Image->new().

Thanks for all the work you all do to provide such a wonderful tool.
-- 
Michael J. South  (msouth@shodor.org)


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

Date: 13 Mar 1997 19:10:53 GMT
From: mfiresto@vnet.ibm.com (Mik Firestone)
Subject: Re: syntax correction
Message-Id: <5g9jft$hs8$1@mail.lexington.ibm.com>

In article <5g9bb7$2pd6@tiger3.ocs.lsu.edu>,
Subesh  Ghose <sghose@tiger.lsu.edu> wrote:
>  Can variables be resolved inside of a system command?
Sure.

>system ('wp2html v:\status\$datafile g:\htmldoc\wkreport\$datafile.htm');     
         ^                                                             ^
But these will cause you lots of problems.  Single quotes in Perl mean do
not resolve variables names.  Double quotes ( and back ticks for that
matter ) will.  I would suggest using double quotes in this line.
Actually, I would suggest dropping the system command and using back ticks,
but that is personal preference.

-----
Mik Firestone  mfiresto@mindspring.com
Evil Overlord Rule #35: If my supreme command center comes under attack,
I will immediately flee to safety in my prepared escape pod and direct
the defenses from there. I will not wait until the troops break into my
inner sanctum to attempt this.


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

Date: 13 Mar 1997 19:14:41 GMT
From: "Petri Bdckstrvm" <...petri.backstrom@icl.fi>
Subject: Re: syntax correction
Message-Id: <01bc2fe2$34e72850$665e40c1@ghoti>

Subesh  Ghose <sghose@tiger.lsu.edu> wrote in article
<5g9bb7$2pd6@tiger3.ocs.lsu.edu>...
>   Can variables be resolved inside of a system command?

But of course! In case you haven't done so already, please
take a look at the Perl documentation (perldata - Perl data
types, in particular):

  "String literals are usually delimited by either single or double 
  quotes. They work much like shell quotes: double-quoted string 
  literals are subject to backslash and variable substitution; 
  single-quoted strings are not (except for ``\''' and ``\\''). 
  The usual Unix backslash rules apply for making characters such 
  as newline, tab, etc., as well as some more exotic forms. See qq 
  for a list."

> Here is my line of code:
> 
> system ('wp2html v:\status\$datafile g:\htmldoc\wkreport\$datafile.htm');
    

Now, based on the above documentation excerpt, I'm sure you can tell
what's wrong with your code.


regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland



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

Date: Thu, 13 Mar 1997 14:00:42 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: syntax correction
Message-Id: <adm9g5.gq2.ln@localhost>

Subesh Ghose (sghose@tiger.lsu.edu) wrote:
:   Can variables be resolved inside of a system command?
                     ^^^^^^^^

interpolated


: Here is my line of code:

: system ('wp2html v:\status\$datafile g:\htmldoc\wkreport\$datafile.htm');     
:                            ^^^^^^^^^                     ^^^^^^^^^

: Any help is appreciated.


Asking the question once should be enough, don't you think?

(see the other time you asked this question for an answer)


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 13 Mar 1997 12:23:45 -0600
From: fox@convex.com (David DeSimone)
Subject: Re: Why are my rand() values so tiny?
Message-Id: <5g9gnh$cgd@mikey.convex.com>

In <Pine.HPP.3.91.970307114305.20328A-100000@ezinfo.ucs.indiana.edu> Jay Tomlin <ltomlin@ucs.indiana.edu> writes:

> Trying int(rand(10000000)) got me integers like 63 and 129. 

It sounds like perl was installed incorrectly, with an incorrect value
for the "number of bits in your rand() function".


-- 
David DeSimone      | "There is no reason for any individual to have a
fox@convex.hp.com   |  computer in their home." -- Ken Olson, President of
 If I said it, it   |         DEC, World Future Society Convention, 1977
 must be my opinion |  PGP: 5B 47 34 9F 3B 9A B0 0D  AB A6 15 F1 BB BE 8C 44


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

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

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