[18837] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1005 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 28 18:05:32 2001

Date: Mon, 28 May 2001 15:05:09 -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: <991087508-v10-i1005@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 28 May 2001     Volume: 10 Number: 1005

Today's topics:
    Re: <> operator problem <xris@dont.send.spam>
    Re: <> operator problem (Abigail)
        [Q] count number of emails (Guillaume Durr)
    Re: convert letters to numbers (Abigail)
    Re: convert letters to numbers <bart.lateur@skynet.be>
        embedding perl <Jens.With@t-online.de>
        exec script w/require & headers (BUCK NAKED1)
    Re: exec script w/require & headers <tony_curtis32@yahoo.com>
    Re: filenames containing spaces <krahnj@acm.org>
    Re: find executable files only <iltzu@sci.invalid>
        Function Call (Grod)
    Re: Generating WML content? <buggs@geekmail.de>
    Re: Good editor for perl Use Scite ! <graham@letsgouk.com>
    Re: Help a script to prompt to input and have those inp (Abigail)
    Re: How to create a text file in Windows/DOS with PERL? <krahnj@acm.org>
        How to launch a program in the background from perl web <extramail@qwest.net>
    Re: How to match and print like this ??? <cadmcse@hotmail.com>
    Re: Long names are doom ? <iltzu@sci.invalid>
    Re: Looking for Programmers - Numerous projects (David H. Adler)
    Re: Premature end of script headers wont go away! <james@zephyr.org.uk>
    Re: Premature end of script headers wont go away! (David Efflandt)
    Re: Premature end of script headers wont go away! <godzilla@stomp.stomp.tokyo>
    Re: Premature end of script headers wont go away! <krahnj@acm.org>
        Problem calling Perl from JavaScript <R.P.Schorn@fz-juelich.de>
    Re: re-sizing GIF images on the fly <graham@letsgouk.com>
    Re: Searching Flat Text File (Abigail)
    Re: simple reg exp problem (Keith Calvert Ivey)
    Re: Text Searching Script Problems <buggs@geekmail.de>
    Re: Text Searching Script Problems <krahnj@acm.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 28 May 2001 14:16:08 -0500
From: xris <xris@dont.send.spam>
Subject: Re: <> operator problem
Message-Id: <xris-D40587.14160828052001@news.evergo.net>

In article <3B1290C0.BEF57E9B@eyp.ee>,
 Risto Vaarandi <risto.vaarandi@eyp.ee> wrote:

> for (;;) {
>       $line = <INPUT>;
>       if (!defined($line))  { select(undef, undef, undef,
> $poll_timeout); }
>         else { print $line; }
> }

why not try something like:

   print while (<INPUT>);
   select(undef, undef, undef, $poll_timeout);

or just open the file for appending?

-Chris



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

Date: Mon, 28 May 2001 21:29:05 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: <> operator problem
Message-Id: <slrn9h5gp1.fv8.abigail@tsathoggua.rlyeh.net>

xris (xris@dont.send.spam) wrote on MMDCCCXXVII September MCMXCIII in
<URL:news:xris-D40587.14160828052001@news.evergo.net>:
{}  In article <3B1290C0.BEF57E9B@eyp.ee>,
{}   Risto Vaarandi <risto.vaarandi@eyp.ee> wrote:
{}  
{} > for (;;) {
{} >       $line = <INPUT>;
{} >       if (!defined($line))  { select(undef, undef, undef,
{} > $poll_timeout); }
{} >         else { print $line; }
{} > }
{}  
{}  why not try something like:
{}  
{}     print while (<INPUT>);
{}     select(undef, undef, undef, $poll_timeout);
{}  
{}  or just open the file for appending?


That would give a handle you can write to...


Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: Mon, 28 May 2001 23:00:29 +0200
From: g.durr@free.fr (Guillaume Durr)
Subject: [Q] count number of emails
Message-Id: <1eu53hv.659bvl17zn7oqN%g.durr@free.fr>

hi, 
I am a newbie to perl, and I have the following problems
I want to count the number of email in a file
I tried : 


open (f, 'email') || die "cant open file"; 

$n=0;

while($ligne = <f>)
{
if ($ligne =~ m°^From:.*$°)
        $n=$n+1;
}
close f;
--

but the problem is that if the message body contains "From:", the $n is
false. 

How to do that properly?


-- 
«Pour voir le PC de demain, regardez le Macintosh d'aujourd'hui.»
                  BYTE, octobre 1995
Guillaume Durr                          g.durr@free.fr
ICQ N# 29417800                http://g.durr.free.fr


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

Date: Mon, 28 May 2001 21:05:06 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: convert letters to numbers
Message-Id: <slrn9h5fc2.fv8.abigail@tsathoggua.rlyeh.net>

Bart Lateur (bart.lateur@skynet.be) wrote on MMDCCCXXVII September
MCMXCIII in <URL:news:r7u4ht8l0punop502i1qd0poa374aq4oap@4ax.com>:
!!  Anno Siegel wrote:
!!  
!! >That's not entirely equivalent.  Abigail's
!! >
!! >       my $counter = "1";   # Keep the quotes.
!! >
!! >initializes a counter of unbounded capacity, while "keys %cache" is a
!! >native integer.  Now for the reason this matters in practice... :)
!!  
!!  You'll run out of memory before you run out of integers. I would guess.


But you won't run out of disk space. You could always tie() the hash.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'


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

Date: Mon, 28 May 2001 21:24:04 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: convert letters to numbers
Message-Id: <keg5htgprs556fhvba04b1nnjgto3h9slh@4ax.com>

Abigail wrote:

>But you won't run out of disk space. You could always tie() the hash.

I was wondering... what would happen to a tied hash if 

	scalar keys  %tied

got too big to fit into an integer or into a FP number without rounding
(roughly 53 bits or so)? Would it still work reliably?

-- 
	Bart.


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

Date: Mon, 28 May 2001 21:17:42 +0200
From: Jens With <Jens.With@t-online.de>
Subject: embedding perl
Message-Id: <3B12A456.8D36BFAC@t-online.de>

Hi,

I used following program miniperl.c to test, why my program 
which embeds a perl interpreter, experienced memory leakage 
if constructing and destroying a perl interpreter everytime
I need one, but don't want to have one allocated permanently:

#include <unistd.h>

#include <EXTERN.h>
#include <perl.h>

static PerlInterpreter *my_perl; /*** The Perl interpreter ***/

int main(int argc, char **argv, char **env)
{
  int i;
  for (i = 1; i <= 100; ++i) {
    my_perl = perl_alloc();
    perl_construct(my_perl);
#if 0
    perl_parse(my_perl, NULL, argc, argv, (char **)NULL);
    perl_run(my_perl);
#endif
    sleep(1); /* helps for better tracing of memory consumption using
top */
    perl_destruct(my_perl);
    perl_free(my_perl);
  }
  return 0;
}

I used this command line to compile and link:

cc -o miniperl miniperl.c `perl -MExtutils::Embed -e ccopts -e ldopts`

Each looping causes a loss of 4 to 8KB on my Linux boxes 
(SuSE 6.1 + perl 5.005.02, SuSE 7.1 perl 5.6.0).

Does anybody could give me a hint what I am doing wrong?
Or is it a perl bug?

Thanks you,

Jens


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

Date: Mon, 28 May 2001 13:27:44 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: exec script w/require & headers
Message-Id: <1863-3B1298A0-22@storefull-243.iap.bryant.webtv.net>

How do I get rid of the headers. When I use 

require "pcount.pl";

within another script, it executes "pcount.pl" as desired, but prints
the content headers. FWIW, I have   require "pcount.pl"   right before
my END block.

Thanks,
Dennis



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

Date: 28 May 2001 14:20:46 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: exec script w/require & headers
Message-Id: <873d9pgu0h.fsf@limey.hpcc.uh.edu>

>> On Mon, 28 May 2001 13:27:44 -0500 (CDT),
>> dennis100@webtv.net (BUCK NAKED1) said:

> How do I get rid of the headers. When I use require
> "pcount.pl";

> within another script, it executes "pcount.pl" as
> desired, but prints the content headers. FWIW, I have
> require "pcount.pl" right before my END block.

<enterprise computer>
Insufficient data
</enterprise computer>

Read what you wrote through someone else's eyes.  Doesn't
make any sense or provide any useful information at all,
does it?  "the headers" -- *what* headers???

-- 
Just reach into these holes.  I use a carrot.


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

Date: Mon, 28 May 2001 20:15:53 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: filenames containing spaces
Message-Id: <3B12B1FB.52036F29@acm.org>

Florian Paulus wrote:
> 
> hi group!
> 
> i have the following problem :
> i want to create an indexfile of a directory containing .avi files,
> including the filesizes. doesnt seem to be a problem, but the filenames
> contain spaces, i don't want to remove them, so glob fails by returning an
> array containing every part of a filename between the spaces, e.g. The
> Watcher.avi glob would return The and Watcher.avi with criteria *.avi
> i got around this using ls and a temp file. now i have to determine the
> filesize using stat, but stat doesnt deliver a filesize, in shell i have to
> use a \ before every space i tried to include but somehow it still doesnt
> work.
> 
> any hint/help would be great! thank you.
> 
> below the code, i wrote so far and an example of some filenames :
> 
> #! /usr/bin/perl -w
> system('ls > temp.dat');
> open IN, "temp.dat";
> @movies=<IN>;
> close IN;
> unlink(temp.dat);
> print @movies;
> while (@movies) {
>  $var=pop(@movies);
>  if ($var=~/\.avi/) {
>      $var=~s/ /\\ /g;
>      unshift @mov,$var;
>  }
> }
> foreach $movie (@mov) {
>  @array=stat($movie);
>  print "$movie has filessize $array[7]\n";
> }

#!/usr/bin/perl -w
use strict;

opendir DIR, '.' or die "Cannot open the current directory: $!";
my @avifiles = grep /\.avi$/i, readdir DIR;
closedir DIR;
print "$_ has file size ", -s $_, "\n" for @avifiles;
__END__


John
-- 
use Perl;
program
fulfillment


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

Date: 28 May 2001 19:51:28 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: find executable files only
Message-Id: <991078758.3935@itz.pp.sci.fi>

In article <slrn9grlpe.5u2.see-sig@typhoon.xnet.com>, David Efflandt wrote:
>On Thu, 24 May 2001 16:34:06 -0400, Claudio Inglesi <cinglesi@puc.cl> wrote:
>> Does anyone know how to use the find command so that it only finds files
>> that are executable (files whose permissions are set as executable for the
>> user, group or everybody).
>
>#!/usr/bin/perl -w
>use File::Find;
>print "Files with owner, group or other execute:\n";
>find(\&wanted,'public_html');
>sub wanted {
>    $file = $File::Find::name;
>    $mode = (stat($_))[2];
>    $mode = sprintf "%lo",$mode;	# convert to octal
>    if ($mode =~ /^(\d)\d\d(\d)(\d)(\d)/) {
>        return 0 unless $1 == 1;	# file?
>        $owner = $2; $group = $3; $other = $4;
>        return 0 unless ($owner & 1 || $group & 1 || $other & 1);
>    } else { print "regex problem for $file $mode"; return 0; }
>    print "$file $owner$group$other\n";
>}

Why on earth is that so convoluted?

  #!/usr/bin/perl -w
  use strict;
  use File::Find;

  find sub {
      print "$File::Find::name\n" if -f and (stat $_)[2] & 0111;
  }, 'public_html';

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.


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

Date: 28 May 2001 13:52:25 -0700
From: ggrothendieck@volcanomail.com (Grod)
Subject: Function Call
Message-Id: <ffd662ea.0105281252.1609044d@posting.google.com>

The following function correctly outputs <1 2 3 4 5>

   use diagnostics;
   @a = sort(&f());
   print "@a\n";

   sub f {
   	return reverse (1..5);
   }

however, if I remove the & before the f then Perl complains
about the string f and outputs <> .  

If I replace the line with the sort in it with these two lines

   @a = f();
   @a = sort @a;

it works again.

Why can't Perl tell that f() is a function in all these cases?
Do I have to put & in front of every function call in all my
programs just to be absolutely sure everything works?

Thanks.


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

Date: Mon, 28 May 2001 20:17:22 +0200
From: buggs <buggs@geekmail.de>
Subject: Re: Generating WML content?
Message-Id: <9eu4lj$6j3$04$1@news.t-online.com>

Robert Nicholson wrote:

> mgjv@tradingpost.com.au (Martien Verbruggen) writes:
> 
>> On Mon, 28 May 2001 06:26:24 GMT,
>> Robert Nicholson <steffi@shell8.ba.best.com> wrote:
>> > OK, I'm forced to split my cards across multiple decks becuase of the
>> > phone limitations so since I'm generating dynamic data I'm asking what
>> 
>> What the hell does all that mean?
> 
> The subject has WML it. This assumes you are familiar with WML.

The name of this newsgroup is comp.lang.perl.misc.
This assumes you talk about the language Perl.

--snip--

Why don't you generate the .wml files when you update your content ?
Otherwise you have kind of a lock file problematic,
which is explained in the FAQ.


Buggs


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

Date: Mon, 28 May 2001 19:41:51 +0100
From: Graham Stow <graham@letsgouk.com>
Subject: Re: Good editor for perl Use Scite !
Message-Id: <03gbcVAvvpE7EwA1@letsgouk.com>

Scite!!     What A find!!!

At first glance it looks incredibly versatile for such a small package.

Ooooooooooh! Line numbers too!!! (I used to copy from Notepad and paste
in Excel to know what lines I was on!).

Shame the Help doesn't work, though.

I'll be using Scite all the time from now on.

Thanks a million Christophe!
-- 
Graham Stow


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

Date: Mon, 28 May 2001 21:20:19 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Help a script to prompt to input and have those input add or append certain lines in a text file
Message-Id: <slrn9h5g8j.fv8.abigail@tsathoggua.rlyeh.net>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDCCCXXV
September MCMXCIII in <URL:news:9ep110$ati$2@mamenchi.zrz.TU-Berlin.DE>:
//  According to Lou Moran  <lmoran@wtsg.com>:
// > On 23 May 2001 10:02:49 -0500, Tony Curtis <tony_curtis32@yahoo.com>
// > wrote wonderful things about sparkplugs:
// > 
// > SNIP
// > >
// > >> I would I go about writting a perl script to do that I
// > >> think you are a perl programmer it would not be so hard
// > >> to write this script.
// > >
// > >Eh? :-)
// > >
// > 
// > Translation
// > 
// > I would go about writing this script to do this but I am not a Perl
// > programmer (I am a Sys Admin) but I think this would be easy for a
// > Perl programmer to write this script (for me.)
//  
//  Since you are frank about it, let me be too:  If we did this, we
//  would be giving away work that other people, or even the very same
//  people, get paid for.  This rarely happens in real life.


Paid? You got to be kidding? Someone claiming to be a sysadmin, but not
being able to do some trivial programming isn't get paid for being one,
now is (s)he? No employer is that foolish...



Abigail
-- 
#!/opt/perl/bin/perl -w
$\ = $"; $SIG {TERM} = sub {print and exit};
kill 15 => fork for qw /Just another Perl Hacker/;


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

Date: Mon, 28 May 2001 20:02:01 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How to create a text file in Windows/DOS with PERL?
Message-Id: <3B12AEBA.D82A6605@acm.org>

Jim Cook wrote:
> 
> > open(FILEHANDLE,">temp.txt") || die "cannot open file.";
> 
> Question of style:
> 
> I've taken to writing these types of lines as:
> open (HANDLE, $_ = ">temp.txt") || die "Cannot open file $_: $!";

I usually write:
my $file = 'temp.txt';
open HANDLE, $file or die "Cannot open file $file: $!";

What happens if someone reads the error message and looks for a file
named ">temp.txt" instead of "temp.txt"?


> Does that seem like a good way to give sufficient information? Also, I
> remember seeing something about precedence and using "or" instead of
> "||" but can't locate it right now. 'perldoc -f open' shows both in the
> example. Could somebody please point me to the faq / documentation for
> that again so I am sure to use the right one in the future?

Simple enough to check:

$ perl -MO=Deparse -e 'open F, "< temp.txt" or die "ERROR: $!"'
-e syntax OK
die "ERROR: $!" unless open F, '< temp.txt';

$ perl -MO=Deparse -e 'open( F, "< temp.txt" ) or die "ERROR: $!"'
-e syntax OK
die "ERROR: $!" unless open F, '< temp.txt';

$ perl -MO=Deparse -e 'open F, "< temp.txt" || die "ERROR: $!"'
-e syntax OK
open F, '< temp.txt';
*********************
$ perl -MO=Deparse -e 'open( F, "< temp.txt" ) || die "ERROR: $!"'
-e syntax OK
die "ERROR: $!" unless open F, '< temp.txt';



John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 28 May 2001 21:05:11 GMT
From: Joel <extramail@qwest.net>
Subject: How to launch a program in the background from perl web script?
Message-Id: <3B12BD7B.AAF65633@qwest.net>

I have been reading and messing around with exec,system and backticks in
an attempt to have a perl web script initiate another program on the
server in the background so the web page can come back immediately and
the process on the server continues until complete.

Here is the script I'm trying:
#!/usr/bin/perl

use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
my $result =
system('/home/httpd/cgi-bin/activeComp/appliance/engine/engine.sh
appliance all 6 4');
print header,start_html,"$result", end_html;

The shell script is:
#!/bin/sh

perl engine/engine.pl $1 $2 $3 $4 &

I am launching the perl script from a shell script because I couldn't
use the '&' to start the process in the background any other way.  It
works from the shell prompt but not from the web script. I am assuming
it may have something to do with the rights of the web user Apache is
running as but I have chown the file as such.

Am I just brain farting?  I am obviously not understanding something
important like 'this can't be done' or something. Can you give me a clue
or point me in the right direction?  Thx!

Joel







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

Date: Mon, 28 May 2001 20:07:40 GMT
From: "cad fei" <cadmcse@hotmail.com>
Subject: Re: How to match and print like this ???
Message-Id: <geyQ6.46432$ko.627396@news1.frmt1.sfba.home.com>


Thanks for instruction! actually I still have difficulty to understand your
code,
becuase I am new to perl ... I had study one day  try to modify the code ,
but every time cause the error....because I don't know hash well..
the real data format actually is like this :

 .subckt seo_TTL ADD ADDPAD CEB VCCIO
XI119 ADD n1 inv
MN109 ADDPAD hn
MN207 n1 ADDPAD hn
MN208 n1 CEB hn
MN209 n1 hn
MP202 ADDPAD NP1 hp
MP204 ADDPAD NP1 hp
MP206 NP1 hp
MP216 net145 ADD n1 hp
MP205 NP1 CEB n1 hp
MP234 NP1 CEB net145 hp

only first line from 3th element to the end are belong to "Terminal" (they
are part of netnames)
I want to modify the code to print the format like this,
     Ternimal  master1(instance1)  master2(instance2) .....
but doesn't work...my concept about array,hash and reference is very poor ><

              Terminal  MN109(hn)  MN207(hn)  MN208(hn)  MN209(hn)
MP202(hp)  MP204
   ADD          X
ADDPAD      X            X
   CEB           X
   NP1
    n1
net145


from running the code, some mark by "M", some by"x".. I even don't know
why..
would u have some free time, can you teach me how to do it?
I am struggling with your code and read the Programing Perl Book for whole
day,

Thank You!

Fei
new cad engineer

"John W. Krahn" <krahnj@acm.org>
> #!/usr/bin/perl -w
> use strict;
>
> my %graph;
> my @masters;
> my $mast_wid = 0;
> my $col_wid  = 0;
> while ( <DATA> ) {
> my @f = split " ";
> my $master = shift @f;
> my $instance = pop @f;
> push @masters, $master;
> $mast_wid = length $master if $mast_wid < length $master;
>
> for ( @f ) {
> $graph{ $_ }{ $master } = substr $master, 0, 1;
> $col_wid = length if $col_wid < length;
> }
> }
> $col_wid++;
> $mast_wid++;
>
> printf "%${mast_wid}s" . "%${col_wid}s" x @masters . "\n", ' ',
> @masters;
> for my $x ( sort keys %graph ) {
> printf "%${mast_wid}s", $x;
> for my $y ( @masters ) {
> printf "%${col_wid}s", exists $graph{$x}{$y} ? $graph{$x}{$y} : ' ';
> }
> print "\n";
> }
>
> __DATA__
> MN109 ADDPAD hn
> MN207 n1 ADDPAD hn
> MN208 n1 CEB hn
> MN209 n1 hn
> MP202 ADDPAD NP1 hp
> MP204 ADDPAD NP1 hp
> MP206 NP1 hp
> MP216 net145 ADD n1 hp
> MP205 NP1 CEB n1 hp
> XI119 ADD n1 inv
> MP234 NP1 CEB net145 hp
>
>
>
> John
> --
> use Perl;
> program
> fulfillment




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

Date: 28 May 2001 20:07:15 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Long names are doom ?
Message-Id: <991080352.4863@itz.pp.sci.fi>

In article <3B0F6809.B9EE02A9@aol.com>, 00001111@aol.com wrote:
>
>  Anybody use variables/names longer than 31 character
>and finds it really useful ?

Sorry, wrong group -- comp.lang.java.misc is just around the corner.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla / Kira -- do not feed the troll.


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

Date: 28 May 2001 21:12:30 GMT
From: dha@panix2.panix.com (David H. Adler)
Subject: Re: Looking for Programmers - Numerous projects
Message-Id: <slrn9h5fpu.99b.dha@panix2.panix.com>

In article <759114d.0105280448.7f12106e@posting.google.com>, William
Cross wrote:
> PerlCoders dot com currently has 2 openings for perl programmers.

You have posted a job posting or a resume in a technical group.

Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.

Had you read and understood the Usenet user manual posted frequently to
"news.announce.newusers", you might have already known this. :)  (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)
Another good source of information on how Usenet functions is
news.newusers.questions (information from which is also available at
http://www.geocities.com/nnqweb/).

Please do not explain your posting by saying "but I saw other job
postings here".  Just because one person jumps off a bridge, doesn't
mean everyone does.  Those postings are also in error, and I've
probably already notified them as well.

If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.

http://jobs.perl.org may be of more use to you

Yours for a better usenet,

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"It was failure proof technology"
"What happened?"
"It failed"                     - Doctor Who, Frontios


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

Date: Mon, 28 May 2001 19:39:11 +0100
From: James Coupe <james@zephyr.org.uk>
Subject: Re: Premature end of script headers wont go away!
Message-Id: <KlPiEoEPtpE7EwHY@obeah.demon.co.uk>

In message <4nwQ6.3917$kh4.348863@bgtnsc04-news.ops.worldnet.att.net>,
Khalid Shahzad <nabeels786@worldnet.att.net> writes
>print "Changes have been made\n"
                                 ^


>#print << "out";
>#   <a href="http://esrclan.vr9.com">click here to go back to the site</a>
>#out

You appear to be missing a semi-colon.

-- 
James Coupe                                                PGP Key: 0x5D623D5D
"You reinstall Dial-Up Networking.  The Elf screams and becomes  EBD690ECD7A1F
an icon. *** CONGRATULATIONS! *** You completed the BT Internet  B457CA213D7E6
Helpdesk training course in 15 out of a possible 9000 moves."   68C3695D623D5D


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

Date: Mon, 28 May 2001 18:49:46 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: Premature end of script headers wont go away!
Message-Id: <slrn9h57ea.aig.see-sig@typhoon.xnet.com>

On Mon, 28 May 2001, Khalid Shahzad <nabeels786@worldnet.att.net> wrote:
> 
> i wrote a script that would take a message and write it to a .js file, which
> is being embedded by an html file. the error log gives these errors:
> 
> syntax error at /data/esrclan/cgi-bin/headline.pl line 38, near "sub
> PrintError "
> syntax error at /data/esrclan/cgi-bin/headline.pl line 44, near "}"
> Execution of /data/esrclan/cgi-bin/headline.pl aborted due to compilation
> errors.
> [Mon May 28 11:13:05 2001] [error] [client 12.78.224.90] Premature end of
> script headers: /data/esrclan/cgi-bin/headline.pl
> [Mon May 28 11:13:05 2001] [error] [client 12.78.224.90] MOD_VR9: Error 500
> occured while processing : /data/esrclan/cgi-bin/headline.pl

If nothing reaches out and grabs you on the error line, check the lines
_before_ that for something like a missing quote, or the missing
semi-colon at the end of line 33.

-- 
David Efflandt  (Reply-To is valid)  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Mon, 28 May 2001 12:43:17 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Premature end of script headers wont go away!
Message-Id: <3B12AA55.83A18ADF@stomp.stomp.tokyo>

Khalid Shahzad wrote:

(various snippage)

> i wrote a script that would take a message and write it to a .js file, which
> is being embedded by an html file. the error log gives these errors:

 
It is very clear to me the underlying code is written
by an author other than yourself and, you have typed
in code which generates errors. Why did you do this?



Remove this line completely:

> print "Content-type: text/html\n\n";


Remove all three of these lines:
 
> $message = "" ;
> $found_err = "" ;
 
> $errmsg = "<p>The password you entered is not valid.</p>\n" ;


Remove the following five lines:
 
> if ($password ne "lemmein") {
>  $message = $message.$errmsg ;
>  $found_err = 1 ; }
 
> if ($found_err) {
>  &PrintError; }

Replace those five lines with:

if ($password ne "lemmein") 
 { &PrintError; }
else
 { print "Content-type: text/html\n\n"; }


Add a semicolon to the end of this line:

> print "Changes have been made\n"


Remove these six lines:

> sub PrintError {  #line 38
>  print "Content-type: text/html\n\n";
>  print $message;
 
>  exit 0;
>     return 1;
> }

Replace those six lines with:

sub PrintError 
 {
  print "Content-type: text/html\n\n";
  print "
     <html><body>
     <br><br>The password you entered is not valid.
     </body></html>";
  exit;
 }



Being annoyed, a few minutes is all I am willing to
invest in what appears to be a typical troll article.


Godzilla!


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

Date: Mon, 28 May 2001 20:25:54 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Premature end of script headers wont go away!
Message-Id: <3B12B473.E774EAE2@acm.org>

Khalid Shahzad wrote:
> 
> hey everyone,
> 
> i wrote a script that would take a message and write it to a .js file, which
> is being embedded by an html file. the error log gives these errors:
> 
> syntax error at /data/esrclan/cgi-bin/headline.pl line 38, near "sub
> PrintError "
> syntax error at /data/esrclan/cgi-bin/headline.pl line 44, near "}"
> Execution of /data/esrclan/cgi-bin/headline.pl aborted due to compilation
> errors.
> [Mon May 28 11:13:05 2001] [error] [client 12.78.224.90] Premature end of
> script headers: /data/esrclan/cgi-bin/headline.pl
> [Mon May 28 11:13:05 2001] [error] [client 12.78.224.90] MOD_VR9: Error 500
> occured while processing : /data/esrclan/cgi-bin/headline.pl
> 
> but i dont see anything wrong at line 38. heres the script:
> 
> #!/usr/bin/perl
> 
> &GetFormInput;
> 
> print "Content-type: text/html\n\n";
> 
> $headline = $field{'headline'} ;
> $password = $field{'password'} ;
> $Submit = $field{'Submit'} ;
> $Submit2 = $field{'Submit2'} ;
> 
> $message = "" ;
> $found_err = "" ;
> 
> $errmsg = "<p>The password you entered is not valid.</p>\n" ;
> 
> if ($password ne "lemmein") {
>  $message = $message.$errmsg ;
>  $found_err = 1 ; }
> 
> if ($found_err) {
>  &PrintError; }
> 
> open (LOGFILE, "> ../scripts/announce.js") ;
>     flock(LOGFILE, 2) ;
>     seek(LOGFILE, 0, 2) ;
>         print LOGFILE "//Script by Nabeel Shahzad\n";
>         print LOGFILE "//Automatically updates with a Perl Script\n";
>         print LOGFILE "document.write('<marquee
> scrollamount=4>$headline</marquee>')\n" ;
>     flock(LOGFILE, 8) ;
> close (LOGFILE) ;
> 
> print "Changes have been made\n"
                                  ^^
                                  **
Missing semicolon.


> #print << "out";
> #   <a href="http://esrclan.vr9.com">click here to go back to the site</a>
> #out
> 
> sub PrintError {  #line 38
>  print "Content-type: text/html\n\n";
>  print $message;
> 
>  exit 0;
>     return 1;
> }



John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 28 May 2001 20:25:34 +0000
From: "Dr. Ralph P. Schorn" <R.P.Schorn@fz-juelich.de>
Subject: Problem calling Perl from JavaScript
Message-Id: <3B12B43E.E3CFDB17@fz-juelich.de>

I want to execute a Perl script on an HTTP server
(just generating an email with sendmail) out of a
JavaScript function, e.g.

<script language="JavaScript">
   function Send_Email()
     {
       location.href = "/cgi-bin/the_script.pl";
     }
</script>

The Perl script itself has no syntax errors and is
quite OK e.g. when used with the action-tag of a
form in HTML. When activated from JavaScript,
however, I receive the internal server error 500.

What's going wrong here ? Any ideas ?

Thanks,
  Ralph


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

Date: Mon, 28 May 2001 20:24:05 +0100
From: Graham Stow <graham@letsgouk.com>
Subject: Re: re-sizing GIF images on the fly
Message-Id: <BU+m0iAVXqE7Ew0f@letsgouk.com>

Thanks Arnar.

(BTW, my name is Graham but I started this dialogue on another machine,
hence the name Andrew).

Snipping...

>
>It's not a good idea to send an image to a browswer use the height and
>width tags to change the size of the image.  The image is generally
>bigger than it has to be and it also means that the conversion is done
>in the browser.  Most browsers use nearest neighbor sampling, they
>just use the value of the nearest pixel.  This generally leads to a
>problem called aliasing and the result is that images look noisy.
I realise this now.

>It's important to know what kind of images you are working with.  If
>your images are similar to text small text then using these resampling
>methods may cause them to appear smoothed or blurry.
Few if any of my images will be similar to text, so I shouldn't have
this problem

>  
>
>It's likely that some of ImageMagick, Photoshop or gimp support
>scaling using the nearest neighbor method which is generally MUCH
>MUCH faster than using the resampling methods.
I guess your saying that using ImageMagick etc is much faster than
letting the browser do the work, right?


>
>Another aspect is that you want to save the scaled version again as
>gif.  The gif format is limited to 256 color palettes.  But if you
>scale using interpolation the resulting image is likely to contain
>much greater number of colors than the original.  This causes your
>image to re-color quantized.  Meaning that the palette is regenerated.
OK, I think I understand this.

>
>Gif also employes LZW compression which is patented by UNISYS for at
>least the next 3 years.  This means that you should get a license from
>UNISYS before using unlicensed programs for generating LZW compressed
>gifs with unlicensed (free) versions of ImageMagick and Gimp.
Sounds like I should avoid generating GIF thumbnails then, and generate
png thumbnails instead (see below)?

>
>I would try to use png images instead of gifs for the thumbnails.  PNG
>is a superior format in every way as long as you don't need
>animations, which I think you don't need according to your description.
No, I don't need animations. But I'm not familiar with the png image
format at all.

>
>Lastly scaling images is a very cpu and memory intensive process,
>especially as the images become bigger.  Doing it on the fly may put a
>very high load on your server.  It may be a better idea to generate
>the thumbnails when you put the larger version on the server.
Most of my images would be under 100K. In the fullness of time I
anticipate having between 10,000 and 20,000 such images on my ISP's
server, all of them input by clients at their browser using the HTML
input field <INPUT TYPE=FILE> (i.e. I would not be putting the images on
the server myself). I have written and tested the Perl scripts do this
and everything works fine. 

The main reason for generating the thumbnails on the fly is that I
wanted to avoid storing between 10,000 and 20,000 thumbnails. However, I
could amend the scripts to generate and file the thumbnails at the same
time as the main image is beamed up to the server. But I'd still rather
do it all on the fly, assuming for the moment that Image Magick can
generate the PNG thumbnails from 80-100K GIF images pretty muck
instantaneously. Any advice on this?

Having said all the above, I'm still faced with persuading my ISP to
install Image Magick on their server (I think they're hoping I'll stop
pestering them and forget all about this).


>
><shameless plug>
>Since I wrote the Imager module I'll include example code of generating a
>thumbnail using that.
>------- CODE -------
>
>#!/usr/bin/perl -w
>
>use Imager;
>
>$img = Imager->new();
>$img->open(file=>"image.gif") or die $img->errstr;
>$thumb = $img->scale(xpixels => 100, ypixels => 80, type => 'min');
>$thumb->write(file=>"thumb.png") or die $img->errstr;
>
>print "Thumbnail Width:  ",$thumb->getwidth() ,"\n";
>print "Thumbnail Height: ",$thumb->getheight(),"\n";
>
>-------------------
>
>That example makes sure that the thumbnail fills as much of a 100x80
>square while maintaining the original aspect ratio.  By default the
>scale method uses resampling, if you should want to use a nearest
>neighbor sampling you can do so by supplying qtype=>'preview' to the
>scale method.
I presume the above code relates to the Imager module of ImageMagick,
and guess it will be very useful when I get this all sorted.


>
>
>
>Hope this helps,  Arnar.
Sure does, Arnar!


-- 
Graham Stow


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

Date: Mon, 28 May 2001 21:24:45 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Searching Flat Text File
Message-Id: <slrn9h5ggt.fv8.abigail@tsathoggua.rlyeh.net>

Bart Lateur (bart.lateur@skynet.be) wrote on MMDCCCXXVII September
MCMXCIII in <URL:news:9q74htk5k1rpd38offfta3jnpu7c64j2lo@4ax.com>:
$$  RoadRunner wrote:
$$  
$$ >I would like to search a text file for any occourances of $keyword. Now, if
$$ >a line contains $keyword, then just print it. The file is has 228,000 lines,
$$ >so would it make more sense to put everything in a mySQL db?
$$  
$$  I think not. In an SQL db, you need to use the "LIKE '%KEYWORD%'"
$$  construct, which won't be a speed demon, and is far less powerfull than
$$  regexes. For example, it would also match parts of a word.


Excuse me? Why do you need to use the "LIKE %KEYWORD%" construct?
There is nothing that requires you to store data in a dumb way.

If you want to search by word, you use a table indexed by word.
Not with the whole text - that would be stupid.



Abigail
-- 
perl -swleprint\$- -- --='Just another Perl Hacker'


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

Date: Mon, 28 May 2001 17:58:18 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: simple reg exp problem
Message-Id: <3b1290e1.62113107@news.newsguy.com>

Bart Lateur <bart.lateur@skynet.be> wrote:
>David Aslanian wrote:
>
>>$test = "sometext <!--#INCLUDE file2.txt--> someothertext";
>>if($test =~ m/.*<!--#INCLUDE\s([A-Z1-10\.]+)-->.*/i) { 
>>         print "a match."; 
>>} else { print "not a match.";  }
>>
>>if acts if it was not a match, and it seems like it should be!
>
>No. You want [A-Z0-9\.] in your character class.
>
>[1-10] is just the digits 1 (to 1) and 0.

Also, unless David is doing something later with $` or $& or $'
(or a few other obscure things), which he probably shouldn't be,
the .* is pointless at the beginning and end of the regex.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Mon, 28 May 2001 20:46:57 +0200
From: buggs <buggs@geekmail.de>
Subject: Re: Text Searching Script Problems
Message-Id: <9eu6cs$rsa$06$1@news.t-online.com>

Austin wrote:

> Hello,
> 
> The script pasted at the end of this message isn't functioning as
> expected. Basically it works in the form of this:
> http://localhost/cgi-bin/search.cgi?<max results>,<extra info (1 or
> 0)>,<keyword 1>,<keyword 2>,<keyword 3>,<keyword 4>,<keyword 5>.
> Basically, it's going past the max limit and it's not reporting the max
> number of results (which should just be the number of lines in the open
> file handle <FILE>). Any help is MUCH appriciated.

OK. But remember *any*.
Nobody will do your work and hunt a bug down.
You won't get much help with the kind of code you posted.

> 
> Also, if your looking to get something out of this, I can offer you a
> 468x60 banner spot on a high profile music site free for 90 days (no xxx).

no xxx then forget about it.

> 
> Cheers-
> Austin
> 
> -- START CODE --
--snip--

When you deal with protcols and API's you don't really understand
stick to their definitions and try to use Modules ( e.g. CGI.pm ).
Don't try to avoid learning the definitions or Modules.
Applying your own extra Magic without understanding is worthless.
Instead use well known code pragmas.
If you don't people won't help you. 

Whenever you start to see repetition of if statements
doing the same you should make loop out of it.

When it looks ugly it probably is.

Buggs


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

Date: Mon, 28 May 2001 19:31:10 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Text Searching Script Problems
Message-Id: <3B12A77F.80293284@acm.org>

Austin wrote:
> 
> Hello,
> 
> The script pasted at the end of this message isn't functioning as expected.
> Basically it works in the form of this:
> http://localhost/cgi-bin/search.cgi?<max results>,<extra info (1 or
> 0)>,<keyword 1>,<keyword 2>,<keyword 3>,<keyword 4>,<keyword 5>. Basically,
> it's going past the max limit and it's not reporting the max number of
> results (which should just be the number of lines in the open file handle
> <FILE>). Any help is MUCH appriciated.
> 
> Also, if your looking to get something out of this, I can offer you a 468x60
> banner spot on a high profile music site free for 90 days (no xxx).
> 
> Cheers-
> Austin
> 
> -- START CODE --
> 
> #!/usr/bin/perl

#!/usr/bin/perl -w
use strict;


> if ($ENV{'QUERY_STRING'} eq "dump") {
>  use IPC::Open2;
>  $pid = open2(readit, writeit, "cat
> /home/newwave/public_html/mcm.inapnow.org/cgi-bin/edump/austin.cgi");
>  waitpid $pid, 0;
>  @script = <readit>;

Did you read the documentation for IPC::Open2? Do you understand why
this is a bad idea?

WARNING
       It will not create these file handles for you.  You have
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       to do this yourself.  So don't pass it empty variables
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       expecting them to get filled in for you.
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

       Additionally, this is very dangerous as you may block
       forever.  It assumes it's going to talk to something like
       bc, both writing to it and reading from it.  This is
       presumably safe because you "know" that commands like bc
       will read a line at a time and output a line at a time.
       Programs like sort that read their entire input stream
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       first, however, are quite apt to cause deadlock.
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

       The big problem with this approach is that if you don't
       have control over source code being run in the child
       process, you can't control what it does with pipe
       buffering.  Thus you can't just open a pipe to cat -v and
       continually read and write a line from it.

You should use:

open readit, "cat
/home/newwave/public_html/mcm.inapnow.org/cgi-bin/edump/austin.cgi |" or
die "cannot pipe from cat: $!";


>  print "Content-type:  text/html\n\n";
>  foreach $key (@script) { print $key; }
>  exit;
> }

Since you are using cat anyways this if statement could be written as:

if ($ENV{'QUERY_STRING'} eq "dump") {
    system( "cat
/home/newwave/public_html/mcm.inapnow.org/cgi-bin/edump/austin.cgi" );
    }

> print "Content-type:  text/html\n\n";
> ($max, $extra, $keyword1, $keyword2, $keyword3, $keyword4, $keyword5) =
> split (',', $ENV{'QUERY_STRING'});
> open FILE, "</home/newwave/public_html/mcm.inapnow.org/edump/infolink_wx.db"
> or die "Cannot open info_nx.db: $!";
> $max = $max + 1;
> $results = 0;
> 
> if ($results < $max) {
>  while (<FILE>) { if (/$keyword1/i and /$keyword2/i and /$keyword3/i and
> /$keyword4/i and /$keyword5/i) { $res[$results] = "$_"; last if ($results +=
> 1) > $max } }
> }
> if ($results < $max) {
>  while (<FILE>) { if (/$keyword1/i and /$keyword2/i and /$keyword3/i and
> /$keyword4/i or /$keyword5/i) { $res[$results] = "$_"; last if ($results +=
> 1) > $max } }
> }
> if ($results < $max) {
>  while (<FILE>) { if (/$keyword1/i and /$keyword2/i and /$keyword3/i or
> /$keyword4/i or /$keyword5/i) { $res[$results] = "$_"; last if ($results +=
> 1) > $max } }
> }
> if ($results < $max) {
>  while (<FILE>) { if (/$keyword1/i and /$keyword2/i or /$keyword3/i or
> /$keyword4/i or /$keyword5/i) { $res[$results] = "$_"; last if ($results +=
> 1) > $max } }
> }
> if ($results < $max) {
>  while (<FILE>) { if (/$keyword1/i or /$keyword2/i or /$keyword3/i or
> /$keyword4/i or /$keyword5/i) { $res[$results] = "$_"; last if ($results +=
> 1) > $max } }
> }

Usually when you have code that looks repetitious it is probably time to
rethink your algorithm. Maybe store the whole file in an array if it is
small enough.

> if ($extra) {
>  $rescnt = 0;
>  foreach $key (@res) {
>   $x = $info = $link = "";
>   ($x, $info, $link) = split('\|', $key);
>   $rescnt++ if ($x ne "") and ($info ne "") and ($link ne "");
>  }
>  while (!(eof(FILE))) {
>   $line = (<FILE>);
>  }
>  ($x, $info, $link) = split('\|', $line);
>  print "Out of a possible <B>$x</B>, there was <B>1</B> result.\n\n" if
> ($rescnt eq "1");
>  print "Out of a possible <B>$x</B>, there were <B>$rescnt</B> results.\n\n"
> if ($rescnt ne "1");
> }
> foreach $key (@res) {
>  $x = $info = $link = "";
>  ($x, $info, $link) = split('\|', $key);
>  print "<B>Item $x<B> -> <A HREF=\"$link\">$info</A>\n" if ($x ne "") and
> ($info ne "") and ($link ne "");
> }
> close (FILE);
> exit;


John
-- 
use Perl;
program
fulfillment


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

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


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