[15596] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3009 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 10 18:15:41 2000

Date: Wed, 10 May 2000 15:15:28 -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: <957996928-v9-i3009@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 10 May 2000     Volume: 9 Number: 3009

Today's topics:
        POSIX shared memory and Perl <enrecka@sandia.gov>
    Re: Precedence question (Abigail)
    Re: Precedence question <uri@sysarch.com>
    Re: Precedence question <bmb@ginger.libs.uga.edu>
    Re: Printing Arrays <bmb@ginger.libs.uga.edu>
    Re: Printing Arrays <lr@hpl.hp.com>
    Re: Printing Arrays <nospam@devnull.com>
        problem: fork and then connecting to another server <Werner.Sager@t-online.de>
    Re: Quality of perl implementations <nobody@internetrobotics.com>
    Re: re-initializing through each loop (Bart Lateur)
    Re: re-initializing through each loop (Abigail)
    Re: re-initializing through each loop <uri@sysarch.com>
    Re: re-initializing through each loop (Bart Lateur)
    Re: re-initializing through each loop (Abigail)
    Re: re-initializing through each loop <aqumsieh@hyperchip.com>
    Re: Recursive copy (Skip links) <rootbeer@redcat.com>
    Re: regex question (Abigail)
    Re: regular expression: how do I accept +integers or +f <Luc-Etienne.Brachotte@wanadoo.fr>
    Re: regular expression: how do I accept +integers or +f <Luc-Etienne.Brachotte@wanadoo.fr>
        removing carriage returns from a form entry <chris@aol.com>
    Re: Returning an IP Address <lr@hpl.hp.com>
    Re: Returning an IP Address <lr@hpl.hp.com>
    Re: Returning an IP Address <flavell@mail.cern.ch>
    Re: Returning an IP Address <aran@mapcruzin.com>
        Semantics of terminal /@/ and "@" (Was: Re: Help Needed <lr@hpl.hp.com>
    Re: signal trapper <andy@u2me3.com>
        simple link checker needed broni99@my-deja.com
        taint workin <changeme@changeme>
    Re: taint workin <rootbeer@redcat.com>
    Re: taint workin <mjmatt@qsun.att.com>
    Re: Tanspose rows to columns (Abigail)
        tweaking Net::DNS <elijah@workspot.net>
    Re: What debugger do people use for Perl? (Abigail)
    Re: What debugger do people use for Perl? <blowther@SpAmFiLtErmicron.com>
        Where's the FAQ? <news@theedgeofpanic.freeserve.co.uk>
    Re: Where's the FAQ? <dave@dave.org.uk>
    Re: Where's the FAQ? <news@theedgeofpanic.freeserve.co.uk>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 10 May 2000 13:13:36 -0600
From: Erik Reckase <enrecka@sandia.gov>
Subject: POSIX shared memory and Perl
Message-Id: <3919B4E0.9C939783@sandia.gov>

I'm working on a project which uses POSIX shared memory in C, and I'd
like to access that shared memory with a Perl program.  Is this
possible?  Is anyone aware of a module that would help me out?  (I know
of the System V commands, but no POSIX implementation.)

--Erik Reckase
--Sandia National Laboratories
--Albuquerque, NM


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

Date: 10 May 2000 18:12:55 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Precedence question
Message-Id: <slrn8hj9l6.so9.abigail@ucan.foad.org>

On Wed, 10 May 2000 10:43:24 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
++ In article <x7og6etkpo.fsf@home.sysarch.com> on Wed, 10 May 2000 
++ 16:48:37 GMT, Uri Guttman <uri@sysarch.com> says...
++ 
++ ...
++ 
++ > perl quiz: name as many syntactical uses for {} as you can.
++ 
++ Risking all:
++ 
++   Hash-key designator
++ 
++   Anonymous hash constructor
++ 
++   Paired delimiters (quotes, regexes, substitutions)
++ 
++   Block delimiters
++ 
++   Dereference delimiters
++      In ${$foo->bar}, the contents of {...} are a BLOCK.
++      In "${foo}bar", similarly.
++      So this may not count as a separate syntactical use.


"Counting" in regular expressions.



Abigail


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

Date: Wed, 10 May 2000 18:15:58 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Precedence question
Message-Id: <x7g0rqtgo2.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> In article <x7og6etkpo.fsf@home.sysarch.com> on Wed, 10 May 2000 
  LR> 16:48:37 GMT, Uri Guttman <uri@sysarch.com> says...

  >> perl quiz: name as many syntactical uses for {} as you can.

  LR>   Hash-key designator

  LR>   Anonymous hash constructor

  LR>   Paired delimiters (quotes, regexes, substitutions)

  LR>   Block delimiters

  LR>   Dereference delimiters
  LR>      In ${$foo->bar}, the contents of {...} are a BLOCK.
  LR>      In "${foo}bar", similarly.
  LR>      So this may not count as a separate syntactical use.

separating ${foo} in a string is different than using {} to deref a hard
ref. the former only works with a bareword and is a syntactical alias
for $foo. the latter is a runtime operation which can take any
expression inside the {}. that also means their syntax is greatly
different so i would qualify them as separate uses of {}.

numeric quantifiers in regexes

ilya's wacky regex code hack

an itch tells me there are a couple more of them.

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: Wed, 10 May 2000 15:26:09 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Precedence question
Message-Id: <Pine.A41.4.10.10005101522460.12498-100000@ginger.libs.uga.edu>

On Wed, 10 May 2000, Uri Guttman wrote:

> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
> 
>   LR> In article <x7og6etkpo.fsf@home.sysarch.com> on Wed, 10 May 2000 
>   LR> 16:48:37 GMT, Uri Guttman <uri@sysarch.com> says...
> 
>   >> perl quiz: name as many syntactical uses for {} as you can.
> 
>   LR>   Hash-key designator
> 
>   LR>   Anonymous hash constructor
> 
>   LR>   Paired delimiters (quotes, regexes, substitutions)
> 
>   LR>   Block delimiters
> 
>   LR>   Dereference delimiters
>   LR>      In ${$foo->bar}, the contents of {...} are a BLOCK.
>   LR>      In "${foo}bar", similarly.
>   LR>      So this may not count as a separate syntactical use.
> 
> separating ${foo} in a string is different than using {} to deref a hard
> ref. the former only works with a bareword and is a syntactical alias
> for $foo. the latter is a runtime operation which can take any
> expression inside the {}. that also means their syntax is greatly
> different so i would qualify them as separate uses of {}.
> 
> numeric quantifiers in regexes
> 
> ilya's wacky regex code hack
> 
> an itch tells me there are a couple more of them.


Mustache in smileys.  :{D (}:

-- 
Brad



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

Date: Wed, 10 May 2000 15:36:29 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Printing Arrays
Message-Id: <Pine.A41.4.10.10005101529310.12498-100000@ginger.libs.uga.edu>

On 10 May 2000, The WebDragon wrote:
 ...
> my @dataList;
> for (@filesList) {
>     my $grabFile = $inputDir . $_;
>     open(GRAB, "<$grabFile") or die ("Cannot open file $grabFile : $!");
> #   print "Successful open of $grabFile\n";
>     push @dataList, "-- $_\n";
>     while(<GRAB>) {
>         tr/\r//d;
>         next unless /^\Qmaps[i++] = new Map(\E([^)]+)/;
>         push @dataList, "$1\n" ;
> #       print "$1\n";
>     }
>     close (GRAB);
> };
> ...
> how do I remove that last \n once @dataList is done being created?

You mean like with chomp?

     1  #!/usr/local/bin/perl -w
     2  use strict;
     3
     4  my @a = ( "1\n", "2\n", "3\n" );
     5  print @a;
     6  chomp $a[-1];
     7  print @a, "eh?";


dataList
filesList
grabFile
inputDir

No offense, but I hate that naming convention with a passion bordering on
obsession.  ("Let's see now, which letter was uppercase?")  :{D

So how come it's not webDragon?  (}:

-- 
Brad




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

Date: Wed, 10 May 2000 12:33:41 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Printing Arrays
Message-Id: <MPG.138359747dff7f6698aa4f@nntp.hpl.hp.com>

In article <8fc78o$dd4$1@216.155.32.13> on 10 May 2000 17:46:00 GMT, The 
WebDragon <nospam@devnull.com> says...
> In article <8fbcfo$jlt$1@nnrp1.deja.com>, Ilja <billy@arnis-bsl.com> 
> wrote:

 ...

> my @dataList;
> for (@filesList) {
>     my $grabFile = $inputDir . $_;
>     open(GRAB, "<$grabFile") or die ("Cannot open file $grabFile : $!");
> #   print "Successful open of $grabFile\n";
>     push @dataList, "-- $_\n";
>     while(<GRAB>) {
>         tr/\r//d;
>         next unless /^\Qmaps[i++] = new Map(\E([^)]+)/;
>         push @dataList, "$1\n" ;
> #       print "$1\n";
>     }
>     close (GRAB);
> };
> ...
> how do I remove that last \n once @dataList is done being created?

Why would you want to have an array of lines, where the last element 
wasn't a line?

But if you insist, here is one of many ways:

    substr($dataList[-1], -1) = "";

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


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

Date: 10 May 2000 21:53:49 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: Printing Arrays
Message-Id: <8fclpd$h4r$1@216.155.32.13>

In article 
<Pine.A41.4.10.10005101529310.12498-100000@ginger.libs.uga.edu>, Brad 
Baxter <bmb@ginger.libs.uga.edu> wrote:

 | On 10 May 2000, The WebDragon wrote:
 | ...
 | > my @dataList;
 | > for (@filesList) {
 | >     my $grabFile = $inputDir . $_;
 | >     open(GRAB, "<$grabFile") or die ("Cannot open file $grabFile : 
 | >     $!");
 | > #   print "Successful open of $grabFile\n";
 | >     push @dataList, "-- $_\n";
 | >     while(<GRAB>) {
 | >         tr/\r//d;
 | >         next unless /^\Qmaps[i++] = new Map(\E([^)]+)/;
 | >         push @dataList, "$1\n" ;
 | > #       print "$1\n";
 | >     }
 | >     close (GRAB);
 | > };
 | > ...
 | > how do I remove that last \n once @dataList is done being created?
 | 
 | You mean like with chomp?
 | 
 |      1  #!/usr/local/bin/perl -w
 |      2  use strict;
 |      3
 |      4  my @a = ( "1\n", "2\n", "3\n" );
 |      5  print @a;
 |      6  chomp $a[-1];
 |      7  print @a, "eh?";
 | 
 | 
 | dataList
 | filesList
 | grabFile
 | inputDir
 | 
 | No offense, but I hate that naming convention with a passion bordering 
 | on
 | obsession.  ("Let's see now, which letter was uppercase?")  :{D
 | 
 | So how come it's not webDragon?  (}:

actually I answered my own question later on while pondering the 
datasctructure and wondering how I was going to tell whether the final 
list had ended since there were no further --'s to indicate the start of 
a new list.. 

so I changed them all to == to start with, and then added a final push 
@dataList, "=="; after the closing the last inputfile. 

as for the naming thing, TMTOWTDI, right? (: 

I use the same thing while mucking around in Tcl too, and it seems to 
work fine there as well =) 

*flee*

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: Wed, 10 May 2000 20:24:22 +0200
From: Werner Sager <Werner.Sager@t-online.de>
Subject: problem: fork and then connecting to another server
Message-Id: <3919A956.38E9E4D3@t-online.de>

Hello,

 1. A client C1 connects to a server S1 ( socket ) ,
 2. the server S1 creates a child CH1 ( fork ) ,
 3. the child CH1 connects to another server S2 ( socket )  
 
 Communication between CH1 and S2 doesn't work:
   my protocol is running, but the child receives empty messages.
 
 If server S1 does not create a child, the same protocol ( same code )
 between C1, S1 and S2  is running !!
 I think, the sharing of file descriptors might be the problem ????
 
 any idea ??
 
 ( for testing I have modified the example "socket_tcp_threaded" chp6
 camel-book,
     I am  using "ActiveState perl 5.6 on win32"  )
 
 mit freundlichem Gruss / Best regards
 
   Werner Sager
 _________________________________________________________
 Robert Bosch GmbH       phone: +49-5121/49 4745 
 Robert-Bosch-Str. 200   fax:   +49-5121/49 17 4745  
 31139 Hildesheim       mailto:Werner.Sager@de.bosch.com


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

Date: 10 May 2000 19:01:48 GMT
From: The Unknown Admin <nobody@internetrobotics.com>
Subject: Re: Quality of perl implementations
Message-Id: <8fcbms02uiu@news2.newsguy.com>

In comp.lang.perl.moderated Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
: The criterion "works just fine in the real world" is the latmus test
: for scripting.

I don't agree. "works just fine in the real world on one system" would 
be a good litmus test for scripting. When it reaches "works just fine
in the real world on thousands of diverse systems" then I maintain it
is a program.

-- 
Internet Robotics, 131 Willow Lane, Floor 2, Oxford, OH  45056
phone +1.513.523.7621 fax 7501 <mikeh@minivend.com>

Any man who is under 30, and is not liberal, has not heart; and any man
who is over 30, and is not a conservative, has not brains.
 -- Winston Churchill


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

Date: Wed, 10 May 2000 18:48:59 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: re-initializing through each loop
Message-Id: <391cae7a.2747678@news.skynet.be>

Abigail wrote:

>Again, you are confusing declarion and run time effects. 

	for(1 ..10)
	    my $i;
	    push @ary, \$i;
	    print \$i,"\n";
	}

This prints 10 different values for the reference. That must take SOME
time, at runtime.

-- 
	Bart.


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

Date: 10 May 2000 19:11:00 GMT
From: abigail@foad.org (Abigail)
Subject: Re: re-initializing through each loop
Message-Id: <slrn8hjd24.so9.abigail@ucan.foad.org>

On Wed, 10 May 2000 18:48:59 GMT, Bart Lateur <bart.lateur@skynet.be> wrote:
++ Abigail wrote:
++ 
++ >Again, you are confusing declarion and run time effects. 
++ 
++ 	for(1 ..10)
++ 	    my $i;
++ 	    push @ary, \$i;
++ 	    print \$i,"\n";
++ 	}
++ 
++ This prints 10 different values for the reference. That must take SOME
++ time, at runtime.


Of course. One more time, as you don't seem to get it: 'my $i;' does 
something both at compile *AND* at runtime.



Abigail


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

Date: Wed, 10 May 2000 19:11:01 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: re-initializing through each loop
Message-Id: <x77ld2te4b.fsf@home.sysarch.com>

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

  BL> Abigail wrote:
  >> Again, you are confusing declarion and run time effects. 

  BL> 	for(1 ..10)
  BL> 	    my $i;
  BL> 	    push @ary, \$i;
  BL> 	    print \$i,"\n";
  BL> 	}

  BL> This prints 10 different values for the reference. That must take SOME
  BL> time, at runtime.

my has an effect at runtime when the variable has a ref count > 1. it
will allocate a new variable for the same lexical name. but it only
happens if you play with references to those vars.

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: Wed, 10 May 2000 20:10:28 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: re-initializing through each loop
Message-Id: <3919c1d8.506518@news.skynet.be>

Abigail wrote:

>Of course. One more time, as you don't seem to get it: 'my $i;' does 
>something both at compile *AND* at runtime.

and:

>What speed penalty? Hopefully you know that my declares the variable
>at _compile_ time; not runtime.


-- 
	Bart.


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

Date: 10 May 2000 20:35:09 GMT
From: abigail@foad.org (Abigail)
Subject: Re: re-initializing through each loop
Message-Id: <slrn8hjhvt.h6o.abigail@ucan.foad.org>

On Wed, 10 May 2000 20:10:28 GMT, Bart Lateur <bart.lateur@skynet.be> wrote:
++ Abigail wrote:
++ 
++ >Of course. One more time, as you don't seem to get it: 'my $i;' does 
++ >something both at compile *AND* at runtime.
++ 
++ and:
++ 
++ >What speed penalty? Hopefully you know that my declares the variable
++ >at _compile_ time; not runtime.


*sigh*

What's your problem?



Abigail


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

Date: Wed, 10 May 2000 21:16:14 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: re-initializing through each loop
Message-Id: <7aem7a85sw.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>


bart.lateur@skynet.be (Bart Lateur) writes:

> Abigail wrote:
> 
> >Again, you are confusing declarion and run time effects. 
> 
> 	for(1 ..10)
> 	    my $i;
> 	    push @ary, \$i;
> 	    print \$i,"\n";
> 	}
> 
> This prints 10 different values for the reference. That must take SOME
> time, at runtime.

Yes. This is because you are storing a reference to $i in each loop. So
Perl *has* to allocate a new piece of memory for each iteration as it
can not reuse the same memory location.

Witness what happens though if you remove the push():

	% perl -wl
	for (0 .. 5) {
	        my $i;
	        print \$i;
	}
	__END__
	SCALAR(0x80e1610)
	SCALAR(0x80e1610)
	SCALAR(0x80e1610)
	SCALAR(0x80e1610)
	SCALAR(0x80e1610)
	SCALAR(0x80e1610)

Perl simply reuses the same memory location since the scope of each
variable ends at the end of each iteration, and there are no more
references to it.

I believe that at each iteration there is a certain bit associated with
$i that gets flagged indicating that the variable's value is undefined,
irrespective of the current value stored in the memory associated with
it. The contents of the memory location are not modified. Once $i is
initialized to some value, this bit is reset to indicate that whatever
is stored in the memory location is now valid (even if it's 'undef').

The above explanation is what I remember from studying perlguts some
long time ago. I could be off, but I hope not.

--Ala



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

Date: Wed, 10 May 2000 12:26:47 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Recursive copy (Skip links)
Message-Id: <Pine.GSO.4.10.10005101225100.3921-100000@user2.teleport.com>

On 10 May 2000, Scott Chapal wrote:

> What is a GOOD way in perl to do a recursive copy of a directory,
> preserve file attributes, replicate link names, but avoid copying from
> links?

> File::Find and File::Copy ??

Hey, if you're going to answer your own questions, you're making this too
easy! :-)

Seriously, those will be a good start. You'll probably have to do some
actual work, though, to earn your salary on this one. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 10 May 2000 18:56:24 GMT
From: abigail@foad.org (Abigail)
Subject: Re: regex question
Message-Id: <slrn8hjc6o.so9.abigail@ucan.foad.org>

On Fri, 05 May 2000 20:27:25 GMT, gbaker@cs.umb.edu <gbaker@cs.umb.edu> wrote:
++ 
++ 
++ Hi,
++ 
++ I have a messy data set of street names with stuff like :
++ 
++    10 MAINST
++    15 LOCUST
++     7 1ST
++    55 PARK WEST
++    12 BALLASTST
++    15 EAST
++    22 NORWALLST
++ 
++ What I would like to do is replace /st$/ with " st"
++ if the two letters before it are not some of the common
++ ones that come up ( i.e. CU in Locust, WE in West, EA in East, ).


#!/opt/perl/bin/perl -w
 
use strict;
 
my @common = map {/(..)st$/i} qw /Locust West East/;
 
 
foreach (<DATA>) {
    local $" = "|";
    s/(?<!@common)(?=st$)/ /i;
    print;
}
 
__DATA__
   10 MAINST
   15 LOCUST
    7 1ST
   55 PARK WEST
   12 BALLASTST
   15 EAST
   22 NORWALLST


Which will print:

   10 MAIN ST
   15 LOCUST
    7 1 ST
   55 PARK WEST
   12 BALLAST ST
   15 EAST
   22 NORWALL ST



Abigail


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

Date: Wed, 10 May 2000 20:22:13 +0200
From: "Luc-Etienne.Brachotte" <Luc-Etienne.Brachotte@wanadoo.fr>
Subject: Re: regular expression: how do I accept +integers or +floats only?
Message-Id: <3919A8D4.EC1DE0A0@wanadoo.fr>

Ed Toivanen a écrit :

> Hi,
>
> I'm trying to accept only positive numbers, that look like either integers
> or floats. When I say "look like", I mean 1 or 1.1 or .1, not in reference
> to any particular data type.
>
> The signed portion isn't that important, so that is OK.
>
> This is my regular expression so far.
>   if( $days[$i]  =~ /\d+\.{0,1}\d{0,1}/){   #makes any non-digit = 0 except
> for decimal
>     #accept value
>   } else {
>    $days[$i] = 0;
>   }
>
> The problem is that while this thing does filter out 'abc' it does not
> filter out 't9.0'. As you can see, I am trying to accept one or more digits,
> 0 or 1 decimal point, and 0 or 1 digit after the decimal.
>
> How can I make this thing work?
>
> Thanks, Ed
> et@telus.net

In fact, if you want only the number, nothing else, you should use

  if( $days[$i]  =~ /^\d+\.{0,1}\d{0,1}$/){   #makes any non-digit = 0 except

or just

  if( $days[$i]  =~ /^\d+\.?\d?$/){   #makes any non-digit = 0 except

Both will accept '9.0' but not 't9.0' nor '9.0t'




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

Date: Wed, 10 May 2000 20:40:57 +0200
From: "Luc-Etienne.Brachotte" <Luc-Etienne.Brachotte@wanadoo.fr>
Subject: Re: regular expression: how do I accept +integers or +floats only?
Message-Id: <3919AD39.CE6CA474@wanadoo.fr>

Ed Toivanen a écrit :

> Hi,
>
> I'm trying to accept only positive numbers, that look like either integers
> or floats. When I say "look like", I mean 1 or 1.1 or .1, not in reference
> to any particular data type.
>
> The signed portion isn't that important, so that is OK.
>
> This is my regular expression so far.
>   if( $days[$i]  =~ /\d+\.{0,1}\d{0,1}/){   #makes any non-digit = 0 except
> for decimal
>     #accept value
>   } else {
>    $days[$i] = 0;
>   }
>
> The problem is that while this thing does filter out 'abc' it does not
> filter out 't9.0'. As you can see, I am trying to accept one or more digits,
> 0 or 1 decimal point, and 0 or 1 digit after the decimal.
>
> How can I make this thing work?
>
> Thanks, Ed
> et@telus.net

Note that your RE will not accept '.1' as you want it.
Try
/^\d*\.?\d$/
It will accept
1
1.1
 .1
123456
124325.1
and will accept only numbers




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

Date: Wed, 10 May 2000 16:48:57 -0700
From: chris <chris@aol.com>
Subject: removing carriage returns from a form entry
Message-Id: <3919F569.5FD0679@aol.com>


unfortunately, when i enter carriage returns into the form they still
show up in the data file and it screws the whole database up.

i think the problem might lie in the somewhere else--the form input does
not come in as an array, although the input fields do correspond to
@db_user_definable_field_order.

i get form data in like this:

$form_data{'field_name_goes_here'}

so maybe the beginning of those lines is wrong.  i have tried the
following variations:

######################################################
foreach $field (@db_user_definable_field_order)
  {
   $form_data{$field} =~ s/\|//mg; # removes pipes
   $form_data{$field} =~ s/\n//mg; # removes returns
  }
######################################################
# or
######################################################
foreach $field (@db_user_definable_field_order)
  {
   $form_data{'$field'} =~ s/\|//mg; # removes pipes
   $form_data{'$field'} =~ s/\n//mg; # removes returns
  }
######################################################
# or
######################################################
foreach $field (@db_user_definable_field_order)
  {
   $field =~ s/\|//mg; # removes pipes
   $field =~ s/\n//mg; # removes returns
  }
######################################################

still, none of them work.  i'm kinda lost.  thanks in advance if you
gots any suggestions.



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

Date: Wed, 10 May 2000 12:42:21 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Returning an IP Address
Message-Id: <MPG.13835b733773973998aa50@nntp.hpl.hp.com>

In article <F5hS4.96986$cZ.260318@typhoon.southeast.rr.com> on Wed, 10 
May 2000 17:35:33 GMT, Aran Meuser <aran@mapcruzin.com> says...
> I'm trying to write a script that will display my IP address as seen by the
> rest of the internet.  I can't seem to find anything in any of the Net,
> Http, DNS, etc, modules that *might* have this capability.  If anyone could
> help, I'd sure appreciate it, I bet its quite simple.

perlfaq9:  "How do I find out my hostname/domainname/IP address?"

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


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

Date: Wed, 10 May 2000 12:51:02 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Returning an IP Address
Message-Id: <MPG.13835d85e4dd0e7d98aa51@nntp.hpl.hp.com>

In article <8fc7un$3430$1@onlink3.onlink.net> on Wed, 10 May 2000 
12:10:55 -0400, Jonah <nomail@nomail.com> says...
> 
> Aran Meuser <aran@mapcruzin.com> wrote in message
> news:F5hS4.96986$cZ.260318@typhoon.southeast.rr.com...
> > I'm trying to write a script that will display my IP address as seen by
> > the rest of the internet.  I can't seem to find anything in any of the
> > Net, Http, DNS, etc, modules that *might* have this capability.  If anyone
> > could help, I'd sure appreciate it, I bet its quite simple.

 ...

> Not sure exactly you mean, but try
> 
> $ENV{'REMOTE_ADDR'};
> 
> is that what you want?

That is set by the webserver to the presumed IP address of a client.  No 
relation to the IP address of the system on which the program is 
running.

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


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

Date: Wed, 10 May 2000 22:44:02 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Returning an IP Address
Message-Id: <Pine.GHP.4.21.0005102241350.8113-100000@hpplus03.cern.ch>

On Wed, 10 May 2000, Larry Rosler wrote:

> In article <F5hS4.96986$cZ.260318@typhoon.southeast.rr.com> on Wed, 10 
> May 2000 17:35:33 GMT, Aran Meuser <aran@mapcruzin.com> says...

> > I'm trying to write a script that will display my IP address 
> > as seen by the rest of the internet. 
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

> perlfaq9:  "How do I find out my hostname/domainname/IP address?"

I couldn't help feeling there was some significance in the way
that the question was posed.  Maybe the hon usenaut is behind a
NAT gateway or something.



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

Date: Wed, 10 May 2000 21:12:53 GMT
From: "Aran Meuser" <aran@mapcruzin.com>
Subject: Re: Returning an IP Address
Message-Id: <phkS4.74172$O7.183989@typhoon.southeast.rr.com>

Yay!  Thank you, that did it.  :)


"Larry Rosler" <lr@hpl.hp.com> wrote in message
news:MPG.13835b733773973998aa50@nntp.hpl.hp.com...
> In article <F5hS4.96986$cZ.260318@typhoon.southeast.rr.com> on Wed, 10
> May 2000 17:35:33 GMT, Aran Meuser <aran@mapcruzin.com> says...
> > I'm trying to write a script that will display my IP address as seen by
the
> > rest of the internet.  I can't seem to find anything in any of the Net,
> > Http, DNS, etc, modules that *might* have this capability.  If anyone
could
> > help, I'd sure appreciate it, I bet its quite simple.
>
> perlfaq9:  "How do I find out my hostname/domainname/IP address?"
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com




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

Date: Wed, 10 May 2000 12:28:58 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Semantics of terminal /@/ and "@" (Was: Re: Help Needed  - Perl Matching Operator)
Message-Id: <MPG.13835855eb54f46a98aa4e@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.  Removed comp.langperl and 
tw.bbs.comp.lang.perl.]

In article <8fc7b3$pu4$1@charm.magnus.acs.ohio-state.edu> on 10 May 2000 
17:47:15 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> says...
> [A complimentary Cc of this posting was sent to Larry Rosler 
> <lr@hpl.hp.com>],
> who wrote in article <MPG.1383343ab62323c698aa49@nntp.hpl.hp.com>:
> 
> > What makes you say that /@/ is 'wrong'?  Did you try it before posting?  
> > If not, why not?
> 
> Please explain where it is documented what 
> 
>   $a = "@";
> 
> means.  And why it is different from "@{ *{$main::{''}}{ARRAY} }".

I cannot find a positive statement about what "@" means, and 
unfortunately "@" behaves differently from "$" (which causes a syntax 
error), for no apparent reason.  But /$/ has specific semantics because 
$ is a regex metacharacter, while /@/ does not; in that context, 
different behavior is understandable.

I would go by this excerpt from perlop:

  For constructs that do interpolate, variables beginning with ``$'' or
  ``@'' are interpolated ...

I see no variable beginning with ``@'' in "@".  Your magic construction 
of a variable with a null name is impressive but hardly compelling, as 
it seems quite useless.  @{""} ?.  Ye gods!  Why???

This seems like yet another case of pragmatic semantics, or 'whatever 
the implementation does'.  I can't think why terminal "$" in a double-
quoted string shouldn't behave as a literal, the same as terminal "@" 
does, but that may be historical baggage.

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


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

Date: Wed, 10 May 2000 19:15:04 +0100
From: "Andy Chantrill" <andy@u2me3.com>
Subject: Re: signal trapper
Message-Id: <8fc8vn$jp5$1@neptunium.btinternet.com>

Yep ... and I know goto won't work ... what I'm asking is for some other
logic that may make it work.


Andy.




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

Date: Wed, 10 May 2000 19:15:43 GMT
From: broni99@my-deja.com
Subject: simple link checker needed
Message-Id: <8fccgd$ns0$1@nnrp1.deja.com>

I have written simple web publishing scrip in ksh (can rewrite it in
Perl if needed).
Now I want to execute simple ksh or perl code to verify links on the
page submitted to  publishing script and display wornings if dead links
are found. I need to check only one page.

Can someone point to such program (preferable, freeware or shareware)?
As I said, I do not need complex functionality, just checking one
submitted page for dead links will be enough.

thanks


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


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

Date: Wed, 10 May 2000 15:24:23 -0400
From: "change" <changeme@changeme>
Subject: taint workin
Message-Id: <8fccp5$7mb13@kcweb01.netnews.att.com>

The taint option seems to break the m/\G... /c regex expressions for the
following.

This is perl, version 5.005_03 built for sun4-solaris

works fine unless I use taint, and then susequent regex calls do NOT advance
the buffer and the routine goes into a infinite loop. Unfortunately my app
has to run in the taint mode because it is setuid so I cannot untaint to
fix. Is this a known problem? Are there any fixes in later perl releases?
Email would be appreciated.

TIA




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

Date: Wed, 10 May 2000 12:57:57 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: taint workin
Message-Id: <Pine.GSO.4.10.10005101255430.16364-100000@user2.teleport.com>

On Wed, 10 May 2000, change wrote:

> works fine unless I use taint, and then susequent regex calls do NOT
> advance the buffer and the routine goes into a infinite loop.

Could you please create a small, self-containted program to demonstrate
this behavior? Ideally, it should produce different output depending upon
whether -T is used. Having that program would make it much more likely
that the bug can be found and squashed quickly.

> Are there any fixes in later perl releases?

With that sample program, it would be easy to find out. :-)

Thanks!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 10 May 2000 17:17:28 -0400
From: "Michael Matthews" <mjmatt@qsun.att.com>
Subject: Re: taint workin
Message-Id: <8fcjd6$7ma14@kcweb01.netnews.att.com>

Sorry, Did not have my news reader configured correctly in original post.

change <changeme@changeme> wrote in message
news:8fccp5$7mb13@kcweb01.netnews.att.com...
> The taint option seems to break the m/\G... /c regex expressions for the
> following.
>
> This is perl, version 5.005_03 built for sun4-solaris
>
> works fine unless I use taint, and then susequent regex calls do NOT
advance
> the buffer and the routine goes into a infinite loop. Unfortunately my app
> has to run in the taint mode because it is setuid so I cannot untaint to
> fix. Is this a known problem? Are there any fixes in later perl releases?
> Email would be appreciated.
>
> TIA
>
>




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

Date: 10 May 2000 18:49:06 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Tanspose rows to columns
Message-Id: <slrn8hjbp2.so9.abigail@ucan.foad.org>

On Thu, 04 May 2000 14:39:38 GMT,
jimbob4334@my-deja.com <jimbob4334@my-deja.com> wrote:
++ Hi,
++ 
++ I have been trying to convert this:
++ 
++ 4|3|7|0|2|0|2|0|2|1|1|0|2|3|0|0|0|0|0|0|0|0|0|0|1.1|
++ 6|2|3|4|6|3|6|8|6|1|2|5|3|7|2|0|0|0|0|0|0|0|0|0|1.2|
++ 0|0|0|0|0|0|0|0|0|0|0|0|0|5|3|0|0|0|0|0|0|0|0|0|1.3|
++ 


#!/opt/perl/bin/perl -w
 
use strict;
 
my @data = map {chomp; [split /\|/]} <DATA>;  
{local $, = "\n"; print "<PRO>", (map {pop @$_} @data), "</PRO>$,";}
{local ($,, $\) = ("\t", "\n"); print "<DATA>"; map {my $i = $_;
 print map {$_ -> [$i]} @data} 0 .. $#{$data [0]}; print "</DATA>";} 


__DATA__
4|3|7|0|2|0|2|0|2|1|1|0|2|3|0|0|0|0|0|0|0|0|0|0|1.1| 
6|2|3|4|6|3|6|8|6|1|2|5|3|7|2|0|0|0|0|0|0|0|0|0|1.2| 
0|0|0|0|0|0|0|0|0|0|0|0|0|5|3|0|0|0|0|0|0|0|0|0|1.3| 


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

Date: 10 May 2000 19:03:52 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: tweaking Net::DNS
Message-Id: <eli$0005101443@qz.little-neck.ny.us>

Sorry for the crosspost. Feel free to send followups to either
group.

The firewall I am behind does not let random UDP packets through.
The admin is willing to let packets to a particular port through,
however.

This poses a problem for using remove nameservers, since nslookup,
etc, just pick random ports to send requests from.

I'm working on fixing this in the Net::DNS module for use in a
script I have, but I'm running into a bind error that has me
confused.

Basically I have rewritten the send_udp() function in Net::DNS::Resolver.
The original code loops over nameservers opening sockets for them,
then loops over nameservers sending queries. That won't work for
for having all requests come from a particular port, so I've
changed (or tried to, at least) the code to loop over nameservers
doing an open/query/wait/close each time, which is certainly slower
but I think should work.

The relevant (I think) code is:

    foreach $each (@{$self->{"nameservers"}}) {

	my $sock =
		IO::Socket::INET->new(PeerAddr => $each,
			      PeerPort => $self->{"port"},
			      Proto    => "udp");
	if ($sport and $sock) {
		$sock->setsockopt(SOL_SOCKET,SO_REUSEADDR, pack('l', 1))
		  or die "setsockopt: $!";
		$sock->bind(pack_sockaddr_in($sport, INADDR_ANY))
		  or die "bind: $!";
	}

        # ...

I always get an error on the bind():

	bind: Invalid argument at /.../Net/DNS/Resolver.pm

Does anyone see what I am doing wrong? $sport is 13579 if that matters.
I get the same results using the perl internal versions of setsockopt
and bind functions for doing this.

In a seperate script I have verified that bind works for GLOB
variables refering to udp ports, so I figure it has to be something
I'm not seeing/understanding about how things are different in
this OO code.

Elijah
------
the udp restriction came after the bugtraq udp port probe discussion


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

Date: 10 May 2000 18:05:03 GMT
From: abigail@foad.org (Abigail)
Subject: Re: What debugger do people use for Perl?
Message-Id: <slrn8hj96f.tf8.abigail@ucan.foad.org>

On Tue,
02 May 2000 13:50:38 -0400, jkroger <jkrogerSPAMBLOCKER@earthlink.net> wrote:
++ Hi, I'm learning Perl, and would like to know what people use for a
++ debugger. I tried typing "perldoc debug" and "perldoc debugger" and got
++ nothing.


I use my eyes and my mind.



Abigail


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

Date: Wed, 10 May 2000 15:55:17 -0600
From: "Bruce W. Lowther" <blowther@SpAmFiLtErmicron.com>
Subject: Re: What debugger do people use for Perl?
Message-Id: <8fclro$r0t$1@admin-srv3.micron.com>

Abigail wrote in message ...
>On Tue,
>02 May 2000 13:50:38 -0400, jkroger <jkrogerSPAMBLOCKER@earthlink.net>
wrote:
>++ Hi, I'm learning Perl, and would like to know what people use for a
>++ debugger. I tried typing "perldoc debug" and "perldoc debugger" and got
>++ nothing.
>
>
>I use my eyes and my mind.
>
>
>
>Abigail

perldoc perldebug

will get you the information that you seek, also try

http://www.cpan.org/authors/id/A/AE/AEPAGE/Devel-ptkdb-1.1066.tar.gz

It's an excellent graphical debugger using TK.

Once it's installed it's invoked by

perl -d:ptkdb myscript.pl







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

Date: Wed, 10 May 2000 19:23:49 +0100
From: "Bagsy" <news@theedgeofpanic.freeserve.co.uk>
Subject: Where's the FAQ?
Message-Id: <8fc9eg$2ot$1@news6.svr.pol.co.uk>

    Hi all,

    Just got here and was looking for the FAQ but I don't see it anywhere in
the last 400 headers. Can somebody post me a URL for the FAQ please?
    I was also looking for a couple of good tutes about DBI and SQL (figured
there'd be lots of info in the FAQ) so any suggestions of this nature would
also be appreciated. Thanks.
--
Bagsy




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

Date: Wed, 10 May 2000 22:46:48 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: Where's the FAQ?
Message-Id: <m3mjhsoicaocmhikoiq5ahv76nl1nnti44@4ax.com>

On Wed, 10 May 2000 19:23:49 +0100, "Bagsy"
<news@theedgeofpanic.freeserve.co.uk> wrote:

>    Hi all,
>
>    Just got here and was looking for the FAQ but I don't see it anywhere in
>the last 400 headers. Can somebody post me a URL for the FAQ please?
>    I was also looking for a couple of good tutes about DBI and SQL (figured
>there'd be lots of info in the FAQ) so any suggestions of this nature would
>also be appreciated. Thanks.

The faq was installed on your system when you installed Perl. Try
typing "perldoc perlfaq" at a command prompt.

Alternatively, the faq can be easily found from the Perl home page at
<http://www.perl.com>.

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: Wed, 10 May 2000 22:56:01 +0100
From: "Bagsy" <news@theedgeofpanic.freeserve.co.uk>
Subject: Re: Where's the FAQ?
Message-Id: <8fcluc$a2l$1@news6.svr.pol.co.uk>


Dave Cross <dave@dave.org.uk> wrote in message
news:m3mjhsoicaocmhikoiq5ahv76nl1nnti44@4ax.com...
> On Wed, 10 May 2000 19:23:49 +0100, "Bagsy"
> <news@theedgeofpanic.freeserve.co.uk> wrote:

> > Can somebody post me a URL for the FAQ please?

> The faq was installed on your system when you installed Perl. Try
> typing "perldoc perlfaq" at a command prompt.

    I haven't installed Perl on my system.

> Alternatively, the faq can be easily found from the Perl home page at
> <http://www.perl.com>.

    Thanks dude.

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

"I could be the catalyst that sparks the revolution, I could be an inmate in
a long-term institution" - Ian Dury [RIP]




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

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


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