[10321] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3914 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 7 09:07:18 1998

Date: Wed, 7 Oct 98 06:00:21 -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, 7 Oct 1998     Volume: 8 Number: 3914

Today's topics:
    Re: (PERL vs VisualBasic) and (PERL with VisualBasic) C <daveclark@prodigy.net>
    Re: =?ISO-8859-1?Q?Portugu=EAs?= (Steffen Beyer)
    Re: Any clues for dealing with serial lines (timeouts)? <howel88@cyberway.com.sg>
    Re: Are there any "perl.newbie" group or forum? (Michael J Gebis)
        Bug in open(FH,"| script") ? <ehsmatt@ehpt.com>
    Re: comp.lang.perl.win32?? <jimbo@soundimages.co.uk>
        Compilation error (vers. 5.004_04) <weitz@goya.informatik.rwth-aachen.de>
    Re: Data Search Question <erhmiru@erh.ericsson.se>
        DBM multiuser <adank@statoil.com>
        Finding the basedir <rikard.sjostrom@swipnet.se>
    Re: Help with Here Document <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: How do I force perl to deallocate hash tables? <howel88@cyberway.com.sg>
        How to delete files with PERL (answer) <info@edoc.co.za>
        How to get a particular string in a file ? <Nicolas.Tual@iuplo.univ-ubs.fr>
    Re: How to match exactly x occurrences of a character <erhmiru@erh.ericsson.se>
    Re: How to open a command that pipes both in and out ?? <erhmiru@erh.ericsson.se>
    Re: How to pass a hash array to a sub program huntersean@hotmail.com
    Re: IDE for Perl <anthony.clark@adv.sonybpe.com>
        missing value after unpack from socket <johnvun@asiapac.net>
    Re: Perl as a dumb terminal <howel88@cyberway.com.sg>
        PERL5.005_002 Solaris2.6 - Files missing  <krithikp@hotmail.com>
    Re: Problems Using a Compare Subroutine with Sort <erhmiru@erh.ericsson.se>
    Re: Problems Using a Compare Subroutine with Sort droby@copyright.com
    Re: Problems Using a Compare Subroutine with Sort droby@copyright.com
    Re: Q: Speed up a regular expression (Larry Rosler)
        Reading all lines from datafile <info@edoc.co.za>
    Re: Reading all lines from datafile <howel88@cyberway.com.sg>
    Re: What's is wrong here? <howel88@cyberway.com.sg>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 07 Oct 1998 06:46:55 -0400
From: Dave Clark <daveclark@prodigy.net>
Subject: Re: (PERL vs VisualBasic) and (PERL with VisualBasic) Can it be done??
Message-Id: <361B469F.19E@prodigy.net>

Guy Doucet wrote:
> 
 ...
> 
> I don't know much about PERL itself, but... Is there a way to submit
> data to a PERL app from an EXE, and can it return data back to the EXE.

    backtick works on win95.  Try:

   @mydir = `DIR`;

   
@mydir will have the dir listing.
   
Executing window style apps my pose a problem... at least finding out
how to do it.  

Dave Clark


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

Date: 7 Oct 1998 07:32:13 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: =?ISO-8859-1?Q?Portugu=EAs?=
Message-Id: <6vf5dt$i4u$1@en1.engelschall.com>

Commitman <commitman@digitalnet.com.br> wrote:

> Quem fala portugujs por aqui, favor dar um reply nesta mensagem, ss pra
> gente saber !!! Obrigado !

E eu vou ganhar o que^ se eu fizer?! :-)

Tiao,
-- 
    Steffen Beyer <sb@engelschall.com>
    Free Perl and C Software for Download: www.engelschall.com/u/sb/download/


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

Date: Wed, 7 Oct 1998 19:49:13 +0800
From: "Xu Hongwei" <howel88@cyberway.com.sg>
Subject: Re: Any clues for dealing with serial lines (timeouts)??
Message-Id: <361b5575.0@news.cyberway.com.sg>

You may need select



Tom Watson wrote in message <361AAC08.2202D5F8@metricom.com>...
>In using the POSIX module I'm trying to get some (yuck) Windoze module
>converted to unix.  Everything is going along quite well, except for the
>timeouts.  Basically what I desire to do is read the serial port (I'm
>dealing with a modem) until a specific response comes along, or a
>timeout happens.
>
>POSIX has timeouts in Termios, but not as convient as I'd like them.  Is
>there a solution for my tale of woe??
>
>
>Thanks.
>--
>Tom Watson             I'm at work now (Generic short signature)
>twatson@metricom.com   (Home:tsw@johana.com)




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

Date: 7 Oct 1998 06:54:57 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <6vf381$6fk@mozo.cc.purdue.edu>

madame philosophe <mp@mkt2mkt.com> writes:
}If the people at this group are tired of hearing the same questions.. why
}doesn't someone start a newbie perl newsgroup?

You've made a common mistake.  People don't flame you because they
want you to leave; hell, it's GREAT fun to flame somebody, and if you
leave, you spoil the fun.  In fact, getting flamed isn't even what really
annoys you!  

What does annoy you is that nobody sticks up for you after you get
unfairly flamed.  It's actually great fun to get flamed and
then have loads of folks stick up for you.  Unfortunately, years of
trivial questions, off-topic posts (and if you haven't noticed yet,
I'm quite off-topic), and pointless repetition have left most people
desensitized and vaguely resentful of the same old story.

Imagine the town bar from your favorite post-apocalypse,
end-of-the-world, mid-80's sci-fi movie.  _Solarbabies_ doesn't
count.  The villagers in the movie aren't bad people, but they've seen
way too many visitors pop in, make a big mess, and leave without so much
as a contribution to the town water bank.  Now you show up.  If you waltz
in like the young Luke Skywalker, nobody will want anything to
do with you.  Unless, of course, they need somebody to tease.

Take my advice:  Be Obi-Wan.  Be Han Solo, or Chewie, or Greedo.
Heck, you can even be a member of the band.  Just don't be Luke.
He's a dork.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Wed, 07 Oct 1998 14:33:37 +0200
From: Mattias Petersson EHS/SKA 62067 <ehsmatt@ehpt.com>
Subject: Bug in open(FH,"| script") ?
Message-Id: <361B5FA1.1FF82708@ehpt.com>

I think I have found a bug in the perl funciton open(FH,"| script").
My perl prg looks like this, where the script prgX is listening
on its STDIN.

#!/usr/bin/perl

open( FH1,"| prgX") or die("prgX not found\n");
select FH1; $|=1;
(print FH1 "OK\n") or die("filehandle not ready\n");


The fact is that if the script prgX doesn't exist, perl anyway
continues the execution.
When it comes to the  last line, it tries to print to a nonexisting 
filehandle resulting in that the perl prg dies before the dying message.

This must be a bug in Perl, right?

/Mattias Petersson

PS I've seen that open( FH1,"| prgX") always returns the process id of
prgX - even though it's non-existing.

--
Mattias Petersson
EHPT				 | phone: +46 (0) 31 7462067 
P.O. Box 333                     | fax:   +46 (0) 31 7462375
S-431 24 MOLNDAL,Sweden          | email:
ehsmatt@<nospam.please!>.ehpt.com


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

Date: 07 Oct 1998 09:16:53 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: comp.lang.perl.win32??
Message-Id: <u4stghjm2.fsf@jimbosntserver.soundimages.co.uk>

cberry@cinenet.net (Craig Berry) writes:

> : 
> : There are several perl issues that would be of interest only to those doing
> : win32 perl programming and not to the rest of the perl community.
> 
> Examples?  And why win32 as opposed to any other particular architecture
> or OS? 
> 

Regarding the second point: The installed base. Unix people are not
particularly pleased with Bill and his products, and many of the
people beginning to use Perl are from his prison. As a result, there
is a high level of basic misunderstanding about what Perl is and does
relative to the experience and unserstanding of this particular
group. There is also a high degree of ignorance about Unix and the
tools philosophy and how that relates to Win32 users. Putting the
Win32 community into a targeted group would reduce the pointless
postings that often make their way into c.l.p.misc.

Other OS's may very well benefit from a targeted group. However, given
the volume of these groups combined, it would seem that each group
would be rather undersubscribed. Maybe not, but I suspect so. A win32
group would experience a high level of posting, perhaps on a par with
c.l.p.misc today.

Regarding the first point: It is very clear there are very significant
differences between Win32 users and the larger Perl community. The
existence of libwin32 highlights this. The accessibility of much of
the administration and configuration of a Win32 system from Perl
requires the use of libwin32. Not much interest in c.l.p.misc for that
in general. Putting these particular issues into their own realm would
be a relief to many of the readers of c.l.p.misc.

It would also give the win32 people a taste of their own ignorance
elixer.
-- 
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.


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

Date: Wed, 07 Oct 1998 14:48:48 +0200
From: Detlef Weitz <weitz@goya.informatik.rwth-aachen.de>
Subject: Compilation error (vers. 5.004_04)
Message-Id: <361B632F.44950A12@goya.informatik.rwth-aachen.de>

Hi !

Can anybody help me with followin message

Making x2p stuff
make[1]: Entering directory `/home/weitz/perl5.004_04/x2p'
makefile:137: *** missing separator.  Stop.
make[1]: Leaving directory `/home/weitz/perl5.004_04/x2p'
make: *** [translators] Error 2


--
+=================================================================+
|  Detlef Weitz  : (Lehrstuhl fuer Informatik V                   |
|                   RWTH Aachen / BSCW - Serverbetreuung)         |
|                                                                 |
|  email         : weitz@i5.informatik.rwth-aachen.de             |
|  phone         : +49-241-80-21512 ( ONLY if important )         |
|                : +49-241-80-21501 ( Sekr. )                     |
|  office        : R 6241 (Rechnerraum)                           |
|  postal address: RWTH Aachen                                    |
|                  Lehrstuhl Informatik V                         |
|                  Ahornstr.55                                    |
|                  52072 Aachen (Germany)                         |
+=================================================================+

thanx



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

Date: 07 Oct 1998 10:19:22 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
Subject: Re: Data Search Question
Message-Id: <lalnmsss1h.fsf@erh.ericsson.se>

Hello,

just a caution to John's solution. Larry wants to search 1000000 strings 10
characters long. That is about 10MB. John makes a local copy of this stuff
in his subroutine. That is another 10MB...

Michal

John Porter <jdporter@min.net> writes:
> Larry Rosler wrote:
> > 
> > The best I can do is an array and a linear search. 
> > I'd love to be shown a better way.
> 
> I'm certainly not suggesting this is a better way,
> but it's how I thought about the problem.
> The downside is it greps the list of words once for
> each character in the input word.
> 
> 
> sub best_match {
>   my $t = shift;
>   my @w = @_;
[...]
> my( $word, $letters ) = best_match (
>   'UQPALRIEOF',
>   qw(
>     JSUWIGKROD
>     KIWPLODGQF
>     WOQPLIFJSK
>     OQPALSNEUG
>     ISOPQKEOSP
>   )
> );
> print "Best match is '$word', with $letters letters.\n";
> 
> -- 
> John "Many Jars" Porter
> baby mother hospital scissors creature judgment butcher engineer


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

Date: Wed, 07 Oct 1998 10:02:01 +0200
From: "=?iso-8859-1?Q?Asbj=F8rn?= Dankertsen" <adank@statoil.com>
Subject: DBM multiuser
Message-Id: <361B1FF9.FF806D4E@statoil.com>

I have written an application which lets several users access a dbm
database. The do both reads and writes.

Every now and then data gets lost/destroyd. I think this happens when
two users writes to the same key in the dbm database at the same time.

Is there a way to lock a dbm file, so that only one user can write to
it? 

BTW. the server is a Linux box.

Regards,
Asbjorn Dankertsen


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

Date: Wed, 07 Oct 1998 10:18:46 +0200
From: "Rikard =?iso-8859-1?Q?Sj=F6str=F6m?=" <rikard.sjostrom@swipnet.se>
Subject: Finding the basedir
Message-Id: <361B23E4.939F66DB@swipnet.se>

I have a problem with finding the right basedir/basepath.

I have two searchscripts (perl). First one is named search.pl
second one is named better-searching.pl

According to the Unixserver (pwd public_html) the basepath
to my websait is
/import/user2/d58825

I tried this path in both searchscripts but it didn't work.
But search.pl works fine with
$basepath =3D '/import/user2/d58825/public_html/../';

The problem is that better-serach.pl is, as you understand,
much better than search.pl

Any suggestions how I should find the real basepath to my
homedirectory?

Many thanks in advance

Rikard Sj=F6str=F6m



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

Date: 06 Oct 1998 17:24:16 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Help with Here Document
Message-Id: <83emslu31b.fsf@vcpc.univie.ac.at>

Re: Help with Here Document, Andrew <ap85@cornell.edu> said:

Andrew>     Is it possible to use the "Here Document" method
Andrew> to print to a variable?

Yes.

Andrew> I have tried

Andrew> print TEXT<<end_of_text;
Andrew> Hello this is a atest
Andrew> end_of_text
Andrew> $words = <TEXT>;
Andrew> print $words;

Andrew> but I can't get this to work.  I am not even sure it
Andrew> is possible.

With perl, all things are possible.

You seem to have the idea that `here' documents can only be
used with filehandles.  However, you can do much more:

    $words = <<EOT;
    That hasn't got much spam in it
    EOT

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Wed, 7 Oct 1998 20:19:18 +0800
From: "Xu Hongwei" <howel88@cyberway.com.sg>
Subject: Re: How do I force perl to deallocate hash tables?
Message-Id: <361b5c82.0@news.cyberway.com.sg>

Does this work?

delete @HASH{keys %HASH}

Craig De Groot wrote in message <361A1DFA.3D0FE221@hdc.net>...
>I am trying to force perl to deallocate some hashes because I am running
>low on memory.  I tried using undef, but this merely removes the
>reference to the hash and does not allow me to reclaim the memory.  Is
>there any way for me to actually remove the hash from memory?
>




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

Date: Wed, 07 Oct 1998 11:48:06 +0200
From: Nico <info@edoc.co.za>
Subject: How to delete files with PERL (answer)
Message-Id: <361B38D6.7D9F@edoc.co.za>

Thanks to all that responded by E-Mail to my question.

If you do not know how to delete a file using PERL, 

do a perldoc -f unlink

Nico


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

Date: Wed, 07 Oct 1998 09:05:28 +0000
From: "Nicolas.Tual" <Nicolas.Tual@iuplo.univ-ubs.fr>
Subject: How to get a particular string in a file ?
Message-Id: <361B2ED8.AFE5543C@iuplo.univ-ubs.fr>

Hello,

I begin in the art of Perl.
I have to get a string from the following file :

/COM
/NOPR
NBLOCK, 6
(3.8,6e16.9)
	1	0	0.5	0.000000000004	0.000000000005
	2	0	0.4	0.000000000001  0.8

 ...

The string I want to get is (3.8,6e16.9) which depends on the file I'm
working on ( for example, it can be on line 4, 5, 6... or be (3.9...).
So, could you help me and tell me how to get this string ?

Thanks a lot.

Excuse my English, I'm french !
-- 

*******************************************
** mailto:Nicolas.Tual@iuplo.univ-ubs.fr **
*******************************************


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

Date: 07 Oct 1998 12:20:14 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
Subject: Re: How to match exactly x occurrences of a character
Message-Id: <lak92csmg1.fsf@erh.ericsson.se>

dragons@scescape.net (Matthew Bafford) writes:
[...]
> There's always lookahead and lookbehind...
> 
> (?<!a)(aa)(?!a)
> 
> Needs the latest and greatest Perl, though.

I am feeling like asking our admin to do the update work...

Michal

> 
> --Matthew


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

Date: 07 Oct 1998 14:43:00 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
Subject: Re: How to open a command that pipes both in and out ???
Message-Id: <laiuhwsfu3.fsf@erh.ericsson.se>

Jonathan Stowe <gellyfish@btinternet.com> writes:
[...]
> > You cannot do this with simple open. What you need is open2 or open3. See
> > derldoc open2 for further reference.
> > 
> That'll be IPC::Open2 or IPC::Open3 of course.

Eiher way is good. You can do perldoc open2, or perldoc IPC::Open2. But you
have to 'use' IPC::Open2 of course.

Michal



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

Date: Wed, 07 Oct 1998 07:31:55 GMT
From: huntersean@hotmail.com
Subject: Re: How to pass a hash array to a sub program
Message-Id: <6vf5db$430$1@nnrp1.dejanews.com>

In article <6vddju$fmu$1@statler.server.colt.net>,
  "Paul Makepeace" <Paul.Makepeace@POBox.com> wrote:
> [cancelled/reposted]
>
> huntersean@hotmail.com wrote in message <6vd1in$bvb$1@nnrp1.dejanews.com>...
> > sub print_hash
> > {
> >  print "Here is the hash array passed into the subprogram:\n";
> >  while (my ($key,$value) = each %{$_}) {print "$key=$value\n";}
> > }
>
> $_ doesn't have the first argument of a subroutine. @_ contains the
> arguments, so you want $_[0].
>

Enough about the typo already!  Mea culpa.  Mea maxima culpa.  I typed the
example wrong.  I've written enough perl over the last 4 years to know that @_
contains the arguments thank you very much.

Sean Hunter


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 7 Oct 1998 09:25:52 +0100 
From: Anthony Clark <anthony.clark@adv.sonybpe.com>
Subject: Re: IDE for Perl
Message-Id: <361B259C.CDC20C8D@adv.sonybpe.com>

Tom Christiansen wrote:

> :is there any IDE for un*x users ?
>
> Unix *is* Perl's IDE!

Um, Not very helpful...  Surely there must be SOMEONE out there that knows of a
class browser?

If not, there's obviously demand for this kind of feature in an IDE, whichever OS
it comes out for... (maybe write it in java and make it cross platform!)

Sorry for the sense of humour failure, but I have great trouble convincing C++/MS
advocates of the benefits of perl and OO helpers could only help

Anthony
--
/*
 * Anthony Clark,
 * Broadcast R&D,
 * Sony Broadcast and Professional Europe,
 * Jays Close, Viables, Basingstoke, UK.
 * RG22 4SB
 *
 * Tel: (+44) (1256) 483444 (direct)
 * Fax: (+44) (1256) 810950
 */




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

Date: Wed, 07 Oct 1998 15:50:19 +0800
From: johnvun <johnvun@asiapac.net>
Subject: missing value after unpack from socket
Message-Id: <361B1D3A.403BE4CE@asiapac.net>

Hi,

Below are my programs, name socket.cgi and socket.pl.  socket.cgi will
run and wait for socket.pl to send infor (2000, 32, 10, 11) back to
socket.cgi. But the problem is value 4 (11) ($var4) didn't print out
when both program stop.  On the screen only print out   "varue 1 is
2000, value 2 is 32, value 3 is 10,  value 4 is ". 11 is not printed
out,  Why ???

Please help.

johnvun

socket.cgi
MAIN:
{
  require "cgi-lib.pl";
  &ReadParse(*input);
  $input{'name'}    =~s/\, /\/ /g;
  print &PrintHeader;
  print "<html><head>\n";
  print "<title>Top Navi</title>\n";
  print "</head>\n";
  &receive_from_server;
  select STDOUT;
  print ("varue 1 is $var1, value 2 is $var2, value 3 is $var3,  value 4
is $var4<br>");
  print "<BODY>\n";
  print "</BODY>\n";
  print "</HTML>\n";
}

sub receive_from_server
{
 use Socket;
 $port = 2001;
 while (getservbyport ($port, "tcp"))
 {
  $port++;
 }
 ($d1, $d2, $prototype) = getprotobyname ("tcp");
 ($d1, $d2, $d3, $d4, $rawserver) = gethostbyname ("servername");
 $serveraddr = pack ("Sna4x8", AF_INET, $port, $rawserver);
 socket (S, AF_INET, SOCK_STREAM , $prototype) || die ("No socket");
 bind (S, $serveraddr) || die ("Can't bind");
 listen (S, 1) || die ("Can't listen");
 ($clientaddr = accept (S2, S)) || die ("Can't accept");
 $infor = <S2>;
 ($var1, $var2, $var3, $var4) = unpack("nnNN", $infor);
 close (S2);
 close (S);
}


socket.pl
MAIN:
{
use Socket;
$infor = pack('nnNN', 2000, 32, 10, 11);
$port = 2001;
while (getservbyport ($port, "tcp"))
{
        $port++;
}
($d1, $d2, $prototype) = getprotobyname ("tcp");
($d1, $d2, $d3, $d4, $rawclient) = gethostbyname ("servername");
($d1, $d2, $d3, $d4, $rawserver) = gethostbyname ("servername");
$clientaddr = pack ("Sna4x8", AF_INET, 0, $rawclient);
$serveraddr = pack ("Sna4x8", AF_INET, $port, $rawserver);
socket (SO, AF_INET, SOCK_STREAM, $prototype) || die ("No socket");
bind (SO, $clientaddr) || die ("Can't bind");
connect (SO, $serveraddr) ;
select (SO);
$| = 1;
print SO ("$infor\n");
close (SO) || die ("can not close");
}





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

Date: Wed, 7 Oct 1998 19:47:27 +0800
From: "Xu Hongwei" <howel88@cyberway.com.sg>
Subject: Re: Perl as a dumb terminal
Message-Id: <361b550a.0@news.cyberway.com.sg>

Why insist on perl? Why not C?


Buxx wrote in message <361AC55E.4468@buxx.com>...
>I'm needing to interface a pc thru a serial port to a Meridian phone
>system to moniter and issue commands. All ascii text and emulating a
>dumb terminal.
>
>Anyone have any words of wisdom or done such a thing ??
>
>Steve Vandiver
>Miracle Recreation
>buxx#buxx.com




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

Date: Wed, 07 Oct 1998 15:05:43 +0800
From: Rakesh Puthalath <krithikp@hotmail.com>
Subject: PERL5.005_002 Solaris2.6 - Files missing 
Message-Id: <361B12C7.F595D3AF@hotmail.com>

The Configure script reports missing files like
 ..
hints/..
 ....
and halts with the following error message:
THIS PACKAGE SEEMS TO BE INCOMPLTE

I have downloaded the latest_tar.gz from perl.com.

Is this a known problem , or some  problem with my extraction.
Kindly help .

Thanks

Rakesh
 



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

Date: 07 Oct 1998 09:50:24 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
To: aqumsieh@tigre.matrox.com
Subject: Re: Problems Using a Compare Subroutine with Sort
Message-Id: <laogrostdr.fsf@erh.ericsson.se>

Ala Qumsieh <aqumsieh@tigre.matrox.com> writes:
> Michal Rutka <erhmiru@erh.ericsson.se> writes:
> 
> > > I have a hard time believing that your
> > > machine, which is alsa a sparc, behaves so differently.
> > 
> > It is up to you.
> 
> Me too .. I share John the difficulty in believing so!

Why it is so difficult to belive? First you have to go to the church every
Sunday. Oops, out of topic.

For me, as a hardware engenieer it is clear as sun on the sky. Because
it is so importent hardware issue, (saw Ariane falling - a big pice of
hradware smashed by a software bug). E.g. in VHDL you have to first
declare if you want to signed or unsigned before you are allowed to do
any arithmetic operation with it. I think that it has a lot of sense.

You Ala as an ASIC engineer should know about it better as anybody else.

[...]
> > $a = dotted_to_int('255.255.255.255');
> > print "$a\n";
> > print $a > 0 ? "is positive" : "is negative" ,"\n";
> > 
> > And here is the result:
> > 
> > -1
> > is negative
> > 
> 
> let me try that out on my Ultra-1 sparc .. result:
> 
> 4294967295
> is positive

There is only one correct conclusion. You cannot trust that the integer is
positive as soon as its MSB >= 0x10. 

> > Here is my debuger:
> > 
> >   DB<1> X a
> > $a = '-1'
> > 
> > Michal
> 
> hmm .. what version of Perl are you using?

On Solaris, not the newest one:
This is perl, version 5.003 with EMBED

-1
is negative
 
But I have also bundled in 'xhdl' software:
This is perl, version 5.002

-1
is negative

Bundled with Mentor Graphic Renoir:
This is perl, version 5.004

4294967295
is positive

Bingo.

So, John you have to add require 5.004 to your code.

We see that it was not a problem with my machine (as John suggested), but with
the version of perl.

Michal

> -- 
> Ala Qumsieh             |  No .. not Just Another
> ASIC Design Engineer    |  Perl Hacker!!!!!
> Matrox Graphics Inc.    |
> Montreal, Quebec        |  (Not yet!)


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

Date: Wed, 07 Oct 1998 12:32:54 GMT
From: droby@copyright.com
Subject: Re: Problems Using a Compare Subroutine with Sort
Message-Id: <6vfn1n$s12$1@nnrp1.dejanews.com>

In article <361A5FB7.A9E33475@min.net>,
  John Porter <jdporter@min.net> wrote:
> Garry T. Williams wrote:
> >
> > I don't believe that interpreting 0xffffffff as a minus one is a bug.
> > That *is* minus one (assuming a 32-bit word size).
>
> No, it entirely depends on whether the word is being treated as
> signed or unsigned.  I think it's clear we are only interested in
> treating these numbers as unsigned.  If Perl lacks a way to force
> the interpretation of words as unsigned, then that's a problem
> with Perl.  I have not encountered that problem, however.
>
> > The real problem is using a numeric compare to sort IP addresses.
> > They are strings and a string compare is the only way to order them.
>
> I'm sorry, Garry, but that is utterly false.
> IP addresses are unsigned 32-bit numbers.
> The dotted-decimal notations are for human convenience only.
>

Actually, I think the RFCs have usually referred to the address as 4 octets.
The Arpanet prior to about 1980 had 3 octet addresses.	IP addresses were
around back when the use of a 32-bit integer was a rather new idea and many
minicomputers were still 16-bit machines.  So it wasn't a word.

As such, there is a good deal of sense in sorting them as strings in their
packed form.

> How I wish the IETF (or whatever) had chosen to specify
> dotted-hex with zero padding, instead of decimal; everyone's
> life would be so much easier.
>

Except the people who are baffled by hex.  ;-)

Some implementations have allowed specifying the address in hex at least in
configuring the interface - I'm pretty sure some versions of MacTCP did, and
some DOS IP stacks (before they were made obsolete by a famous OS vendor).

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 07 Oct 1998 12:36:53 GMT
From: droby@copyright.com
Subject: Re: Problems Using a Compare Subroutine with Sort
Message-Id: <6vfn96$sgp$1@nnrp1.dejanews.com>

In article <laogrostdr.fsf@erh.ericsson.se>,
  Michal Rutka <erhmiru@erh.ericsson.se> wrote:
>
> On Solaris, not the newest one:
> This is perl, version 5.003 with EMBED
>
> -1
> is negative
>
> But I have also bundled in 'xhdl' software:
> This is perl, version 5.002
>
> -1
> is negative
>
> Bundled with Mentor Graphic Renoir:
> This is perl, version 5.004
>
> 4294967295
> is positive
>
> Bingo.
>
> So, John you have to add require 5.004 to your code.
>
> We see that it was not a problem with my machine (as John suggested), but with
> the version of perl.
>
> Michal
>

Ah, good!  I guess we can cancel that bug report.

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 7 Oct 1998 00:07:22 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Q: Speed up a regular expression
Message-Id: <MPG.1084b30243b419c89898a3@nntp.hpl.hp.com>

In article <MPG.1084755ece9abd2b9898a2@nntp.hpl.hp.com> on Tue, 6 Oct 
1998 19:44:24 -0700, Larry Rosler <lr@hpl.hp.com> says...
> In article <361ACD7F.A64FF252@wrkhors.com> on Tue, 06 Oct 1998 21:10:07 -
> 0500, Steven Lembark <lembark@wrkhors.com> says...
> > > Is there a way to speed up this regular expression ?
> > > 
> > > if ($line =~ /(^$Search )|( $Search )/io)
> ...
> > probably faster as
> > 
> > 	$line =~ /^$blah/ || $line =~ / $blah/
> > 
> > the first one can 
> > short circut the second if they are separate regexes; with 
> > an or-ed regex you end up having to search for both before 
> > deciding what's correct.
> 
> This is not so.  The alternatives in an or-ed regex are tried in 
> sequence, and the first one that matches stops the search (assuming that 
> the rest of the pattern, if any, is also matched).
> 
> Rather than start up two regex matches (in case the first one fails), one 
> should write simply:
> 
>     if ($line =~ /(?:^| )$Search /io)

I felt guilty about posting conjectures about performance without 
benchmarking them, so I wrote a simple benchmark.  Now I am completely 
baffled, because my reasoning^Wintuition has failed completely yet again.

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

timethese (1 << (shift || 0), {
  one_regex0 => sub { $_ = 'fox';  /(?:^| )foo/ },
  one_regex1 => sub { $_ = 'foo';  /(?:^| )foo/ },
  one_regex2 => sub { $_ = ' foo'; /(?:^| )foo/ },
  two_regex0 => sub { $_ = 'fox';  /^foo/ || / foo/ },
  two_regex1 => sub { $_ = 'foo';  /^foo/ || / foo/ },
  two_regex2 => sub { $_ = ' foo'; /^foo/ || / foo/ },
} );
__END__                                                                               

Benchmark: timing 262144 iterations of one_regex0, one_regex1, 
one_regex2, two_regex0, two_regex1, two_regex2...
one_regex0: 14 wallclock secs (14.33 usr +  0.00 sys = 14.33 CPU)
one_regex1: 12 wallclock secs (12.29 usr +  0.00 sys = 12.29 CPU)
one_regex2: 13 wallclock secs (13.40 usr +  0.00 sys = 13.40 CPU)
two_regex0:  8 wallclock secs ( 8.57 usr +  0.00 sys =  8.57 CPU)
two_regex1: 12 wallclock secs (11.80 usr +  0.00 sys = 11.80 CPU)
two_regex2: 11 wallclock secs ( 9.29 usr +  0.00 sys =  9.29 CPU)

Conclusion:

Two regexes *are* faster than one regex with alternation.  Why???
(The factoring in the single regex has minor performance implications.)

This is perl 5.005_02 on Wintel.

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


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

Date: Wed, 07 Oct 1998 11:46:08 +0200
From: Nico <info@edoc.co.za>
Subject: Reading all lines from datafile
Message-Id: <361B3860.40EC@edoc.co.za>

Hi,

I'm using Perl5.004 under WIN95

I have the following problem:  

I'm trying to read ALL the lines from a datafile one by one for
processing.  The code below reads only every second line.

The datafile was prepared in Notepad, with <enter> at the end of each
line.

What am I doing wrong?

Thanks for the help.

Nico


#Read datalines in file

$filename1 = 'c:\myfiles\testfile.txt';

open(CAT,$filename1) || die "can't open file $filename1";

while (<CAT>)

{
$ty =<CAT>;
print "$ty\n";}

close(CAT);

PS:  Thanks for all the brilliant, kind answers to previous stupid
questions!


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

Date: Wed, 7 Oct 1998 19:30:54 +0800
From: "Xu Hongwei" <howel88@cyberway.com.sg>
Subject: Re: Reading all lines from datafile
Message-Id: <361b512a.0@news.cyberway.com.sg>


Nico wrote in message <361B3860.40EC@edoc.co.za>...
>Hi,
>
>I'm using Perl5.004 under WIN95
>
>I have the following problem:
>
>I'm trying to read ALL the lines from a datafile one by one for
>processing.  The code below reads only every second line.
>
>The datafile was prepared in Notepad, with <enter> at the end of each
>line.
>
>What am I doing wrong?
>
>Thanks for the help.
>
>Nico
>
>
>#Read datalines in file
>
>$filename1 = 'c:\myfiles\testfile.txt';
>
>open(CAT,$filename1) || die "can't open file $filename1";
>
>while (<CAT>)
>
>{



#### >$ty =<CAT>;
$ty = $_;


>print "$ty\n";}
>
>close(CAT);
>
>PS:  Thanks for all the brilliant, kind answers to previous stupid
>questions!




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

Date: Wed, 7 Oct 1998 19:55:39 +0800
From: "Xu Hongwei" <howel88@cyberway.com.sg>
Subject: Re: What's is wrong here?
Message-Id: <361b56f6.0@news.cyberway.com.sg>

$cnt = $foo =~ tr#\/##;

Allen Choy wrote in message <361A95CC.310A6638@us.oracle.com>...
>
>This problem is driving me up the wall.
>
>I'm trying to count the number of directory levels - simple enough.
>
>$cnt = $foo =~ tr#/#/#;
>
>This works just fine on regular unix.  But to work on multiple OS's, I
>want to
>do something like this:
>
>$cnt = $foo =~ tr#$SEP#$SEP#;;
>
>But it's not producing the same results.
>
>I look at the Camel book, and it states that tr accepts a char list, so
>if $SEP eq  '/',
>it should work, right? Unless it's interpolating it in a way I'm not
>familiar with.
>
>Thanks in advance,
>
>Allen
>
>PS: I'm using 5.004 on Solaris.
>
>
>




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

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

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