[16433] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3845 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 29 18:05:25 2000

Date: Sat, 29 Jul 2000 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: <964908309-v9-i3845@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 29 Jul 2000     Volume: 9 Number: 3845

Today's topics:
    Re: Apology to perl newsgroup (Craig Berry)
        Data Editing <psychoNOpsSPAM@pcpatches.com.invalid>
    Re: Differences between two files? <iltzu@sci.invalid>
    Re: Differences between two files? <bart.lateur@skynet.be>
    Re: ecologically printed perldocs <flavell@mail.cern.ch>
    Re: Help with param method in CGI.pm <mn@chello.at>
    Re: Help with param method in CGI.pm <uri@sysarch.com>
    Re: I Am An Idiot <lr@hpl.hp.com>
    Re: I Am An Idiot <godzilla@stomp.stomp.tokyo>
    Re: I Am An Idiot <dave@dave.org.uk>
    Re: I Am An Idiot <godzilla@stomp.stomp.tokyo>
    Re: I Am An Idiot <dave@dave.org.uk>
    Re: I Am An Idiot <collin@crosslink.net>
    Re: I Am An Idiot <dave@dave.org.uk>
    Re: Is "exit()" really necessary? <bart.lateur@skynet.be>
        perl reference on nt server <tommclean@mindspring.com>
    Re: Programmer - PERL - JAVA - JS - HTML - DreavWeaver <hyagillot@tesco.net>
        Removing all HTML tags from a String aaron@preation.com
    Re: return value of `eval "use lib"' <sumus@aut.dk>
        Sockets <ztinky@linux.nu>
    Re: Sockets (Steve Leibel)
    Re: strip from character to end of string <lr@hpl.hp.com>
        taint checking with perlis/perlex <gboyle@sympatico.ca>
    Re: Wraping file with XML code <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 29 Jul 2000 20:16:47 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Apology to perl newsgroup
Message-Id: <so6etfc7o0b161@corp.supernews.com>

Bart Lateur (bart.lateur@skynet.be) wrote:
: Lauren Smith wrote:
: >>  Also, could anyone please tell me what
: >> a killfile is?
: 
: >It's a system that filters out selected induhviduals. 
: 
: Funny misspelling.

Thank Scott Adams ("Dilbert" creator).

-- 
   |   Craig Berry - http://www.cinenet.net/users/cberry/home.html
 --*--  "Turning and turning in the widening gyre
   |   The falcon cannot hear the falconer." - Yeats, "The Second Coming"


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

Date: Sat, 29 Jul 2000 14:16:22 -0700
From: psycho <psychoNOpsSPAM@pcpatches.com.invalid>
Subject: Data Editing
Message-Id: <00f344d0.a47a73d9@usw-ex0104-028.remarq.com>

i've posted something like this before i need to be able to open
a file and edit the data thats in the file i've found some
source code it's from cgi101.com.

#!/usr/bin/perl
print "Content-type:text/html\n\n";
srand(time() ^ ($$ + ($$ << 15)) );

open(INF,"addata.txt");
@grok = <INF>;
close(INF);

@vads = ();

foreach $i (@grok) {
    # added this line in case the file has a blank line in it
    if ($i eq "") {
	next;			# skip to the next loop iteration
    }
    chomp($i);
    ($id,$gif,$url,$alt,$max,$count) = split(/\|/,$i);
    if ($count < $max) {
	push(@vads,$i);
    }
}

$rid = int(rand(@vads));

if ($rid < 0) {
    # there's been some problem.  Abort.
    exit;
}

$ad = $vads[$rid];
($id,$gif,$url,$alt,$max,$count) = split(/\|/,$ad);
print qq(<a href="$url"><img src="$gif" alt="$alt"></a>\n);

$count = $count + 1;

open(INF,">addata.txt");
flock(INF,2);
seek(INF,0,0);
foreach $i (@grok) {
    chomp($i);
    if ($i eq $ad) {
	print INF "$id|$gif|$url|$alt|$max|$count\n";
    } else {
	print INF "$i\n";
    }
}
close(INF);


is there an simpler way to do this?


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

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



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

Date: 29 Jul 2000 21:23:58 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Differences between two files?
Message-Id: <964905603.25776@itz.pp.sci.fi>

In article <hvu5osocd99716gatri34t9jbqbs1pvca5@4ax.com>, Bart Lateur wrote:
>It may not be that simple. For example, I can imagine that some parts of
>the files are of different length, so that all bytes in one file may be
>shifted inside the file, when compared to the other file.

The OP said they had the same length, and Larry's solution works just
fine in that case.  If deletions or insertions are possible, the best
approach would be to split the files into character arrays and apply
Algorithm::Diff to those.  Takes more memory, though.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Sat, 29 Jul 2000 21:41:56 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Differences between two files?
Message-Id: <foj6osc3ghls5k3946du5qn2ps0aiiik7t@4ax.com>

Larry Rosler wrote:

>Furthermore, as you imply, if the strings happen to have different 
>length, every byte in the longer string will count as a mismatch, which 
>is appropriate, except for the pathological null bytes that probably 
>wouldn't be there in text files in any case.  The example files may well 
>be binary, though, judging by their suffixes.

If, as you say, the files are text files, your approach will work. But
I'd look at diff first.

However, the OP wrote:

>My real problem is that I have two directories of release software
>(different versions). The software is serial number stamped to make a
>matched set. Some files are stamped and some are not.

It could be just me, but "software" sounds like binary files to me.

>The software is serial number stamped

Again, that sounds like binary file to me.

I wonder why he doesn't just extract the version number.

-- 
	Bart.


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

Date: Sat, 29 Jul 2000 20:24:50 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: ecologically printed perldocs
Message-Id: <Pine.GHP.4.21.0007292006260.9706-100000@hpplus03.cern.ch>

On Sat, 29 Jul 2000, Larry Rosler wrote:

> > > ZCZC
> > 
> > Good heavens!  I haven't seen that used since half a lifetime.
> 
> So what does it mean? 

Actually, thinking-back that half a lifetime, I now realise I should
have been surprised to see it at the _end_ of the posting.

It's an old teleprinter convention, ZCZC = start of message, NNNN =
end of message.

(Oh well, it _might_ all be some bizarre coincidence, I suppose.)

A web search reveals a reference to these usages at:

http://www.blueboxmoon.com/bluebook/7_1_06.txt

(which however their idiot web server claims is a text/html
file, which it isn't - it's plain text).




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

Date: Sat, 29 Jul 2000 18:17:00 GMT
From: "Niederkircher" <mn@chello.at>
Subject: Re: Help with param method in CGI.pm
Message-Id: <wcFg5.8505$NS3.773610@news.chello.at>

try this:
print OUTF <<EOF;  # print until the word EOF
$p_name = param('name');
$p_email = param('email');
$p_news = param('news');
EOF # end printing

Simon


"DS" <snakeman@kc.rr.com> wrote in message
news:dABg5.16439$t%4.142605@typhoon.kc.rr.com...
> Hello-
>      I am having difficulty with getting the param method in CGI.pm to
work
> in a certain instance. For instance I am trying to write these param to
file
> but it writes the param name such as param("email) instead of the value
> itself. I have got it to work by using the following but I felt I was just
> riggin it to work and would like to know the right way if so.  Thanx
>
>  open OUTF,">>$datfile"  or die "Couldn't open $datfile for writing: $!";
>  my $p_name = param('name');
>  my $p_email = param('email');
>  my $p_news = param('news');
>
>
>  flock(OUTF,2);
>  seek(OUTF,0,2);
>
>
>  print OUTF "$date|$p_name|$p_email|$p_news\n";
>  close(OUTF);
>
> Dirk
>
>




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

Date: Sat, 29 Jul 2000 19:04:14 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Help with param method in CGI.pm
Message-Id: <x7u2d84v2q.fsf@home.sysarch.com>

>>>>> "N" == Niederkircher  <mn@chello.at> writes:

  N> try this:
  N> print OUTF <<EOF;  # print until the word EOF
  N> $p_name = param('name');
  N> $p_email = param('email');
  N> $p_news = param('news');
  N> EOF # end printing

BZZT! thanx for playing. please try again.

sub calls are not interpolated in here docs which normally behave like
double quoted strings.

and the here doc must end with the closing token at the beginning of the
line all by itself. the comment broke that.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 29 Jul 2000 11:21:32 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: I Am An Idiot
Message-Id: <MPG.13ecc08917757a5898ac0d@nntp.hpl.hp.com>

In article <8luqlb$fnu$1@orpheus.gellyfish.com>, gellyfish@gellyfish.com 
says...
> On Sat, 29 Jul 2000 11:56:14 GMT Tim Kosmider wrote:
> > There are many ways, depends on the kinds of data you are reading.
> > 
> > open (FILE, "myfile.txt");
> 
> You will want to check the success of this open and report the reasons
> for any failure :
> 
>   open(FILE,'myfile.txt') || die "Could'nt open 'myfile.txt' : $!\n";

Godzilla! directed its wrath against Dave Cross for the generic use of 
'die' to handle the error condition, implying that we all thought that 
was always the required action.  The important thing is to check and 
take appropriate action for the circumstances.

 ...

> >     @flds = split(","); #create array from input line, separate line at
> 
> the first argument to split() is a regular expression - it is probably
> less confusing to the beginner to make that explicit ( split /,/ ).

I have been arguing that any use of a literal string (other than the 
magic " ") should draw a warning.  That would help catch the ubiquitous 
'|' error. Perhaps in Perl 6 it should be a fatal compile-time error!

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sat, 29 Jul 2000 11:37:28 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: I Am An Idiot
Message-Id: <39832468.ABEA4141@stomp.stomp.tokyo>

Larry Rosler wrote:
 
> gellyfish wrote:
> >  Tim Kosmider wrote:

> > > There are many ways, depends on the kinds of data 
> > > you are reading.

> > > open (FILE, "myfile.txt");

> > You will want to check the success of this open and report
> > the reasons for any failure :

> >   open(FILE,'myfile.txt') || die "Could'nt open 'myfile.txt' : $!\n";
 
> Godzilla! directed its wrath against Dave Cross for the generic
> use of 'die' to handle the error condition, implying that we all
> thought that was always the required action.  The important thing
> is to check and take appropriate action for the circumstances.



Well, well. You boys are beginning to learn
some Effective Perl Programming, thanks to
my hard efforts in educating the Perl unaware.

* spits fire *

Godzilla!

--
I will monster rock you.
http://la.znet.com/~callgirl5/werewolf.mid


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

Date: Sat, 29 Jul 2000 19:53:08 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: I Am An Idiot
Message-Id: <pq96os8tem3bpfmrpnie0hn3bejjj9jq8m@4ax.com>

On Sat, 29 Jul 2000 11:21:32 -0700, Larry Rosler <lr@hpl.hp.com>
wrote:

>Godzilla! directed its wrath against Dave Cross for the generic use of 
>'die' to handle the error condition, 

When, in fact, what I said was that you should always check the return
value from open. Admittedly I used die in my example, but that was
because it _was_ the best action for the sample script.

>                                     implying that we all thought that 
>was always the required action.  The important thing is to check and 
>take appropriate action for the circumstances.

Absolutely. And in her counter example does she check the return from
open?

Dave...

-- 
<http://www.dave.org.uk>  SMS: sms@dave.org.uk
yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>

"There ain't half been some clever bastards" - Ian Dury [RIP]


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

Date: Sat, 29 Jul 2000 12:26:23 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: I Am An Idiot
Message-Id: <39832FDF.711B9944@stomp.stomp.tokyo>

Dave Cross wrote:
 
> Larry Rosler wrote:

> >Godzilla! directed its wrath against Dave Cross for the
> > generic use of 'die' to handle the error condition,
 
> When, in fact, what I said was that you should always 
> check the return value from open. Admittedly I used die
> in my example, but that was because it _was_ the best 
> action for the sample script.


This statement is in direct contradiction of your
previous statement, paraphrased,  "... _always_ use die."
However, your statement shows a bit more wisdom through
implication use of die may not always be the best choice.


> > implying that we all thought that was always the required
> > action. The important thing is to check and take appropriate
> >  action for  the circumstances.

> Absolutely. And in her counter example does she check the return
> from open?


Just as I thought; dogmatic || die.

Take this home with you for study and hopefully, comprehension.
Perhaps Rosler and Stowe can help you on this. Between the three
of you, my hopes are you boys can figure out what this snippet
of code does; allows a program to successfully run and complete
despite two possible open failures, actually more open failures
than this as there are other read / write attempts later.

Point is, I write programs which compensate for errors,
continue to successfully run, where you boys would
give up and kill your program. Suppose this is a marked
difference between real women and, real men; we women
don't surrender easily, if ever.


      open (POKERLOG, "+<$poker_log");
      $read_poker = <POKERLOG>;
      close (POKERLOG);

      if (!($read_poker))
       {
        open (POKERLOG2, ">$poker_log");
        print POKERLOG2 "500";
        close (POKERLOG2);
        $player_cash = "500";
       }
      if ($read_poker)
       { $player_cash = $read_poker; }



* spits more fire *

Godzilla!

-- 
$godzilla = "godzilla rocks!";
srand(time() ^ ($$ + ($$ << 15))); 
sub randcase
 { rand(40) < 20 ? "\u$1" : "\l$1" ; }
$godzilla =~  s/([a-z])/randcase($1)/gie;
print $godzilla; exit;


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

Date: Sat, 29 Jul 2000 22:11:06 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: I Am An Idiot
Message-Id: <vvh6osotep7ssu197p5djge6ucatbqaq5k@4ax.com>

On Sat, 29 Jul 2000 12:26:23 -0700, "Godzilla!"
<godzilla@stomp.stomp.tokyo> wrote:

>Dave Cross wrote:
> 
>> Larry Rosler wrote:
>
>> >Godzilla! directed its wrath against Dave Cross for the
>> > generic use of 'die' to handle the error condition,
> 
>> When, in fact, what I said was that you should always 
>> check the return value from open. Admittedly I used die
>> in my example, but that was because it _was_ the best 
>> action for the sample script.
>
>
>This statement is in direct contradiction of your
>previous statement, paraphrased,  "... _always_ use die."

This is what I said (not paraphrased, cut and pasted directly from my
post).

"You should _always_ check the return value from a call to open."

How is that in cntradiction with what you quoted me saying above?

Who's lying now Kira?

Dave...

-- 
<http://www.dave.org.uk>  SMS: sms@dave.org.uk
yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>

"There ain't half been some clever bastards" - Ian Dury [RIP]


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

Date: Sat, 29 Jul 2000 17:06:43 -0400
From: "Collin Borrlewyn" <collin@crosslink.net>
Subject: Re: I Am An Idiot
Message-Id: <964904952.324076@pizza.crosslink.net>

Ah, I thank you, this hits the spot.


--

-Collin E Borrlewyn
  -Half the fun and twice the vomit.
    -collin@crosslink.net

Jon Bell <jtbell@presby.edu> wrote in message news:FyGJ4I.2oE@presby.edu...
> In article <964868333.926550@pizza.crosslink.net>,
> Collin Borrlewyn <collin@crosslink.net> wrote:
> > [...] can someone tell me how to get the contents of a
> >file into an interact-able form, such as a variable? Something to do with
> >open()? read()? The documentation isn't prescise, and nothing I have
tried
> >has worked.
>
> The documentation that comes with Perl is rather precise; it's simply
> meant as a reference, not as a tutorial.  But you can easily find what
> you need with a Web search engine.
>
> Go to http://google.com/ and enter "Perl read file variable" into the
> search box.  The very first hit is titled "Learn Perl -- Read files with
> Perl".  The third one (obviously part of a larger tutorial) is "Chapter 9
> -- Using Files".  Etc.
>
> --
> Jon Bell <jtbell@presby.edu>                        Presbyterian College
> Dept. of Physics and Computer Science        Clinton, South Carolina USA
> [ Questions about newsgroups?  Visit http://www.geocities.com/nnqweb/  ]
> [                or ask in news:news.newusers.questions                ]




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

Date: Sat, 29 Jul 2000 22:25:45 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: I Am An Idiot
Message-Id: <9di6osod5baqmdb3q3tu0fq3ls4h4rgbgl@4ax.com>


Let's step back for a second and try actually reach a consensus on
what we're discussing. The question before us seems to be "what
additional actions should you take when opening a file?" Seems to me
that there are four options:

1/ Always check the return from the open and _always_ die.
You won't find that anyone has actually advocated this option,
although the fact that both Jonathan Stowe and me both used die in our
examples could be misconstrued as us advocating this action. I know
that I don't and I'm pretty sure that Jonathan doesn't either.

2/ Always check the return value and take _appropriate_ action. This
may involve dying or it may involve logging an error and simply moving
on. This is the option that Larry Rosler suggested. It's also what I
would advocate and (reading his mind) I'm sure that Jonathan would
agree with us.

3/ _Sometimes_ it's ok to not even check the return value from open.
Reading her example code, this seems to be what Kira advocates, but
she has yet to explain under what circumstances she believes this is a
valid course of action.

4/ _Never_ check the return value from open. 
This is clearly very silly and I don't believe that any of us are
advocating this option.

Does that sound like a reasonable summary to everyone? If not, perhaps
you could point out the errors in a calm manner without resorting to
insults.

hth,

Dave...

-- 
<http://www.dave.org.uk>  SMS: sms@dave.org.uk
yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>

"There ain't half been some clever bastards" - Ian Dury [RIP]


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

Date: Sat, 29 Jul 2000 20:57:02 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Is "exit()" really necessary?
Message-Id: <m4h6os0h03n856au86luuqoidjuat44v77@4ax.com>

BUCK NAKED1 wrote:

>So, I don't think that exit() is needed at the end of every Perl script
>written. Who is correct? 

IMO: you.

I try to avoid exit() as much as possible. If I ever need it inside a
sub, I tend to consider this a defeat. So I'll try to get rid of it.

p.s. Nothing wrong wit hquick-and-dirty scripts, or with not using "use
strict;". The latter is only desirable (not "necessary") in larger
scripts.

-- 
	Bart.


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

Date: Sat, 29 Jul 2000 14:29:33 -0400
From: "Tom McLean" <tommclean@mindspring.com>
Subject: perl reference on nt server
Message-Id: <8lv7h7$rqr$1@slb6.atl.mindspring.net>

I am trying to execute a script on an nt webserver that has the interpreter
installed in the ntreskit directory.  No matter how I try to reference the
script I get the error.

%1 is not a valid Windows NT application

the script executes on mindsprings servers.

How do i change the first line of code to reflect the interpreter location

Help

Tom






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

Date: Sat, 29 Jul 2000 22:39:11 +0100
From: "B Kemp" <hyagillot@tesco.net>
Subject: Re: Programmer - PERL - JAVA - JS - HTML - DreavWeaver
Message-Id: <8lvj5k$l0e$1@barcode.tesco.net>


Dave Cross wrote in message <7646oss1p901htejlvcu206qqns07vf7o0@4ax.com>...
>On Sat, 29 Jul 2000 17:04:40 GMT,
>TeleComMuter@WeBProgrammersInternational.net wrote:
>
>[a job advert]
>
>use dha::Job::Posting::Rant qw(:standard);


I really think its time that there was a revision on the above
something like

use dha::Job::Posting::Rant qw(:pXXX_off);


>"There ain't half been some clever bastards" - Ian Dury [RIP]

Attracted to post gratuitously for the first?? time by the above.
That song contains a fine analysis of relativity theory. nice.




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

Date: Sat, 29 Jul 2000 20:39:05 GMT
From: aaron@preation.com
Subject: Removing all HTML tags from a String
Message-Id: <8lvfd9$rhd$1@nnrp1.deja.com>



I am attempting to remove every HTML tag from a large string which is
made up of all the lines of an HTML page. My goal is to create plain
text which I can put into a sort of search engine page as a
representation of the content of that page for a PERL site search
engine.

I have been trying to use Regex code to deal with this problem by
something like this:

$desc =~ s/(<?*>)//g;

Yet I don't have a good understanding of regex and I understand that the
code I am using above is not valid. It was my understanding that the ?
would take any character, and the * would allow for as many of them as
needed until it finds the > to end the match. But this doesn't work. Can
anyone advise what I should do, where can I find this code. I tryed the
PERLFAQ many times but can't find it anywhere.

Also, although I put in this line of code ($desc =~ s/\n//g;) to the
string with all of the page code in it, I still end up with carriage
returns when I print the string to a simple text file. Why won't this
get rid of those line returns?

Thanks for any advice you can provide to these frustrating problems.
Aaron H.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 29 Jul 2000 22:49:45 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: return value of `eval "use lib"'
Message-Id: <wvi4irva.fsf@macforce.sumus.dk>

Bart Lateur <bart.lateur@skynet.be> writes:

> Use the source, Luke.

Thanks Obi W :-)

> "use lib" will die if you pass it an empty string,
> or a file name instead of a directory.

I see - and the error message I get is:

    Parameter to use lib must be directory, not file at .....
                 ^^^

Even when my code uses require/import. The lib.pm assumes that it's being
used and not reqired.

Well now I'm a little more clever with regards to _how_ things work. But
there's still some _why_s. It still beats me why nonexistant directories
are accepted. The only reason I can think of is that you might create
the directory, copy some file to it and then require that file. But then
you could also unlink a file, create a directory with the same name
and etc...

> But that happens inside "import", so require+import should die as well.

And of course it does. Apparently some of my initial tests were broken.

-- 
Jakob


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

Date: Sat, 29 Jul 2000 22:43:11 +0200
From: "Johan" <ztinky@linux.nu>
Subject: Sockets
Message-Id: <AkHg5.21703$rH5.50972@nntpserver.swip.net>

If I want to watch socket 'SOCK' and 'SOCK2' for "messages".

I can NOT write like this:

while (<SOCK>) {
    # process socket
}

Because then Perl will stop at the while-loop and only execute it if SOCK
containts any data. If it doesn't contain data it continues to "sleep" until
there's data on the socket, with other words: anything below it won't get
executed.
If you tell me to include modules to fix it, then _please please_ also give
me an example which shows how to read from the sockets.
Please, please help me!




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

Date: Sat, 29 Jul 2000 14:08:43 -0700
From: stevel@bluetuna.com (Steve Leibel)
Subject: Re: Sockets
Message-Id: <stevel-2907001408430001@192.168.100.2>

In article <AkHg5.21703$rH5.50972@nntpserver.swip.net>, "Johan"
<ztinky@linux.nu> wrote:

> If I want to watch socket 'SOCK' and 'SOCK2' for "messages".
> 
> I can NOT write like this:
> 
> while (<SOCK>) {
>     # process socket
> }
> 
> Because then Perl will stop at the while-loop and only execute it if SOCK
> containts any data. If it doesn't contain data it continues to "sleep" until
> there's data on the socket, with other words: anything below it won't get
> executed.
> If you tell me to include modules to fix it, then _please please_ also give
> me an example which shows how to read from the sockets.
> Please, please help me!


You need to use select() to wait for input on any number of sockets.  

Take a look at 

% man select 

which gives you the Unix info about the select() function.

Then look up select() in the Perl documentation.

After that, if you are modularly inclined, you can use IO::Select to make
everything a little more convenient.

The basic idea is that instead of reading a particular socket, you specify
which sockets you are interested in reading.  Then you call select() to
wait for any of those sockets to become ready.  When select() completes
and tells you one or more sockets have input, you THEN read the socket. 
That way you never wait on a socket.  You already know there's data
waiting before you read it.

Steve L


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

Date: Sat, 29 Jul 2000 11:00:39 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: strip from character to end of string
Message-Id: <MPG.13ecbb9a44e92d3b98ac0c@nntp.hpl.hp.com>

In article <8ltpo9$lin@junior.apk.net>, catfood@apk.net says...
> In article <Pine.LNX.4.10.10007282231210.28023-100000@fnord.io.com>,
> Robert Campbell  <poohba@io.com> wrote:
> >how do i strip a variable from a character to the end of that string.
> >
> >$image =~ s/"from the '-' to the end of the file name"//g;
> >
> >All of the files used look like this. THISFILE-athome1.jpg.  I want $image
> >to only be THISFILE.  How do i accomplish this?
> 
> $image =~ s/-.*$//g;

Neither the '$' nor the '/g' accomplish anything.  A '/s' might be 
useful, though.

Another approach to this problem uses split().  But as I noted in a 
similar thread yesterday, the most efficient solution uses substr() and 
either index() or rindex().  However, it requires more keystrokes.  :-(

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sat, 29 Jul 2000 14:51:38 -0400
From: Grant Boyle <gboyle@sympatico.ca>
Subject: taint checking with perlis/perlex
Message-Id: <972097A1F1360AB1.5CD40BCFE202CF9E.C0968634F952A71B@lp.airnews.net>


I've got a CGI script I'm working on that is written for use with
taint checking. I can run the script with taint checking under Apache
on OpenBSD already.

Unfortunately I haven't been able to figure out how to enable taint
checking when using perl for ISAPI (perlis.dll) under NT4/IIS4. I
tried the -T switch on a #! line but that just gave the usual 'too
late' message. I did some searching on the net but came up empty.

Any ideas?

-- Grant


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

All Nature is but art, unknown to thee,
All chance direction which thou can'st not see;
All discord harmony, not understood,
All partial evil universal good,
And in spite of pride in erring Reason's spite,
One Truth is clear, whatever is is right.


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

Date: Sat, 29 Jul 2000 21:37:34 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Wraping file with XML code
Message-Id: <ngj6os8ncmgite1587hhjmtoqq75jhlde7@4ax.com>

Sasa Danicic wrote:

>How can I wrap a binary file with an envelope, in fact how can I read
>the file first and at last add some XML-ish string at the beggining of
>the file?

Be careful that your binary file doesn't accidently prematurely includes
a closing tag. Whatever you do, including a random bianry file inside an
XML file sounds like a bad idea to me.


-- 
	Bart.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


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


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