[10025] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3618 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 2 12:07:08 1998

Date: Wed, 2 Sep 98 09:01:33 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 2 Sep 1998     Volume: 8 Number: 3618

Today's topics:
        print "Content-type:text/html\n\n"; and redirection... <simon@new-mediacom.com>
    Re: Problems building threaded perl 5.005 on OSF 4.0d (Greg Bacon)
    Re: reading from file (I.J. Garlick)
        Subtracting two arrays zix6@yahoo.com
    Re: Threading/forking simple(?) programs (Duke)
    Re: Tom Phoenix: ANSWERS WANTED! <jdporter@min.net>
    Re: Tom Phoenix: ANSWERS WANTED! <eashton@bbnplanet.com>
    Re: Tom Phoenix: ANSWERS WANTED! <eashton@bbnplanet.com>
        We don't need no stinking benchmarks (was Re: Newbie RE <dgris@rand.dimensional.com>
    Re: Where to get Net/Domain.pm? (I R A Aggie)
    Re: Why Perl ? <jdporter@min.net>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 2 Sep 1998 16:22:02 +0100
From: Simon Wistow <simon@new-mediacom.com>
Subject: print "Content-type:text/html\n\n"; and redirection...
Message-Id: <645CAC0140CED111AF1500805FEDDB8AB6A0@ns.new-mediacom.co.uk>


IIS also sometimes complains if you don't put 

print "HTTP/1,0 200 OK\n";

before the content type statement. However having this produces an error
if put it on my Unix server. Yet another case where Miro$loth just *HAD*
to be different.



> -----Original Message-----
> From:	news@csc.liv.ac.uk (News Eater) [SMTP:news@csc.liv.ac.uk] On
> Behalf Of ijg@csc.liv.ac.uk (I.J. Garlick)
> Posted At:	Sunday, August 30, 1998 3:32 PM
> Posted To:	misc
> Conversation:	print "Content-type:text/html\n\n"; and redirection...
> Subject:	Re: print "Content-type:text/html\n\n"; and
> redirection...
> 
> In article <slrn6tikge.mh7.maurice@we-24-130-48-83.we.mediaone.net>,
> maurice@hevanet.com (Maurice Aubrey) writes:
> > On Tue, 18 Aug 1998 11:52:57 +0200, Wouter Hermans
> <whermans@mail.dma.be> wrote:
> > 
> >>for some weird reason "Content-type:text/html" shows up in my
> browser when i
> >>run a perl script on a microsoft iis3 server.  don't know if it
> happens on
> >>unix servers...
> > 
> > Are you using CGI.pm?
> > 
> >>also: i'm trying to read in a value (=url) from a form, and then let
> the cgi
> >>relink the user through to that url.  any ideas?
> > 
> > #!/usr/bin/perl -Tw
> > 
> > use CGI;
> > 
> > $cgi = new CGI;
> > print $cgi->redirect( $cgi->param('newurl') );
> 
> Ahhhhhh.... I hate you. I have been doing a complicated dance with the
> Location header and search and replavce of spaces on params I need to
> pass
> on.
> 
> I don't really hate you but this will make my life easier no end. It's
> what I get for not reading the pod I suppose, but it's so damned big.
> 
> -- 
> --
> Ian J. Garlick
> ijg@csc.liv.ac.uk
> 
> Your conscience never stops you from doing anything.  It just stops
> you
> from enjoying it.



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

Date: 2 Sep 1998 14:41:20 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Problems building threaded perl 5.005 on OSF 4.0d
Message-Id: <6sjleg$8t$3@info.uah.edu>

In article <35EC9697.80A30007@uni-lj.si>,
	Jure Simsic <jure.simsic@uni-lj.si> writes:
: Has anybody gotten this to work. I tried perl 5.005 and 5.005_51 but
: failed.

Check in <URL:http://www.itsc.uah.edu/perl/query>.  Set the architecture
to alpha-dec_osf-thread.

Hope this helps,
Greg
-- 
When Primitive man screamed and beat sticks on the ground we called him a
Barbarian.  When Modern man does the same we call him a golfer.


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

Date: Wed, 2 Sep 1998 14:58:49 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: reading from file
Message-Id: <EynwA1.GEH@csc.liv.ac.uk>

In article <35EC1961.63C66284@email.mot.com>,
Jeffrey Rosen <Jeffrey_Rosen-P28312@email.mot.com> writes:
> I have code that is not behaving as I would expect.  $name gets
> manipulated as if it was a pointer to $line, not a string copy of the
> informaiton. How do I make a copy of the string?
> 

Why are you doing it like this? What's wrong with $_? or is there some reason
you are using $line that you are not telling us?

> 
> $DATA_FILE = "/tmp/1998_08_11_013400.ldif";
> open(DATA,"$DATA_FILE") || die "Input file not found";
> while ($line=<DATA>) {
	while (<DATA>) {
> $name=$line;
>      if ($line =~ /nscalxitemid:/) {
		if (/nscalxitemid:/) {
>        print $name;
			print;
>        ($attribute,$node,$id)=split(/:/,$line);
			($attribute,$node,$id)=split ':';
>        if (!defined($idlist{$id})) {
>             $idlist{$id} = 1;
>        }
>        else {
>            print "dup: $id";
>        }
>      } #end match id
> } #end while main loop

Nothing wrong with above code runs fine here.

Hmmm.. You are using NT to send this. You using this script on an NT machine?
Shouldn't thinks with that dir structure but you have to ask.
Which then leads to the $65 million question do you have permission to read
file? You should have or it would be dieing, is it dieing you don't say?

BTW try code like this:-

$DATA_FILE = "/tmp/1998_08_11_013400.ldif";
open(DATA,"$DATA_FILE") || die "Input file not found";
while (<DATA>) {
	if (/nscalxitemid:/) {
		print;
		($attribute,$node,$id)=split ':';
		if (!defined($idlist{$id})) {
			$idlist{$id} = 1;
		}
		else {
			print "dup: $id";
		}
	} #end match id
} #end while main loop

The '$line' variable disappears (which may or may not be causing problem) as
does $name. Thats what the builtin variables are for, they may even make the
code faster, I don't know I am no expert.

--
Ian J. Garlick
ijg@csc.liv.ac.uk

Whenever people agree with me I always feel I must be wrong.
                -- Oscar Wilde


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

Date: Wed, 02 Sep 1998 15:23:21 GMT
From: zix6@yahoo.com
Subject: Subtracting two arrays
Message-Id: <6sjnt8$o75$1@nnrp1.dejanews.com>

I have two arrays of the same length and I want to substract them element by
element to create a new array:

@array1 = (1,2,3);
@array2 = (4,5,6);
for ($i = 0; $i <= $#array1; ++$i)
{
    push(@array3, $array2[$i] - $array1[$i]);
}
print @array3;

Is there a simpler more "Perl like" way to do this?

Brian

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 02 Sep 1998 15:28:56 GMT
From: duke@co.kittitas.wa.us (Duke)
Subject: Re: Threading/forking simple(?) programs
Message-Id: <35ed6126.682751264@mars.co.kittitas.wa.us>

On 27 Aug 1998 01:52:54 GMT, Zenin <zenin@bawdycaste.org> wrote:

>Duke <duke@co.kittitas.wa.us> wrote:
>> Sometimes it seems that bar(1) takes longer than foo(2) and my blocking
>> doesn't seem to take that into account.
>        >snip<
>> If I block on waitpid($$) also then won't I just hang
>> forever since the original PID won't be done?
>
>        The foo(2) child exits when it's done.  If/when the foo(2) child
>        finishes first, a "Zombie" or "defunct" process will be left in the
>        process table until its parent (the main program) waits for it.
>
>        So, even if foo(2) does finish first, bar(1) is free to reap foo's
>        pid at any time.  In this case, waitpid() won't block because foo
>        is done and its pid is ready to be reaped, which should be fine.
>
>        Look at it this way (dots are working code):
>
>        Time------------------------------------>
>        foo.....foo...  foo.....foo....
>                bar.....bar..   bar.......bar...
>                        ^       ^         ^
>                        wait    wait      wait
>
>        Thus, we sync our access regardless of who takes longer to run,
>        because waitpid() returns when foo is done or immediately if foo
>        is already done before we called waitpid().
>-- 
>-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
>BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
>Berkeley or thereabouts.  Similar in many ways to the prescription-only
>medication called "System V", but infinitely more useful. (Or, at least,
>more fun.)  The full chemical name is "Berkeley Standard Distribution".

I hate to keep bothering you....
I seem to keep getting multiple foo's running which dogs down the read
times, then bar looks for the foo(2) filename which foo is not yet
done with, and bar(2) fails.  Meanwhile I have foo(2) and foo(3)
running.  I don't understand enough yet about IPC to figure this one
out or even how to troubleshoot.

I am running subroutines which (roughly) look like:
$cdreadprog = "fooprog";
$dataprocessprog = "barprog";
sub findtrack
{
    find out which tracks on the CD to process.
}

sub cdread
{
   system("$cdreadprog $cdreadargs $cdreadtrack");
   system("mv $cdreadtrack-filename $tracknumber.ext");
}

sub dataprocess
{
   system("$dataprocessprog $dataprocessargs $curtrack.ext");
   system("mv $curtrack.ext2 $filename.correct");
}

#pseudosub MAIN
#{
    findtrack();
    put data from that into @tracks;
    @datatracks = @tracks;
    $dataindx = 0;
    $curtrack = $datatracks[$dataindx++];

   $cdreadtrack = shift(@tracks);
   cdread();

   foreach $cdreadtrack (@tracks)
   {
      my $pid = fork();
      defined $pid or die "fork(): $!";

       if ($pid)
       {
            cdread();
        } else
       {
            exit dataprocess();
       }
      
       waitpid ($pid,0) ||
          die "Child error: $?" if $?;

      $curtrack = $datatracks[$dataindx];
      $dataindx++;
   }
   dataprocess();
#}
  
Process dies when attempting dataprocess on second filename.  Second
filename does not exist.  I do a ps and find (2) cdread processes
going.  One for 2nd track and one for the 3rd track.

Thanks again for all of your help!
duke


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

Date: Tue, 01 Sep 1998 10:54:59 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Tom Phoenix: ANSWERS WANTED!
Message-Id: <35EC0AC3.92960958@min.net>

Scratchie wrote:
> 
> I beg to differ.
> 
> In <Pine.GSO.4.02A.9808311703010.24074-100000@user2.teleport.com>,
> Tom Phoenix wrote:
> : I suspect that you want to remove newlines rather than carriage returns.
> : Removing newlines is done most often in Perl with chomp. Does that do
> : what you need? Hope this helps!
> 
> That was the very first post that a Dejanews search turned up under Tom's
> name. I'd say it provides both insight (guessing what the person was
> trying to do based on her question) and direction (check out the function
> "chomp").

You guess wrongly.

As the followup to that post, Andre L correctly pointed out:
> 
> I'm afraid that might not cut it with the problem at hand -- that is, if
> the poster has the data from each of his HTML form inputs in a scalar.
> Then, it becomes a matter of eliminating end-of-line sequences inside a
> string, not in an array, as the subject line misleadingly states.
> 
> The HTML specs tell us that the ends-of-lines in textareas are \015\012
> (carriage return and linefeed). So, to remove the ends-of-lines, a
> substitution like this would be used:
> 
>    $textarea =~ s/\015\012/ /g;
>    #                       ^this is a space
> 
> Remember to append a newline to the modified textarea string when writing
> it to the file.

Not as brief, perhaps, nor as angelically polite, but much more
helpful inasmuch as it was much more correct.


> 
> How 'bout this one?
> 
> In <Pine.GSO.4.02A.9808311800590.24074-100000@user2.teleport.com>:
> Tom Phoenix wrote:
> : That's valid Perl code, dispite the misleading backslashes. Isn't it
> : doing what you want? It should find a string in $daemon beginning with
> : '<in', followed by any character but newline, then finishing up with
> : 'routed>>', and when it finds that string it should replace it with
> : '/usr/sbin/in.routed'. Is that not what you want? Hope this helps!
> 
> Here somebody's regex isn't working the way it's "supposed" to. Tom walks
> him through the regex and points out exactly what it's doing.  Does that
> lack "direction"?

But Tom P utterly failed to grasp the deeper context.
Ian A. Lowe's regex was /\<in.routed>\>/, and he explained that he
wanted to match "in.routed" or "/usr/sbin/in.routed".
He was expecting -- as any vi user might -- to match word boundaries
with \< and \>.  Such things are matched by \b in perl, of course;
Tom coulda mentioned that.  He also coulda suggested a regex that
actually did Ian was trying to do.  Hope this helps!

Those two examples are very illustrative of the point I'm making.


> Even responses like
> : The command 'perldoc constant' should inform you. Hope this helps!
> (from <Pine.GSO.4.02A.9808311807580.24074-100000@user2.teleport.com>)
> 
> or the rare
> 
> : FAQ
> 
> tell the person where to find the answer to their question, don't they?

As I say in another post, when the answer is RTFM, Tom can say it as
well as anybody, and more politely than most.


> I'm not saying this to bust your balls, John, but out of genuine
> curiosity. Tom P is one of the (if not *the*) most helpful people on this
> newsgroup, yet you find him unhelpful. Tom is the closest thing we have to
> the dreaded "free help desk", so what do you find lacking in his approach?

Last thing I want is for Tom P to stop posting he courteous responses.
It's just that his idea of helpfulness and mine are a little different.

-- 
John Porter


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

Date: Wed, 02 Sep 1998 15:37:08 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Tom Phoenix: ANSWERS WANTED!
Message-Id: <35ED63D0.ED9108D3@bbnplanet.com>

Nathan V. Patwardhan wrote:
> 
> Jonathan Feinberg (jdf@pobox.com) wrote:
> 
> : I'm trying to see your posts today as anything other than trolls.
> : Please help me to do so by explaining exactly what it is about Tom
> : Phoenix's posts that you'd change.  Do you not think it's appropriate
> 
> It's unfortunate that people read the posting as an attack on Tom's
> character, which it was not.  On one hand, people cannot be honest
> with themselves about the lack of content or depth in a pre-canned
> response, and apparently they cannot be convinced otherwise.  On the
> other hand, Tom is quite personable and largely unflappable.
> 
> It's unfortunate that both methods seem bound for failure:
> (1) usage of cluebats.  People get upset.  People throw mud at
>     "l33ts".  etc etc etc.  No new tale here.
> (2) answering questions en masse with the cut and paste method.
>     Most people won't read FAQs or lengthy pre-canned postings.  Too
>     much of too little cluttlers up the joint.  Most people seem not
>     to return if they're ignored.
> 
> : Do you not think it's appropriate to send people to an on-topic
> : newsgroup for discussion of things that are off-topic for this one?
> It's better to say nothing most of the time: at least these days.

ill drink to that.

> In other words, no *literate* person should be so fucked that they are
> unable to grep, grope, surf, archie, hack, test, peruse, read,
> memorize, or think in a way reasonable enough to (1) formulate an
> intelligent and thoughtful question and (2) discover background
> information which is related to what they're hoping to achieve.  And
> it just doesn't seem logical that people are failing in BOTH areas in
> this so-called "information age".

literate would be the key word here. and lazy. nature follows the path
of least resistance. why think when someone can do it for you? this is a
major flaw i see in so many people entering into this profession. i like
toms responses because he begs a question from a question much in the
socratic way. a little thought goes a long way to draw you down the path
of enlightenment and edification. 

> It's better to say nothing and get people to research things in other
> ways.

tell that to a jesuit. :) 

e.


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

Date: Wed, 02 Sep 1998 15:39:54 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Tom Phoenix: ANSWERS WANTED!
Message-Id: <35ED6476.D80083FC@bbnplanet.com>

> Only Hitler-types think they can end a thread
> by simply declaring it ended.

hmmm...well, i am half german and love leather boots. does that count?
;) don't bandy that name about so casually. 

i merely meant that the thread had grown tiresome.

e.


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

Date: Wed, 02 Sep 1998 15:19:26 GMT
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: We don't need no stinking benchmarks (was Re: Newbie RE Question)
Message-Id: <6sjmtd$1l$1@rand.dimensional.com>

[posted to comp.lang.perl.misc and mailed to the cited author]

In article <6sjlp6$dfj$1@monet.op.net>
mjd@op.net (Mark-Jason Dominus) wrote:

>I am going to make a bold prediction now.  With ten years, we are
>going to discover that the kind of performance typically measured by
>these `benchmark' tests is irrelevant to the real performance of real
>Perl programs, and in fact is exactly the sort of micro-optimization
>that everyone already says you should avoid.

Amen to that! :-)

Seriously, folks, who cares if (to use Greg's example)
index is 100% slower than the equivalent regular
expression.  Even in that example you only lost _3 seconds_
on 80,000 iterations.  Let's see, that's roughly 1/27,000
of a second per iteration in speed difference.  It may be
just me, but that hardly seems worth the effort it always
incites in the group.

Not to mention the fact that there have been instances where
the Benchmark module has been shown to produce inaccurate
results due to optimizations in the perl compiler (search
for `The Devil's Work' in the p5p archive).

If your program is too slow you are much better off 
reevaluating it and making fundamental algorithmic changes
than you are micro-optimizing the performance of your
regular expressions.  You'll see far greater performance
benefits through algorithmic improvements than any number of 
1/27,000 of a second speedups are going to produce.

dgris
-- 
Daniel Grisinger           dgris@perrin.dimensional.com
`Train of thought derailed.  7 dead, film at 11.'


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

Date: Wed, 02 Sep 1998 10:16:33 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Where to get Net/Domain.pm?
Message-Id: <fl_aggie-0209981016330001@aggie.coaps.fsu.edu>

In article <35ED2E67.642D@gianni.com>, 8\(F&@ <versace@gianni.com> wrote:

+ The error is "Can't locate Net/Domain.pm".  I've tried to find it at
+ CPAN but the web page said Net/Domain.pm should be included in libnet
+ and I don't have libnet either.

Perhaps you should consider installing the libnet package first?

James


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

Date: Tue, 01 Sep 1998 11:15:32 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Why Perl ?
Message-Id: <35EC0F94.6DFC7291@min.net>

dn5006@my-dejanews.com wrote:
> 
> Try the following script:
> 
> #!/usr/bin/perl
> print ":-) ";
> while (<>) { print eval; print ( ($@ || "\n") . ":-)" ) }

To this you should add "use Shell;".
Here's my hack of the above code:

  use Shell;
  $IPERL::l=1;
  while (
    print("$IPERL::l> "),
    defined($_=<>)
  ) {
    print eval;
    print ($@ || "\n");
    $IPERL::l++;
  }

Then you can say things like:

1> &who
2> ls('-l')

Now all we need is csh-like history recall/editing.

-- 
John Porter


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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


------------------------------
End of Perl-Users Digest V8 Issue 3618
**************************************

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