[18628] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 796 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 29 21:07:39 2001

Date: Sun, 29 Apr 2001 18:05:08 -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: <988592708-v10-i796@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 29 Apr 2001     Volume: 10 Number: 796

Today's topics:
        Advice req. on Timing Out STDIN (Shawn Smith)
    Re: Advice req. on Timing Out STDIN (Garry Williams)
    Re: building Perl 5.6.0 with a custom @INC <ceverett@ceverett.com>
    Re: counter (Garry Williams)
    Re: cr's in input text fields screwing up the database  <xris@dont.send.spam>
    Re: dynamic creation of classes? <gellyfish@gellyfish.com>
        error in XML::DOM <perl@imchat.com>
    Re: error in XML::DOM (Tad McClellan)
        Help <hafateltec@hotmail.com>
    Re: How to down size /usr/bin/perl ? (Logan Shaw)
    Re: How to write a multi process program with perl ? <gtoomey@usa.net>
    Re: Jeopardy (was Re: First and last element in list lo <bowman@montana.com>
    Re: libgdm NOT! (Garry Williams)
        Perl and "exec" <lxq79@REMOVE.CAPITALS.hotmail.com>
    Re: Point of using perlcc (Rudolf Polzer)
    Re: pointer/reference question (Garry Williams)
    Re: pretty-printing perl? <theaney@toadmail.toad.net>
    Re: pretty-printing perl? (Tad McClellan)
    Re: re-sizing GIF images on the fly <graham@letsgouk.com>
    Re: re-sizing GIF images on the fly <graham@letsgouk.com>
    Re: re-sizing GIF images on the fly <graham@letsgouk.com>
    Re: re-sizing GIF images on the fly (Randal L. Schwartz)
    Re: re-sizing GIF images on the fly (Charles M. Kozierok)
    Re: re-sizing GIF images on the fly (Eric Bohlman)
        Removing Lines... how's this? (BUCK NAKED1)
    Re: Removing Lines... how's this? (Garry Williams)
    Re: Removing Lines... how's this? <bart.lateur@skynet.be>
    Re: Removing Lines... how's this? <uri@sysarch.com>
    Re: Should Perl be first? <comdog@panix.com>
    Re: Should Perl be first? (Rudolf Polzer)
    Re: Should Perl be first? (Gwyn Judd)
    Re: Should Perl be first? <bchambless@nrlssc.navy.mil>
    Re: Should Perl be first? <bchambless@nrlssc.navy.mil>
    Re: XML::RSS and mod_perl <m2@csu.edu.au>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 29 Apr 2001 20:53:56 GMT
From: SPAMloginprompt@yahoo.com (Shawn Smith)
Subject: Advice req. on Timing Out STDIN
Message-Id: <3aec7cab.5098242@netnews.worldnet.att.net>

Hello all.

I have been programming in Perl for about 5 months, right of of
school. I am maintaing existing code.

I have this snippet in a daemon. It checks if the user types "quit" to
stop the script. I have been asked to add the check for the existance
of a file named "quit".

  ###################################

while (1) {
    eval {
        local $SIG{ALRM} = sub {$alarm = 1};
        alarm 300;
        $cmd = <stdin>;
        alarm 0;
    };
    if ($alarm) {
        $alarm = 0;
    }

  # check other condtions, such as existance of a file
} # end while loop
 ####################################

Problem is it never seems to time out at 300 seconds. It just sits
there waiting for STDIN. What I have done is (I forgot my code at work
so this is from memory):

 ####################################
while (1) {
 # used flag to fork just once
  if ($mypid = fork) {
    exec $cmd = <stdin>;
  }
# check other stuff

} # end while loop
 ####################################

This seems to work ok except I don't like that I now see two instances
of the script via unix ps command. 

Any tips on how to best time out a read from STDIN? 

TIA,


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

Date: Sun, 29 Apr 2001 22:41:30 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Advice req. on Timing Out STDIN
Message-Id: <slrn9ep64q.bv7.garry@zfw.zvolve.net>

On Sun, 29 Apr 2001 20:53:56 GMT, Shawn Smith
<SPAMloginprompt@yahoo.com> wrote:

> I have this snippet in a daemon. It checks if the user types "quit" to
> stop the script. I have been asked to add the check for the existance
> of a file named "quit".
> 
>   ###################################
> 
> while (1) {
>     eval {
>         local $SIG{ALRM} = sub {$alarm = 1};
>         alarm 300;
>         $cmd = <stdin>;
>         alarm 0;
>     };
>     if ($alarm) {
>         $alarm = 0;
>     }
> 
>   # check other condtions, such as existance of a file
> } # end while loop
>  ####################################

I don't see how this `checks if the user types "quit"', but your time
out problem is solved by using the method recommended in the perlipc
manual page: 

         eval {
             local $SIG{ALRM} = sub { die "alarm clock restart" };
             alarm 300;
             $cmd = <stdin>;	# File handles should be all uppercase
             alarm 0;
         };
         if ($@ and $@ !~ /alarm clock restart/) {
             ...

> Problem is it never seems to time out at 300 seconds. It just sits
> there waiting for STDIN. What I have done is (I forgot my code at work
> so this is from memory):
> 
>  ####################################
> while (1) {
>  # used flag to fork just once
>   if ($mypid = fork) {
>     exec $cmd = <stdin>;

This probably fails, if you left the new line character on the read
from stdin.  Also, it might be a good idea to check the input for
(malicious) mistakes.  (See perlrun for the -T option and read the
perlsec manual page.)  

-- 
Garry Williams


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

Date: Sun, 29 Apr 2001 16:15:04 -0500
From: "Christopher L. Everett" <ceverett@ceverett.com>
Subject: Re: building Perl 5.6.0 with a custom @INC
Message-Id: <3AEC8458.6A9E2BF@ceverett.com>

Andy Dougherty wrote:
> 
> In article <3AE91562.BAFF13E1@ceverett.com>, Christopher L. Everett wrote:
> >How?  It works with 5.6.1 where ./Configure asks
> >if I want to have any other directories added to
> >the @INC, but the ./Configure for 5.6.0 doesn't
> >ask the question.  I tried to edit the config.sh
> >to add a line "otherlibdirs=/usr/share/perl5"
> >but it doesn't get added to @INC, despite what it
> >says in the INSTALL file.
> 
> Correct.  That's a bug in 5.6.0 that should be fixed in 5.6.1.  If you
> want to back-port the fix to 5.6.0, you need to copy the otherlibdirs
> stuff from 5.6.1's config_h.SH and perl.c and paste them into the
> 5.6.0 versions of those files.  Then go and add your otherlibdirs line
> to config.sh, run sh Configure -S; make depend; make.  It should
> work then.
> 

Gack! I was afraid of that ... no time ... stuck
PERL5LIB=/usr/share/perl5 
into /etc/profile instead - seems to work for what I need it to do. Wish
I 
could just run 5.6.1 though.

Thank you very much for your kind & quick assistance.

  --Christopher


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

Date: Sun, 29 Apr 2001 21:43:45 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: counter
Message-Id: <slrn9ep2oh.bv7.garry@zfw.zvolve.net>

On Tue, 24 Apr 2001 17:24:50 +0200, Kris van der Mast
<kris.v@net2view.be> wrote:

> Currently I'm searching for just a normal website counter that keeps every
> "hit" on the fist page in a text file.

> If anyone knows where I can find such scripts, please let me know.

Look on your own hard drive.  The last paragraph of the "Other I/O
Issues" section of the perlopentut manual page gives an example.  

-- 
Garry Williams


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

Date: Sun, 29 Apr 2001 13:31:52 -0500
From: xris <xris@dont.send.spam>
Subject: Re: cr's in input text fields screwing up the database (not text area)
Message-Id: <xris-1EC137.13314729042001@news.evergo.net>

In article <leunetcklsuetb0jidlrupfsn7m52212ct@4ax.com>,
 Bart Lateur <bart.lateur@skynet.be> wrote:

> n.b. A textarea produces both CR (13) and LF (10). You usually want to
> get rid of every "\r" anyway.

I've found that some weird browsers only transmit \r in textareas (and 
presumably also in TEXT fields if text was pasted in containing 
newlines).  Thus, it's good to delete the \r in \r\n pairs, but also 
check for single \r characters after this and convert them to \n.

-Chris



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

Date: 29 Apr 2001 18:40:51 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: dynamic creation of classes?
Message-Id: <9chn7j$1os$1@neptunium.btinternet.com>

nobull@mail.com wrote:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> 
>> According to  <nobull@mail.com>:
>> > anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
>> > 
>> > >     $class =~ s!::!/!g;  $class .= '.pm';
>> > >     require $class;
>> > 
>> > I used to recommend this myself, but then I head of .pmc files.
>> 
>> What are those?
> 
> Dunno, something I saw one day when I was 'strace'ing a Perl program.
> 
> At a wild guess I'd say byte-code precompiled modules.
> 

Infact if you look at the B::Bytecode manpage there is an implicit
indication of this :

              perl -MO=Bytecode,-m,-oFoo.pmc Foo.pm

/J\
-- 
Jonathan Stowe                      |
<http://www.gellyfish.com>          |      This space for rent
                                    |


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

Date: Sun, 29 Apr 2001 13:31:14 -0500
From: mark <perl@imchat.com>
Subject: error in XML::DOM
Message-Id: <3AEC5DF2.74C19621@imchat.com>

Normally this error which I have known about for some time doesn't cause
any problems, however, now it's preventing my daemon from running.

unrecognized escape \d passed through at /blah/XML::DOM.pm line 136.

$ReCharRef = "(?:\&#(?:\d+|x[0-9a-fA-F]+);)";

Can I change this to something that doesn't cause an error?





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

Date: Sun, 29 Apr 2001 16:20:11 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: error in XML::DOM
Message-Id: <slrn9eotrr.did.tadmc@tadmc26.august.net>

mark <perl@imchat.com> wrote:

>Normally this error 


It is not an "error". It is not an "error message" even.

It is a "warning message".

(though the warning _does_ point to a bug in the DOM.pm code...)


>which I have known about for some time doesn't cause
>any problems, 


"Errors" are fatal. If it had been an error, you would be 
experiencing "problems"  :-)

But it sure does seem that the bug uncovered by the warning
ought to cause problems...


>however, now it's preventing my daemon from running.
>
>unrecognized escape \d passed through at /blah/XML::DOM.pm line 136.
>
>$ReCharRef = "(?:\&#(?:\d+|x[0-9a-fA-F]+);)";
>
>Can I change this to something that doesn't cause an error?


You can change it to something that does not cause the *warning message*,
sure. But it is much more important to fix the real bug that the
warning is clueing you in to:

   $_ = "(?:\&#(?:\d+|x[0-9a-fA-F]+);)";
   print "$_\n";

Unrecognized escape \d passed through at ./temp line 4.
(?:&#(?:d+|x[0-9a-fA-F]+);)
       ^^^
       ^^^ the module author is not getting the pattern 
           he thought he was getting...


So, let's use single quotes, because they don't recognize
backslash escapes:

   $_ = '(?:\&#(?:\d+|x[0-9a-fA-F]+);)';
   print "$_\n";

(?:\&#(?:\d+|x[0-9a-fA-F]+);)
   ^
   ^ don't need that:


   $_ = '(?:&#(?:\d+|x[0-9a-fA-F]+);)';
   print "$_\n";

(?:&#(?:\d+|x[0-9a-fA-F]+);)


Looks like that might do it.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 30 Apr 2001 07:49:28 +1000
From: "Michael R. McPherson" <hafateltec@hotmail.com>
Subject: Help
Message-Id: <9ci2ik0u42@enews1.newsguy.com>

I know this is a bit off topic but I really am lost on this.  I am trying to
install DBD::ODBC yet I always fail with this error below when I try to run
tests.
I am using OpenLink with iodbc which I ran the odbctest on and it passes so
I know that I have my OpenLink installed.  I also looked in the MS access
database which I use as my DSN for testing the DBD::ODBC before I install it
and it has the data from the test in it.  I have
ODBCHOME=/home/mydir/openlink, DBI_PASS, DBI_USER,DBI_DSN=dbi:ODBC:demo all
in my environment before I run perl Makefile.PL.  Somebody out there has to
have had this problem before so could you PLEASE help me out and let me know
what you did to get this installed and WORK correctly.

ps. feel free to e-mail directly if this is to off topic

Thanks




PERL_DL_NONLAZY=1
/usr/local/bin/perl -Iblib/arch -Iblib/lib -I/usr/local/lib/pe
rl5/5.6.1/i686-linux -I/usr/local/lib/perl5/5.6.1 -e 'use Test::Harness
qw(&runt
ests $verbose); $verbose=0; runtests @ARGV;' t/*.t
t/01base............ok
t/02simple..........dubious
        Test returned status 0 (wstat 11, 0xb)
DIED. FAILED tests 13-14
        Failed 2/14 tests, 85.71% okay
t/03dbatt...........ok
t/05meth............ok
t/09bind............ok
Failed Test  Status Wstat Total Fail  Failed  List of Failed
----------------------------------------------------------------------------
----
t/02simple.t       0    11    14    2  14.29%  13-14
Failed 1/5 test scripts, 80.00% okay. 2/40 subtests failed, 95.00% okay.
make: *** [test_dynamic] Error 29




--
##############Þ
print "\n Welcome to NEPP";$Þ=1;while ($Þ){
print "\n$Þ";$Þ++;if ($Þ == 1000) {
print "\n$Þ"."\nWell almost never ending :þ";exit;}}
##############Þ






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

Date: 29 Apr 2001 15:21:39 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: How to down size /usr/bin/perl ?
Message-Id: <9cht4j$1p4$1@charity.cs.utexas.edu>

In article <3aec3ea0.6341$384@news.op.net>,
Mark Jason Dominus <mjd@plover.com> wrote:
>
>In article <9ccr0o$nog$1@daggoo.cs.utexas.edu>,
>Logan Shaw <logan@cs.utexas.edu> wrote:
>>First, you've got to decide whether the C/C++/Perl/Java family of
>>syntaxes is wonderful and the Algol/Pascal/Modula-2/Ada family is evil,
>
>Your notion of programming language syntax seems impoverished.
>C, C++, Perl, and Java *are* in the Algol family of syntax.
>
>For counterexamples, see Prolog, Common Lisp, Cobol, Fortran, and Haskell.

I have used Prolog, Lisp, and Haskell, and I realize they're different,
though it's not the syntax itself that's the chief difference.
(Actually my comment about making the notation look as much like some
other notation as possible was a jab at Haskell, which IMHO makes the
syntax unnecessarily confusing by trying to make it look like
mathematical notation.)

Still, I think most people these days choose to either copy C's or
Pascal's syntax.  I agree that the two don't work that much
differently, but most people designing a new language aren't going to
make it a functional or logic language anyway.

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: Mon, 30 Apr 2001 09:57:14 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: How to write a multi process program with perl ?
Message-Id: <7G1H6.14150$482.73923@newsfeeds.bigpond.com>

"dekuo" <dekuo@hello.com.tw> wrote in message
news:9cg4qa$lne$1@news.ethome.net.tw...
> How to use fork() system function to fork multi child process at the same
time ?
 ...
> Run a program to fork 5 child process at the same time and the parent must
wait
> until all child exit.
 ...

If you've only got 1 CPU, five processes many not run faster than 1
process - there is only 1 running process at any instant.

gtoomey




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

Date: Sun, 29 Apr 2001 18:40:29 -0600
From: "bowman" <bowman@montana.com>
Subject: Re: Jeopardy (was Re: First and last element in list loop)
Message-Id: <Yt2H6.2291$st.15469@newsfeed.slurp.net>


"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m3itjnlmdl.fsf_-_@mumonkan.sunstarsys.com...
>
>   2) placing the new text at the top saves people the
>      trouble of rereading old material.

A long time ago (when Delphi was alive and well), a poster in one of the
groups was blind, and used a text to speech program. He requested people
replying to his posts to put the answer first as he was tired of listening
to his questions. I'd assume the text to speech proggies have gotten smarter
since then and can skip '>' lines. Good argument, though, for not using
one's private little quoted material demarkers.




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

Date: Sun, 29 Apr 2001 22:01:24 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: libgdm NOT!
Message-Id: <slrn9ep3pk.bv7.garry@zfw.zvolve.net>

On Thu, 26 Apr 2001 15:41:51 -0000, Andy Dougherty
<doughera@maxwell.phys.lafayette.edu> wrote:

> In article <3ae76a5b.0@news2.lightlink.com>, Homer Wilson Smith wrote:
>>     Running Linxu 2.0.38 and perl 5.00x
>>
>>     How do I compile perl to NOT include libgdbm.so but only
>>libdb.so?
> 
> Try reading the INSTALL document that comes with the perl source kit,
> especially the section  =head2 Extensions.
> 
>>     Alternately how do I tell perl to use libdb.so with the dbopen()
>>statement, it seems to insist on using libgdbm which is incompatible
>>with the file I wish to read.
> 
> Try reading the dbmopen() section of perlfuc.pod, especially the
> section starting "You can control which DBM library you use ..."

Check out the first line of the dbmopen() section, too: 

  "[This function has been largely superseded by the `tie' function.]"

-- 
Garry Williams


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

Date: Mon, 30 Apr 2001 03:17:48 +0900
From: LXQ <lxq79@REMOVE.CAPITALS.hotmail.com>
Subject: Perl and "exec"
Message-Id: <20010430031748.60d540b1.lxq79@REMOVE.CAPITALS.hotmail.com>

Hi,

I tried to execute sudo command from CGI using Perl. I wrote a simple
script like this:
 
exec "sudo /etc/rc.d/init.d/httpd restart";

But the problem is sudo will not run the command directly, it will display
a password prompt first. How can I send the password to the shell after I
send the exec? I know maybe I can't use exec, as it would exit as soon as
it sent the command to the shell. Please help. Thanks very much.

-LXQ-



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

Date: Sun, 29 Apr 2001 20:26:01 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: Re: Point of using perlcc
Message-Id: <slrn9eon5p.4r6.eins@www42.t-offline.de>

flash <bop@mypad.com> wrote:
> I was just wondering the point of using perlcc?
> I know it compiles the program (no one can steal the source)
> 
> But it makes the file like 680 times larger!
> 
> Does anyone use perlcc here?
> For what purpose?

If there is a Windoze version of perlcc, it _is_ useful. You can 
compile the program so the user does not have to install perl when you 
can statically link to perl.

-- 
#!/usr/bin/perl -W -- WARNING: This will print 22,307 bytes! <strictsafe!>
use strict;for(my$y=-1;$y<1;$y+=.1){for(my$x=-1.9;$x<.4;$x+=.03){print'+';
my$X=my$Y=0;for(0..99){($X,$Y)=($X*$X-$Y*$Y+$x,2*$X*$Y+$y);print"\b "if$X*
$X+$Y*$Y>9;}}print"\n"};print''.reverse"\nHPAJ \a!rezloP .R yb torblednaM"


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

Date: Sun, 29 Apr 2001 22:13:48 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: pointer/reference question
Message-Id: <slrn9ep4gs.bv7.garry@zfw.zvolve.net>

On Sat, 21 Apr 2001 23:11:46 -0500, xris <xris@dont.send.spam> wrote:

> In article <9btbef$e2r$1@mamenchi.zrz.TU-Berlin.DE>,
>  anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:

[snip]

>> If de-referencing becomes a pain it is often a sign of an unfortunate
>> data structure design and/or subroutine layout.  Sometimes a simple
>> measure like passing a hashref instead of many parameters is all it
>> takes.  Sometimes a deeper redesign is indicated.  Using an aliasing
>> mechanism would only cure the symptom, not the disease.
> 
> It's not a matter of passing in a lot of variables to a routine, just 
> accessing the one or two variables I do pass in a bunch of times.  My 
> main concern is that I'll forget the extra $ to dereference something 
> and it'll cost me hours of bug testing to find the typo.  :)

  use warnings;
  use strict;

Program without fear.  

-- 
Garry Williams


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

Date: 29 Apr 2001 14:17:15 -0400
From: Tim Heaney <theaney@toadmail.toad.net>
Subject: Re: pretty-printing perl?
Message-Id: <87vgnn3710.fsf@susie.watterson>

"ivo welch" <nospam@yale.edu> writes:
>
> Is there a pretty-printer for perl?  (Preferably, one that also takes pod
> into account.)

You might be interested in Perltidy

  http://perltidy.sourceforge.net/

Hope this helps,

Tim


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

Date: Sun, 29 Apr 2001 15:55:35 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: pretty-printing perl?
Message-Id: <slrn9eosdn.dfk.tadmc@tadmc26.august.net>

ivo welch <nospam@yale.edu> wrote:
>
>Is there a pretty-printer for perl? 


Is there a Perl FAQ? 

Yes.

Are you expected to check the Perl FAQ before posting to the
Perl newsgroup? 

Yes.

Please try that first in the future:

   perldoc -q pretty-printer

      "Is there a pretty-printer (formatter) for Perl?"


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 29 Apr 2001 23:13:25 +0100
From: Graham Stow <graham@letsgouk.com>
Subject: Re: re-sizing GIF images on the fly
Message-Id: <U3lTMIAFIJ76EwYX@letsgouk.com>

>I am confused. The GIF format is not a trivial one to work with,
>certainly not so trivial that you can claim that 'a simple script' can
>be written to resize it, once you know the new size. However, what is
>simple, is to parse the first few bytes of a GIF file to determine what
>its intended size is.
>
>So, either you know a lot about the image format (which is implied,
>since you can write a simple script to resize the image), or you know
>nothing, (which is implied because you don't seem to know how to get the
>size of the image from the file).
>
>Which is it?
>
>Martien

I know nothing!

Sorry - I have used the word resizing incorrectly. I have folk beaming
up GIF files to my website and these are all different sizes. To create
thumbnails of them on the fly, I therefore need to establish their size
in order to render the thumbnail with the correct aspect ratio - this is
not the same thing as resizing and I apologise for the confusion.

My simple script is as follows..

use Image::Size;
($x, $y) = imgsize ("$imagefile");
$standardheight=80;     # all thumbnails to be rendered 80 pixels high
$height=$standardheight;
$width=$standardheight*($x/$y);
print "<IMG SRC=\"$imagefile\" WIDTH=\"$width\" HEIGHT=\"$height\"
HSPACE=10 BORDER=0 ALIGN=\"RIGHT\" ALT=\"Thumb\">\n";

Graham
-- 
Graham Stow


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

Date: Sun, 29 Apr 2001 23:24:32 +0100
From: Graham Stow <graham@letsgouk.com>
Subject: Re: re-sizing GIF images on the fly
Message-Id: <Jn8UYWAgSJ76Ewa3@letsgouk.com>

>Then why do you need to use Image::Size ?  If you know enough about the
>format of your image files to be able to do the resizing why would you
>need to use a module ?  Ah you mean *dumbnails* not thumbnails dont you ?
>Specify the smaller size of the image in HTML. Complete waste of time in
>my opinion.  But hey its your website.
>
>/J\

I have folk beaming up GIF files to my website and these are all
different sizes. Image::Size tells me their size and I can then maintain
the correct aspect ratio when rendering a thumbnail. Here's the script..

Use Image::Size;
($x, $y) = ("");
$standardheight=80;     # all thumbnails to be rendered 80 pixels high
$height=$standardheight;
$width=$standardheight*($x/$y);
print "<IMG SRC=\"$imagefile\" WIDTH=\"$width\" HEIGHT=\"$height\"
HSPACE=10 BORDER=0 ALIGN=\"RIGHT\" ALT=\"Thumb\">\n";

Now what's dumb about that?
-- 
Graham Stow


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

Date: Sun, 29 Apr 2001 23:40:37 +0100
From: Graham Stow <graham@letsgouk.com>
Subject: Re: re-sizing GIF images on the fly
Message-Id: <939ZMKAlhJ76Ew9L@letsgouk.com>

> Here's the script..
>
>Use Image::Size;
>($x, $y) = ("");
>$standardheight=80;     # all thumbnails to be rendered 80 pixels high
>$height=$standardheight;
>$width=$standardheight*($x/$y);
>print "<IMG SRC=\"$imagefile\" WIDTH=\"$width\" HEIGHT=\"$height\"
>HSPACE=10 BORDER=0 ALIGN=\"RIGHT\" ALT=\"Thumb\">\n";
>
>Now what's dumb about that?

What's dumb about it is that I can't even copy and paste properly!
Should have read as follows...

use Image::Size;
($x, $y) = imgsize ("$imagefile");
$standardheight=80;     # all thumbnails to be rendered 80 pixels high
$height=$standardheight;
$width=$standardheight*($x/$y);
print "<IMG SRC=\"$imagefile\" WIDTH=\"$width\" HEIGHT=\"$height\"
HSPACE=10 BORDER=0 ALIGN=\"RIGHT\" ALT=\"Thumb\">\n";
-- 
Graham Stow


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

Date: 29 Apr 2001 15:53:49 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: re-sizing GIF images on the fly
Message-Id: <m1n18zgvwi.fsf@halfdome.holdit.com>

>>>>> "Graham" == Graham Stow <graham@letsgouk.com> writes:

Graham> Sorry - I have used the word resizing incorrectly. I have folk beaming
Graham> up GIF files to my website and these are all different sizes. To create
Graham> thumbnails of them on the fly, I therefore need to establish their size
Graham> in order to render the thumbnail with the correct aspect ratio - this is
Graham> not the same thing as resizing and I apologise for the confusion.

Graham> My simple script is as follows..

Graham> use Image::Size;
Graham> ($x, $y) = imgsize ("$imagefile");
Graham> $standardheight=80;     # all thumbnails to be rendered 80 pixels high
Graham> $height=$standardheight;
Graham> $width=$standardheight*($x/$y);
Graham> print "<IMG SRC=\"$imagefile\" WIDTH=\"$width\" HEIGHT=\"$height\"
Graham> HSPACE=10 BORDER=0 ALIGN=\"RIGHT\" ALT=\"Thumb\">\n";

That's not a thumbnail.  That's a "dumbnail".  Please don't do that.

        <http://www.stonehenge.com/merlyn/WebTechniques/col29.html>

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sun, 29 Apr 2001 23:05:20 GMT
From: ixlu@PCGuide.com (Charles M. Kozierok)
Subject: Re: re-sizing GIF images on the fly
Message-Id: <Q61H6.809$Be3.85134@news.shore.net>

In article <U3lTMIAFIJ76EwYX@letsgouk.com>,
Graham Stow  <graham@letsgouk.com> wrote:
} Sorry - I have used the word resizing incorrectly. I have folk beaming
} up GIF files to my website and these are all different sizes. To create
} thumbnails of them on the fly, I therefore need to establish their size
} in order to render the thumbnail with the correct aspect ratio - this is
} not the same thing as resizing and I apologise for the confusion.
} 
} My simple script is as follows..
} 
} use Image::Size;
} ($x, $y) = imgsize ("$imagefile");
} $standardheight=80;     # all thumbnails to be rendered 80 pixels high
} $height=$standardheight;
} $width=$standardheight*($x/$y);
} print "<IMG SRC=\"$imagefile\" WIDTH=\"$width\" HEIGHT=\"$height\"
} HSPACE=10 BORDER=0 ALIGN=\"RIGHT\" ALT=\"Thumb\">\n";

That doesn't actually create thumbnails, it just scales them in the
browser; this is really woefully inefficient as the user has to wait
for the image to download in full, and then it looks poor because
browsers don't resample very well when they scale down pix.

However, if you really do want to do this, you may not even need
to know the image size. I am fairly sure that most browsers, if you
specify just the height or width tag, will automatically resize and
keep the proper aspect ratio. So you could just use:

print "<IMG SRC=\"$imagefile\" HEIGHT=\"$height\"
HSPACE=10 BORDER=0 ALIGN=\"RIGHT\" ALT=\"Thumb\">\n";

Give it a try.

cheers,

-*-
Charles M. Kozierok (mailto:ixl@PCGuide.com)
Webslave, The PC Guide - <http://www.PCGuide.com>
Comprehensive PC Reference, Troubleshooting, Optimization and Buyer's Guides...


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

Date: 29 Apr 2001 23:37:55 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: re-sizing GIF images on the fly
Message-Id: <9ci8kj$nto$1@bob.news.rcn.net>

Graham Stow <graham@letsgouk.com> wrote:
>>Then why do you need to use Image::Size ?  If you know enough about the
>>format of your image files to be able to do the resizing why would you
>>need to use a module ?  Ah you mean *dumbnails* not thumbnails dont you ?
>>Specify the smaller size of the image in HTML. Complete waste of time in
>>my opinion.  But hey its your website.
>>
>>/J\

> I have folk beaming up GIF files to my website and these are all
> different sizes. Image::Size tells me their size and I can then maintain
> the correct aspect ratio when rendering a thumbnail. Here's the script..

> Use Image::Size;
> ($x, $y) = ("");
> $standardheight=80;     # all thumbnails to be rendered 80 pixels high
> $height=$standardheight;
> $width=$standardheight*($x/$y);
> print "<IMG SRC=\"$imagefile\" WIDTH=\"$width\" HEIGHT=\"$height\"
> HSPACE=10 BORDER=0 ALIGN=\"RIGHT\" ALT=\"Thumb\">\n";

> Now what's dumb about that?

Because you're requiring the browser to download the full-size image and
then rescale it down (something, BTW, the browsers tend to do an
esthetically *ugly* job of).  You're simply shifting effort; you've made
your job as a designer easier by making your users go to extra effort
(consider an image gallery of 20 downloadable images, each of which is 50K
full size.  If you dumbnail the images, the user has to download the full
meg worth of images just to see all the thumbnails.  That means he has to
wait several minutes before he can see all the thumbnails, and once again,
the thumbnails will be ugly and distorted).


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

Date: Sun, 29 Apr 2001 16:46:13 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Removing Lines... how's this?
Message-Id: <13384-3AEC8BA5-19@storefull-245.iap.bryant.webtv.net>

After studying perlop, perlre, and the FAQs, this is the best I could
come up with... for removing the first 3 lines from a log file. 

$log =~ s/(.*?)\n(.*?)\n(.*?)\n//;
print $log;

Is there a better way? I couldn't get 
{n} to work, as in 

$log =~ s/(.*?){3}\n//;

Thanks,
--Dennis



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

Date: Sun, 29 Apr 2001 22:49:16 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Removing Lines... how's this?
Message-Id: <slrn9ep6jc.bv7.garry@zfw.zvolve.net>

On Sun, 29 Apr 2001 16:46:13 -0500 (CDT), BUCK NAKED1
<dennis100@webtv.net> wrote:

> After studying perlop, perlre, and the FAQs, this is the best I could
> come up with... for removing the first 3 lines from a log file. 
> 
> $log =~ s/(.*?)\n(.*?)\n(.*?)\n//;
> print $log;
> 
> Is there a better way?

  perl -wne 'print if $. > 3' file

> I couldn't get 
> {n} to work, as in 
> 
> $log =~ s/(.*?){3}\n//;

  s/(?:.*?\n){3}//

-- 
Garry Williams


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

Date: Sun, 29 Apr 2001 22:50:59 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Removing Lines... how's this?
Message-Id: <8l6petori8gt8a01vgfuoihqlgp8lip3j8@4ax.com>

BUCK NAKED1 wrote:

>After studying perlop, perlre, and the FAQs, this is the best I could
>come up with... for removing the first 3 lines from a log file. 
>
>$log =~ s/(.*?)\n(.*?)\n(.*?)\n//;
>print $log;

The question marks and the parens are unnecessary, as . doesn't match a
newline, and you're not interested in those lines themselves. So this
will do:

	$log =~ s/^.*\n.*\n.*\n//;

The ^ mainly serves to indicate the purpose of the code.

>Is there a better way? I couldn't get 
>{n} to work, as in 
>
>$log =~ s/(.*?){3}\n//;

Because . doesn' match newline. This ought to work:

	$log =~ s/^(.*\n){3}//;

-- 
	Bart.


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

Date: Sun, 29 Apr 2001 23:38:39 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Removing Lines... how's this?
Message-Id: <x7r8ybff8x.fsf@home.sysarch.com>

>>>>> "BN" == BUCK NAKED1 <dennis100@webtv.net> writes:

  BN> After studying perlop, perlre, and the FAQs, this is the best I could
  BN> come up with... for removing the first 3 lines from a log file. 

  BN> Is there a better way? I couldn't get 
  BN> {n} to work, as in 

  BN> $log =~ s/(.*?){3}\n//;

you need to put the \n inside the grouped string. . won't match a
newline so that works nicely.

but those assume you have read the entire file into memory which is not
efficient. why not do a simple one liner?

perl -ni -e 'print if $. > 3' log_file

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Sun, 29 Apr 2001 15:49:21 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: Should Perl be first?
Message-Id: <comdog-3A9AC4.15492129042001@news.panix.com>

In article <9chgi4$lb7$1@news.datasync.com>, Billy Chambless 
<bchambless@nrlssc.navy.mil> wrote:

> In article <11863-3AEB2495-139@storefull-248.iap.bryant.webtv.net>,
> BUCK NAKED1 <dennis100@webtv.net> wrote:

> >Friends tell me that VB is THE language to learn. 

> Get new friends. Preferably smarter ones. 

VB programmers can make a lot of money.  you need to know why
they say VB is the language to learn before you judge their
wisdom. :)

-- 
brian d foy <comdog@panix.com>
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



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

Date: Sun, 29 Apr 2001 22:23:07 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: Re: Should Perl be first?
Message-Id: <slrn9eou1b.21p.eins@www42.t-offline.de>

brian d foy <comdog@panix.com> wrote:
> In article <9chgi4$lb7$1@news.datasync.com>, Billy Chambless 
> <bchambless@nrlssc.navy.mil> wrote:
> 
> > In article <11863-3AEB2495-139@storefull-248.iap.bryant.webtv.net>,
> > BUCK NAKED1 <dennis100@webtv.net> wrote:
> 
> > >Friends tell me that VB is THE language to learn. 
> 
> > Get new friends. Preferably smarter ones. 
> 
> VB programmers can make a lot of money.  you need to know why
> they say VB is the language to learn before you judge their
> wisdom. :)

Perl, too. There are many applications, especially CGI.

-- 
#!/usr/bin/perl -W -- WARNING: This copies a random file from
use strict;my$s;my$n=0;for # the  current  directory  to your 
(<*>){++$n;int rand$n or$s # signature  file.   Use  at  your
=$_};`cp $s ~/.signature`; # own risk! (c) 2001 Rudolf Polzer


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

Date: Sun, 29 Apr 2001 21:07:49 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Should Perl be first?
Message-Id: <slrn9ep0l4.4qo.tjla@thislove.dyndns.org>

"mein Luftkissenfahrzeug ist voll von den Aalen"
said Billy Chambless (bchambless@nrlssc.navy.mil) in 
<9chgi4$lb7$1@news.datasync.com>:
>In article <11863-3AEB2495-139@storefull-248.iap.bryant.webtv.net>,
>BUCK NAKED1 <dennis100@webtv.net> wrote:
>
>>Friends tell me that VB is THE language to learn. 
>
>Get new friends. Preferably smarter ones. 

Such blanket statements just beg to be disagreed with. VB programmers
can (as someone mentioned) make a lot of money. Additionally I find the
language itself has a lot of nice features. Not that I want to start a
language war, just I think you are dead wrong.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
I can't decide which WRONG TURN to make first!!  I wonder if BOB
GUCCIONE has these problems!


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

Date: 29 Apr 2001 21:17:13 GMT
From: Billy Chambless <bchambless@nrlssc.navy.mil>
Subject: Re: Should Perl be first?
Message-Id: <9ci0cp$qke$1@news.datasync.com>

In article <comdog-3A9AC4.15492129042001@news.panix.com>,
brian d foy  <comdog@panix.com> wrote:

><bchambless@nrlssc.navy.mil> wrote:

>> BUCK NAKED1 <dennis100@webtv.net> wrote:

>> >Friends tell me that VB is THE language to learn. 

>> Get new friends. Preferably smarter ones. 

>VB programmers can make a lot of money.  you need to know why
>they say VB is the language to learn before you judge their
>wisdom. :)


"But what doth it profit a man if he gain the whole world, 
and lose his soul"?

Seriously, you have a point. OTOH, Perl programmers can make a lot
of money, too, without being nauseous. :) 




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

Date: 29 Apr 2001 21:31:11 GMT
From: Billy Chambless <bchambless@nrlssc.navy.mil>
Subject: Re: Should Perl be first?
Message-Id: <9ci16v$qt2$1@news.datasync.com>

In article <slrn9ep0l4.4qo.tjla@thislove.dyndns.org>,
Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
>"mein Luftkissenfahrzeug ist voll von den Aalen"

>>>Friends tell me that VB is THE language to learn. 

>>Get new friends. Preferably smarter ones. 

>Such blanket statements just beg to be disagreed with. 

And "VB is THE language to learn" isn't a blanket statement
that begs to be disagreed with? I'd go as far as to say that 
ANY statment of the form "<foo> is THE language to learn"
is somewhere between shortsighted and stupid.

> VB programmers can (as someone mentioned) make a lot of money. 
> Additionally I find the language itself has a lot of nice features.

I'll cheerfully stipulate both of those points; the first is verifiably
true, and the second is subjective --  but they still don't 
add up to supporting the idea with which I was disagreeing. 

Allow me to express myself in more detail:

1. The concept of "THE language to learn" is meaningless. Even within
a single problem domain, new languages come along with astonishing
regularity.

2. Even if we narrow the problem domain down to Web development, and
try to determine if there is one best language, VB suffers in several
ways, portability being the most obvious.


> Not that I want to start a language war,

Of course you don't.

> just I think you are dead wrong.

Could you point out exactly what it is I'm wrong about (just in the context
of this thread, we don't have time to discuss ALL the ways I'm wrong. :) )


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

Date: Mon, 30 Apr 2001 09:27:50 +1000
From: "Matt Morton-Allen" <m2@csu.edu.au>
Subject: Re: XML::RSS and mod_perl
Message-Id: <wp1H6.11$oQ5.1406@news0.optus.net.au>

Hi again,
the thing is I can't get this to work. I compile apache (1.3.19) and all is
good (the proposed strings test on the AxKit FAQ shows no plain text XML
references in the binary). But after compiling mod_perl (1.25) the XML
references are back in the binary! I use EVERYTHING=1 to get my other
requirements so I tried that off to no effect. I also tried the apache
directive to mod_perl with no effect. What am I missing?

Matt.

"Matt Sergeant" <matt@sergeant.org> wrote in message
news:3AEC1656.455BCBF2@sergeant.org...
> Matt Morton-Allen wrote:
> >
> > Hi All,
> > I am trying to use XML::RSS under mod_perl but keep getting a segfault.
The
> > error occurs only on the call to the parse method. Anyone experienced
this?
>
> It's caused by conflicts with the version of expat compiled into Apache.
> You'll have to recompile Apache with --disable-rule=expat (or
> RULE_EXPAT=no for older Apache's).
>
> See the mod_perl guide or the AxKit FAQ for more details on this.
>
> --
> <Matt/>
>
>     /||    ** Founder and CTO  **  **   http://axkit.com/     **
>    //||    **  AxKit.com Ltd   **  ** XML Application Serving **
>   // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
>  // \\| // ** mod_perl news and resources: http://take23.org  **
>      \\//
>      //\\
>     //  \\




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 796
**************************************


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