[13606] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1016 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 7 18:10:26 1999

Date: Thu, 7 Oct 1999 15:10:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <939334217-v9-i1016@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 7 Oct 1999     Volume: 9 Number: 1016

Today's topics:
        Previous Link <ICEMOUNTAIN@prodigy.net>
    Re: Question about alarm and run away processes <cassell@mail.cor.epa.gov>
    Re: Rapid Repeated Ftp <cassell@mail.cor.epa.gov>
    Re: running other programs from perl (James Stevenson)
    Re: set startup page <cassell@mail.cor.epa.gov>
    Re: STDERR output doesn't match $! <ilya@speakeasy.org>
    Re: Test if file contains certain text <cassell@mail.cor.epa.gov>
    Re: Test if file contains certain text <cassell@mail.cor.epa.gov>
    Re: tool to convert BMPs to GIFs programatically? (Abigail)
    Re: We do complex Perl Programming <kperrier@blkbox.com>
    Re: Wrong?  s/\n\n/#/g; <myriad@erols.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 7 Oct 1999 17:24:43 -0400
From: <ICEMOUNTAIN@prodigy.net>
Subject: Previous Link
Message-Id: <7tj36e$fkg$1@newssvr04-int.news.prodigy.com>

I posted this a couple of days ago and got a response and that person told
me that there were more people that responded, but there wasn't any on my
computer.
I want to put a previous link in my script, I have one but It's always on
there, even when there is nothing before it to see.
here is the part of the script that has the previous and next link.:

print <<"END";
<html>
<head>
<title>3rd Generation Camaros - Camaro Gallery - $FORM{'model'} </title>
<style type="text/css">
<!--
     A:link {color: blue;}
     A:hover {color: red;}
     A:visited {color: purple;}
     A:hover {color: red;}
-->
</style>

</head>

<body style="font-size : 11px;font-family : verdana, arial;">
 <h2 align=center style="font-size : 16px;font-family : verdana,
arial;">$FORM{'model'}</h2>
<center>
<table style="font-size : 11px;font-family : verdana, arial;">
END
;

%model = ("RS" => "rs",
    "Iroc-Z" => "iroc-z",
    "Z28" => "z28",
    "Berlinetta" => "berlinetta");

$max = 4;
$last = $FORM{'num'} + $max;
$next = $last + 1;
$prev = $FORM{'num'} - $max;

open(TEXT,"$model{$FORM{'model'}}.txt");
@info = <TEXT>;
close(TEXT);

if($last < $#info) {
 for($i=$FORM{'num'}; $i<=$last; $i++) {
  ($year,$model,$numb,$width,$lwidth,$lheight,$desc,$align) = split(/\|/,
@info[$i]); #/\|\|/
  print "<tr><td align=center>\n";
  print "<a
href=/gallerytest1.cgi?action=desc&model=$model&year=$year&numb=$numb><img
src=/gallery/$model{$FORM{'model'}}/images/$year$numb\small.jpg border=0
width=$width height=150 alt=\"Click for larger image and
description\"></a>\n";
  print "</td></tr><tr><td align=center><a
href=/gallerytest1.cgi?action=desc&model=$model&year=$year&numb=$numb>19$yea
r $FORM{'model'}</a></td></tr>\n";
 }
 print "</table><br><img src=\"/images/blank.jpg\" width=\"1\"
height=\"10\"><br>\n";
 if (($FORM{'num'} < $#info) && ($prev < $#info)) {
 print "<a
href=\"gallerytest1.cgi?action=$FORM{'action'}\&model=$FORM{'model'}\&num=$p
rev\">Previous</a>\&nbsp;\&nbsp;\&nbsp;\n";
 }
 if ($last < $#info) {
 print "<a
href=\"gallerytest1.cgi?action=find_model\&model=$FORM{'model'}\&num=$next\"
>Next</a>\n";
 }
}
else {
 for($i=$FORM{'num'}; $i<=$#info; $i++) {
  ($year,$model,$numb,$width,$lwidth,$lheight,$desc,$align) = split(/\|/,
@info[$i]);
  print "<tr><td align=center>\n";
  print "<a
href=/gallerytest1.cgi?action=desc&model=$model&year=$year&numb=$numb><img
src=/gallery/$model{$FORM{'model'}}/images/$year$numb\small.jpg border=0
width=$width height=150 alt=\"Click for larger image and
description\"></a>\n";
  print "</td></tr><tr><td align=center><a
href=/gallerytest1.cgi?action=desc&model=$model&year=$year&numb=$numb>19$yea
r $FORM{'model'}</a></td></tr>\n";
 }
 print "</table>\n";
 print "<p><a
href=\"gallerytest1.cgi?action=$FORM{'action'}\&model=$FORM{'model'}\&num=$p
rev\">Previous</a></p>\n";
}
print <<"END";
</center>
</body>
</html>
END
;

if your interested in what the script displays you can go here:
http://www.3gc.net/cgi-bin/scripts/backup/gallerytest1.cgi?action=find_model
&model=Iroc-Z

-----------------------------------------------------------------
http://www.3gc.net , 3rd Generation Camaros
-----------------------------------------------------------------




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

Date: Thu, 07 Oct 1999 15:01:19 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Question about alarm and run away processes
Message-Id: <37FD182F.76DFB542@mail.cor.epa.gov>

Ilya wrote:
> In comp.lang.perl.misc M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
[snip]
> > Start with the FAQ entry, which I found in seconds with
> > 'perldoc -q timeout':
> 
> > perlfaq8:  How do I timeout a slow event?
> 
> =head2 How do I timeout a slow event?
> 
> Use the alarm() function, probably in conjunction with a signal
> handler, as documented L<perlipc/"Signals"> and chapter 6 of the
> Camel.  You may instead use the more flexible Sys::AlarmCall module
> available from CPAN.
> 
> Not very descriptive, is it?

It seems descriptive *enough* though.

It doesn't match what I see.  I get:

  Use the alarm() function, probably in conjunction with a
  signal handler, as documented the section on "Signals"
  in the perlipc manpage and chapter 6 of the Camel. You
  may instead use the more flexible Sys::AlarmCall module
  available from CPAN.

Which is more helpful, I think.  What version of Perl 
are you running?

More to the point, it says to go read the perlipc pages.
So do that.  Type:

perldoc perlipc

And pay special attention to the section on "Signals".
Just as the text says.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 07 Oct 1999 14:47:53 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Rapid Repeated Ftp
Message-Id: <37FD1509.E6CCFC9F@mail.cor.epa.gov>

Abigail wrote:
> 
> Kristjan Varnik (kav200@omicron.acf.nyu.edu) wrote on MMCCXXVI September
> MCMXCIII in <URL:news:66uK3.30$Gm4.3173@typhoon.nyu.edu>:
> &&
> && Lastly, I am a bit new to perl.. are their any flags
> && I can use to make my perl programs run faster.
> 
> Yeah. There are 9 flags, -1 to -9. With -1, Perl runs the fastest,
> but sloppy. It'll make mistakes. With -9, Perl won't make mistakes,
> but it's slow.
> 
> The default, -5, is kind of a middle ground. Slow and sloppy.

That's only on old Perls.  Newer versions use the letters
'a' through 'i' instead of 1 to 9.  I use the -e flag a lot
for one-line programs.

To the original poster:

Some programs use more than one of these flags, so you'll
want to carefully read the 'perlrun' pages to find out just
what they do and how to use them.  Type:

perldoc perlrun

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 7 Oct 1999 17:51:04 +0000
From: James@linux.home (James Stevenson)
Subject: Re: running other programs from perl
Message-Id: <slrn7vpnc8.h55.James@linux.home>

Hi

yea i finally managed to do it if anyone wants to see how i did it it is
on my web site
its forks the program the executes
every second it will print the number of programs still running as well

cya
	James

On Sat, 02 Oct 1999 18:48:54 GMT, Kragen Sitaker <kragen@dnaco.net> wrote:
>In article <slrn7v023f.nkm.James@linux.home>,
>James Stevenson <mistral@stevenson.zetnet.co.uk> wrote:
>>ahh sorry i did not see the &
>>but how do i know when the program exits?
>
>If you want to know that, I think you have to explicitly fork(),
>exec(), and wait() or waitpid().
>-- 
><kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
>Fri Oct 01 1999
>39 days until the Internet stock bubble bursts on Monday, 1999-11-08.
><URL:http://www.pobox.com/~kragen/bubble.html>


-- 
---------------------------------------------
Check Out: http://www.users.zetnet.co.uk/james/
E-Mail: mistral@stevenson.zetnet.co.uk
  5:50pm  up 2 days,  3:46,  3 users,  load average: 0.25, 0.16, 0.10


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

Date: Thu, 07 Oct 1999 15:04:22 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: set startup page
Message-Id: <37FD18E6.7B092625@mail.cor.epa.gov>

a1234_ec@yahoo.com wrote:
> 
> Is it possible to write a perl script to automatically set a browser's
> startup page?

No, it is not.  Perl works on the server side, not the client
side.  You would have to do this via something like JavaScript.

But why would you *want* to?  If you're doing this for a company,
then surely you have a system so that everyone uses the proper
browsers for your intranet, so you can distribute the browser
with this already set.

If you're doing this to the unwary, then I'm glad I have
JavaScript turned off in all my JavaScript-capable browsers.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 07 Oct 1999 21:47:31 GMT
From: Ilya <ilya@speakeasy.org>
Subject: Re: STDERR output doesn't match $!
Message-Id: <rvq57jtfd6e60@corp.supernews.com>

Natalya Barner <nbarner@uswest.com> wrote:
> I'm trying to write some code which will output the OS error message if
> a system call fails.
> The problem I'm having is that the message going to STDERR is not the
> same message that's getting stored in $!.

> Here's the code:
>     #!/usr/local/bin/perl
>     $rc = system("mkdir mydir");
>     if ($rc)
>     {
>         print "couldn't do it: $!\n";
>     }

> And here's the output:
>     mkdir: cannot create mydir: File exists
>     couldn't do it: No such file or directory

> Any help greatly appreciated.

      Could you possibly redirect the standard error:

      $result=`command 2>&1`;
      print ("$result\n");

      That's how I used it with other commands, don't know about mkdir
      specifically.





	==============================================================
	Paper money eventually returns to its intrinsic value -- zero.
                 				  -Voltaire
	==============================================================


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

Date: Thu, 07 Oct 1999 14:38:19 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Test if file contains certain text
Message-Id: <37FD12CB.2AE53730@mail.cor.epa.gov>

tomschenk@my-deja.com wrote:
> 
> Hi-
> 
> I know this is probably easy, and yes, I have searched to find the
> answer, but can't.

Well, always start with the FAQ.  If you have Perl on your
machine, you have the FAQ too.  It comes with the install.
You can search it for keywords with the perldoc program.

> So--I am trying to write a script which accepts form input from a web
> page, then checks a text file to see if that text is already in that
> file. If it isn't, I want to add it to the end of the file.  I already
> know how to process the form, open the file, and write to the file, I
> just can't figure out how to see if the text is already there.  The
> text file is just a list of words--that's all, one per line.  Can
> someone help??? Thanks!

Try typing this at a command prompt:

perldoc -q contains
perldoc -q intersection

You'll get the answers from the FAQ for two relevant
questions.. along with code to solve your problem (after
you make minor mods, of course).

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 07 Oct 1999 14:41:12 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Test if file contains certain text
Message-Id: <37FD1378.DB28622D@mail.cor.epa.gov>

Alexandre Amelin wrote:
> 
> The solution is to make a grep on your file. Lioke this :
[massive snip]

No.  That is not the answer.  A better answer is in the Perl
FAQ, and as such is what should be recommended to beginners
[unless you are Abigail].  But thanks for trying.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 7 Oct 1999 15:14:55 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: tool to convert BMPs to GIFs programatically?
Message-Id: <slrn7vq0bs.1fk.abigail@alexandra.delanet.com>

Alan J. Flavell (flavell@mail.cern.ch) wrote on MMCCXXVIII September
MCMXCIII in <URL:news:Pine.HPP.3.95a.991007174943.22932A-100000@hpplus01.cern.ch>:
;; On Thu, 7 Oct 1999, J. A. Mc. wrote:
;; 
;; > On 7 Oct 1999 04:05:01 -0500, abigail@delanet.com (Abigail) wrote:
;; > 
;; > >Scott McMahan (scott@aravis.softbase.com) wrote on MMCCXXVI September
;; > >MCMXCIII in <URL:news:EDpK3.1178$H32.71815@newshog.newsread.com>:
;; > >__ 
;; > >__ But GIFs are patent-protected, or something, and require a license
;; > >__ from whoever has the legal rights to them, aren't they? Can you
;; > >__ make freeware that supports GIFs without having to pay
;; > >__ for the rights to them?
;; > >
;; > >Yes.  But you cannot make everything.
;; 
;; > Wanna bet? <G>
;; 
;; I can't help suspecting that there has been a failure of information
;; transfer here.  I interpreted Abigail's comment as referring back the 
;; earlier point made, that there is nothing preventing you from creating
;; GIF format, since the patent claims refer to a specific compression
;; algorithm, and you don't have to use that algorithm.  (I'm sure Abigail
;; will be quick to correct me if I misinterpreted the message ;-)


No, I was referring to the fact that Unisys only wants money if you use
their compression technique to create images. Viewers are royalty free.
I don't know what their POV is on translators. And of course, there's no
royalty to pay on free compression techniques. So, you can make freeware
that supports GIFs, but you cannot do everything.




Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 07 Oct 1999 16:43:49 -0500
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: We do complex Perl Programming
Message-Id: <A258F5FA3F4270AA.F2565AFDE4A47FF6.CEAB317E051C458B@lp.airnews.net>

> sehgal@del2.vsnl.net.in (Sahil) wrote in <7th2f6$n1u$1@news.vsnl.net.in>:
> >Hi,
> >We are an E-commerce based company and do any type of complex Perl

You're E-commerce based?  What city is that?  I've never heard of it.
Is it in the USA?

Kent
-- 
"I will tell you the secret of getting rich on Wall Street... You try 
to be greedy when others are fearful, and you try to be very fearful 
when others are greedy." 
						-- Warren Buffett


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

Date: Thu, 7 Oct 1999 17:17:58 -0400
From: "Myriad" <myriad@erols.com>
Subject: Re: Wrong?  s/\n\n/#/g;
Message-Id: <7tj2jt$h9d$1@autumn.news.rcn.net>

Eric, Seth:

You two are awesome for knowing that.  I can't thank you enough.  Perl
always fries my brain.  I have a love-hate with it that's turning more to
love.  But I have a problem -- after working with other languages and then
returning to Perl after some time, I'm like a deer in headlights all over
again.

Thanks a million for your help.

Tom


Myriad wrote in message <7tinos$omn$1@autumn.news.rcn.net>...
>perl -pe s/\n\n/#/g; somedoc.txt
>
>Can someone tell me why this won't work to remove replace double hard
>returns in a text file?  Can't figure it out.   Thought maybe it was
because
>\n needed to be used in conjunction with \r, but that didn't work either.
>
>Thanks!
>
>
>




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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 1016
**************************************


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