[17543] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4963 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 24 18:05:37 2000

Date: Fri, 24 Nov 2000 15:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <975107112-v9-i4963@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 24 Nov 2000     Volume: 9 Number: 4963

Today's topics:
    Re: /s and $1 (Randy Galbraith)
    Re: Can regexps handle this type of parsing? <iltzu@sci.invalid>
    Re: Check for integer <iltzu@sci.invalid>
    Re: Check for integer (Garry Williams)
    Re: Check for integer (Anno Siegel)
    Re: Code trash (Mark W. Schumann)
    Re: FAST hex string to binary string conversion <nobody@nowhere.invalid>
        Found Error - Sorry (Florian Oefinger)
    Re: Go from decimal to hexadecimal. (M.J.T. Guy)
    Re: help with number comparsion (Adam Spragg)
        Help with regexp <a58289@yahoo.com>
    Re: Help with regexp <aqumsieh@hyperchip.com>
    Re: Help with regexp <aqumsieh@hyperchip.com>
        HTTP Post Help <wrwoodman@yahoo.com>
    Re: HTTP Post Help <brannon@lnc.usc.edu>
    Re: HTTP Post Help (Tad McClellan)
    Re: Need help with LPW (Mark W. Schumann)
    Re: Perl "save file" formatting text ... please assist <jean.zoch@utoronto.ca>
    Re: Perl "save file" formatting text ... please assist (Tad McClellan)
    Re: perl options (Tad McClellan)
        Problem w/ Meta Characters <wcsmith6@home.net>
    Re: Restrict HTTP daemon to a list of IP addresses (Mark W. Schumann)
    Re: Sort runtime 5.005 vs 5.004 <jpl@research.att.com>
    Re: Sort runtime 5.005 vs 5.004 elmo@iii.org.tw
        Splitting Strings <jean.zoch@utoronto.ca>
    Re: Strange behavior from localtime() Oct31 2000 or lat <softh@bellsouth.net>
    Re: Stripping carriage returns (Mark W. Schumann)
    Re: Stripping carriage returns <marcus@allinonemortgage.com>
        substituting a hash value with a regex? <webqueen@my-deja.com>
    Re: substituting a hash value with a regex? (Tad McClellan)
    Re: substituting a hash value with a regex? <aqumsieh@hyperchip.com>
    Re: substituting a hash value with a regex? (Garry Williams)
    Re: test post - dont read <bart.lateur@skynet.be>
    Re: Test to see if a file exists? <godoy@conectiva.com>
        UPS Tools <rwoodman@home.com>
    Re: writing system error messages to a logfile... (Mark W. Schumann)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 24 Nov 2000 20:43:45 +0000 (UTC)
From: randy.galbraith@pegs.com (Randy Galbraith)
Subject: Re: /s and $1
Message-Id: <8vmju1$1g29$1@freepress.anasazi.com>

All,

As promised, I'm getting back with an answer to my own question.  It turns 
out that one must be careful when using (...) for both grouping and back 
referencing purposes.  You'll notice my regexpr does this... (..(...)*), of 
course now the question becomes where does $1 and $2 backreference to?

Well in my case I didn't need to answer that question, instead, I skipped 
backreferecing on the inner parens, like this... (..(?:...)*).  Regexpr 
experts of course will laugh, but for me that was a tremendous advancement 
in my understanding, namely that "?:" removes the backreference :-)

- Randy

randy.galbraith@pegs.com wrote in <1103_974743149@rgalbraith>:

>Hello All,
>
>I'm having some trouble understanding how 'backreferences' work in 
>regular expressions.  I'm trying to modify a script that comes with 
>LXR (Linux Cross Referencer) to handle K&R style declarations.  
>I've paired my problem code do to this snippet...
>
>#!/usr/local/bin/perl -w
>use strict;
>
>my $bug = 1;
>my $contents = "int foo()\nchar *s;\n{}\nint bar()\n{}";
>my $count;
>
>sub wash 
>{
>  my $towash = $_[0];
>  #    $towash =~ s/[^\n]+//gs;
>  print "bw>$towash<\n" if ($bug);
>  $towash =~ tr/\n//cd;
>  print "aw>$towash<\n" if ($bug);
>  return($towash);
>}
>
>
>print "BEFORE>>$contents<<\n";
>$count = $contents =~ s/\)((\s*[A-Za-z0-9,_ 
>\t\*\[\]\n]{2,};)*)(\s*)\{/
>"\)".&wash($1).&wash($2)."{"/goe;
>print "AFTER>>$contents<<\n";
>print "count = $count\n";
>
>I know the s/ is a bit daunting, but essentially I'm trying to 
>identify all chars between ) and { and send them to 'wash' for 
>clean up.  Here is the output when I run this...
>
>BEFORE>>int foo()
>char *s;
>{}
>int bar()
>{}<<
>bw>
>char *s;<
>aw>
><
>bw>
>char *s;<
>aw>
><
>bw><
>aw><
>Use of uninitialized value at ./foo.pl line 12.
>bw><
>Use of uninitialized value at ./foo.pl line 13.
>Use of uninitialized value at ./foo.pl line 14.
>aw><
>Use of uninitialized value at ./foo.pl line 21.
>AFTER>>int foo()
> 
>{}
>int bar(){}<<
>count = 2
>
>The final output looks not too bad, except we've lost a new line 
>char in the 'int bar()\n{}', and this of course, causes LXR to 
>think identifiers are at different line numbers than they really 
>are. 
>
>I'm also surprised by what really gets passed to wash. As you can 
>see 4 calls are made, and '\nchar *s;' get passed twice, and 3 
>times it complains about unitialized values.  Finally, there is 1 
>complaint of unitialized value in the s/.
>
>Of course I'll keep working on this, and if I find an answer I'll 
>post it back here.  But if you have any insight on this it would be 
>greatly appreciated.  Thanks in advance.
>
>-Randy Galbraith
>Spammers please note: Spam/UCE is NOT welcome in my inbox.
>
>
>
>



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

Date: 24 Nov 2000 19:36:12 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Can regexps handle this type of parsing?
Message-Id: <975093720.14203@itz.pp.sci.fi>

In article <slrn91r795.ths.tadmc@magna.metronet.com>, Tad McClellan wrote:
>
>Can we count on a semicolon (outside of comments) marking the
>end of the statement?
>
>If so, then also no problem.
>
>(assuming that slurping the entire file into a scalar 
> is not a problem)

Why not set $/ = ";"?  Of course, if there might be semicolons within
comments, that special case would have to be handled.  Something like:

  $_ .= <> while m!/\*([^*]+|\*+[^*/])*$! and not eof();

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post
 something, we discuss its implications.  If the discussion happens to
 answer a question you've asked, that's incidental." -- nobull in clpm





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

Date: 24 Nov 2000 19:54:51 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Check for integer
Message-Id: <975095371.23841@itz.pp.sci.fi>

In article <8vlve3$89k$1@lublin.zrz.tu-berlin.de>, Anno Siegel wrote:
>at the remainder, which the %-operator gives you.  Observing the
>boolean qualities of numbers we get that "not $x % $y" is true
>exactly if $y divides $x (for $y != 0).

If only this worked.  Alas, it doesn't, not unless both $x and $y are
integers.  Maybe Perl 6 will have a sensibly defined modulus operator.

The obvious way to check whether a number is an integer in Perl is
simply $_ == int($_).  So $y divides $x if $x/$y == int($x/$y).

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post
 something, we discuss its implications.  If the discussion happens to
 answer a question you've asked, that's incidental." -- nobull in clpm





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

Date: Fri, 24 Nov 2000 20:41:39 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: Check for integer
Message-Id: <7oAT5.1611$xb1.97797@eagle.america.net>

On 24 Nov 2000 19:54:51 GMT, Ilmari Karonen <iltzu@sci.invalid> wrote:
>The obvious way to check whether a number is an integer in Perl is
>simply $_ == int($_).  So $y divides $x if $x/$y == int($x/$y).

As Anno Siegel pointed out to me in this thread, there may be a
problem with this approach due to floating point calculations.  You
probably need something like: 

  my $epsilon = 0.0005;
  print "is integer\n" if abs($_ - sprintf "%.0f", $_) < $epsilon;

-- 
Garry Williams


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

Date: 24 Nov 2000 22:39:36 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Check for integer
Message-Id: <8vmqn8$93l$1@lublin.zrz.tu-berlin.de>

Ilmari Karonen  <usenet11285@itz.pp.sci.fi> wrote in comp.lang.perl.misc:
>In article <8vlve3$89k$1@lublin.zrz.tu-berlin.de>, Anno Siegel wrote:
>>at the remainder, which the %-operator gives you.  Observing the
>>boolean qualities of numbers we get that "not $x % $y" is true
>>exactly if $y divides $x (for $y != 0).
>
>If only this worked.  Alas, it doesn't, not unless both $x and $y are
>integers.  Maybe Perl 6 will have a sensibly defined modulus operator.

Yes, I was actually assuming integer $x and $y, which I stated further
up in the snipped part.  As for the modulus operator, I've been
advocating the extension to reals (and a reasonable treatment of
signed operands) a long time.  Well, I did so once, a long time
ago...

Anno


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

Date: 24 Nov 2000 17:03:09 -0500
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Code trash
Message-Id: <8vmoit$lf7@junior.apk.net>

[Posted and emailed.]

In article <Xns8FF2AB87502188@24.128.8.202>,
Donkey_perlM <ghard296@jaminnet.com> wrote:
>I've been trying to get this trash load of code i wrote down to fast, CPU 
>friendly code. Unfortunately, I have failed miserably in my attempt.

[snip 50 lines of code]

Uh, what was the question?



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

Date: Fri, 24 Nov 2000 14:13:09 -0800
From: Nobody <nobody@nowhere.invalid>
Subject: Re: FAST hex string to binary string conversion
Message-Id: <241120001413099400%nobody@nowhere.invalid>

In article <8vm2ee$4k4$1@nnrp1.deja.com>, <nigel_elliot@my-deja.com>
wrote:

> I'm looking for some FAST routines to convert between hex and binary
> string representations of a number
> 
> eg   "123abc" <=> "000100100011101010111100"
> 
> My hex strings are long (100's of chars) and doing global substitutions
> on a line takes a great deal of time when you need to process millions
> of lines (which I do!)
> 
> Any advice welcome

pack/unpack


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

Date: Fri, 24 Nov 2000 22:03:20 +0100
From: FlorianOefinger@web.de (Florian Oefinger)
Subject: Found Error - Sorry
Message-Id: <1ekmfvr.1wdjugt17dn5fkN@pc19f1b0b.dip.t-dialin.net>

Florian Oefinger <FlorianOefinger@web.de> wrote:

found the solution. Sorry for useless posting!

Florian Oefinger


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

Date: 24 Nov 2000 19:13:17 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Go from decimal to hexadecimal.
Message-Id: <8vmekd$nsf$1@pegasus.csx.cam.ac.uk>

Logan Shaw <logan@cs.utexas.edu> wrote:
>In article <8uv9sh$66h$1@nnrp1.deja.com>,  <fallenang3l@my-deja.com> wrote:
>>I know how to do that using (s)printf, but it works only for one value.
>>For example:
>>
>>$myval = 20;
>>printf "%x", $myval;
>>
>>That works, but the problem is there may be a huge amount of decimal
>>number to convert into hexadecimal, and printf isn't cutting it.
>
>So put it in a loop.  Or, put it in a call to map():
>
>	@x = ( 0 .. 100 );
>	@y = map (sprintf ("%x", $_), @x);
>	foreach (@y) { print "$_\n"; }
>

Another useful technique is to generate the sprintf() pattern dynamically,
for example

	printf "%x\n" x scalar(@array), @array;


Mike Guy


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

Date: 24 Nov 2000 19:11:53 GMT
From: atspragg@garbanzo.engr.ucdavis.edu (Adam Spragg)
Subject: Re: help with number comparsion
Message-Id: <8vmehp$73c$1@mark.ucdavis.edu>

jim flaherty (kf4dmb@net-magic.net) wrote:
: my code dont seam to work :

Among other things...

: $count = "";
: $count++;
: if ($count eq 1) {
: #do this
: }

Seems to work for me...  I'd change it to "$count == 1", but it's not 
necessary.

Adam


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

Date: Fri, 24 Nov 2000 18:57:24 GMT
From: Aitor Garcia <a58289@yahoo.com>
Subject: Help with regexp
Message-Id: <8vmdmk$bo2$1@nnrp1.deja.com>

Hi everybody,

I'm new in Perl and need help with a little program.

The program has to remove all the lines in file_in
that have zeros, i.e, 0.00000000 0.0000000,
where the number of decimals can be variable.
When it is found a line with a number different than zeros,
it must display all the following lines.

Here's the code,
But somehow the reg exp that I've written does not match what
I want. It matches everything even the lines that I do not
want. Can anyone explain me why ?.

#!/usr/bin/perl -w
#Perl script to eliminate the all the first 0s.
$file_in = "file_in.dump";
$file_out = "file_out.dump";
open(F_IN,"<$file_in");
open(F_OUT,">$file_out");
$found =  0;
while(<F_IN>)
{

  if($_ !~ /0\.\0*\s\0\.\0*/){
    $found = 1;
  }

  if($found){
  print F_OUT "$_";
  }
}

Thanks for any help,

Best Regards,

Aitor


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


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

Date: Fri, 24 Nov 2000 19:53:05 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Help with regexp
Message-Id: <7a1yw16tb0.fsf@merlin.hyperchip.com>


Aitor Garcia <a58289@yahoo.com> writes:

> The program has to remove all the lines in file_in
> that have zeros, i.e, 0.00000000 0.0000000,
> where the number of decimals can be variable.

> open(F_IN,"<$file_in");
> open(F_OUT,">$file_out");

It's always a good idea to verify that your open()s succeeded before you
attempt to read/write from/to your files:

	open(F_IN, $file_in)     or die "Can't open $file_in : $!";
	open(F_IN, ">$file_out") or die "Can't open $file_out: $!";

> $found =  0;
> while(<F_IN>)
> {
> 
>   if($_ !~ /0\.\0*\s\0\.\0*/){

Why are you escaping the 0's? Remove them and your regexp will
match. You might also want to anchor your regexp using ^ and $. Checkout
perlre for more info.

--Ala


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

Date: Fri, 24 Nov 2000 21:05:02 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Help with regexp
Message-Id: <7avgtd5beo.fsf@merlin.hyperchip.com>


Ala Qumsieh <aqumsieh@hyperchip.com> writes:

> 	open(F_IN, $file_in)     or die "Can't open $file_in : $!";
> 	open(F_IN, ">$file_out") or die "Can't open $file_out: $!";

That second F_IN should be  F_OUT, of course.

--Ala


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

Date: Fri, 24 Nov 2000 19:40:29 GMT
From: Randall Woodman <wrwoodman@yahoo.com>
Subject: HTTP Post Help
Message-Id: <3A1EC482.3B661B04@yahoo.com>

I've been looking through the documentation both online and within
activeperl's documentation.  But I guess I don't know where to look to find
the answer.  Here is the real root of the problem I am trying to solve.

UPS offers a set of tools that one can use and incorporate into one's own
CGI based web pages.  They describe how data are formatted for both sending
and receiving.  The transmissions occur via http post on port 80.  (They
provide sample code in Java.  However, all my code is written in perl.)
So, my question becomes, how do I call some program on another system using
http post via port 80?

What modules do I use?  What functions do I call? Where would I find these
functions documented?  After I send something via this call, how do I get a
response?  I know what the system I call will be sending, I just don't know
how to receive it.

Would some kind soul point me in the right direction?  Also, any sample
code would be greatly appreciated.

Thanks
-=} Randall {=-




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

Date: Fri, 24 Nov 2000 19:55:31 GMT
From: Terrence Brannon <brannon@lnc.usc.edu>
Subject: Re: HTTP Post Help
Message-Id: <lbd7fli1qt.fsf@lnc.usc.edu>

hi, type perldoc lwpcook

then tyhpe perldoc LWP

then join the LWP mailing list.

> I've been looking through the documentation both online and within
> activeperl's documentation.  But I guess I don't know where to look to find
> the answer.  Here is the real root of the problem I am trying to solve.
> 
> UPS offers a set of tools that one can use and incorporate into one's own
> CGI based web pages.  They describe how data are formatted for both sending
> and receiving.  The transmissions occur via http post on port 80.  (They
> provide sample code in Java.  However, all my code is written in perl.)
> So, my question becomes, how do I call some program on another system using
> http post via port 80?
> 
> What modules do I use?  What functions do I call? Where would I find these
> functions documented?  After I send something via this call, how do I get a
> response?  I know what the system I call will be sending, I just don't know
> how to receive it.
> 
> Would some kind soul point me in the right direction?  Also, any sample
> code would be greatly appreciated.
> 
> Thanks
> -=} Randall {=-
> 
> 

-- 
Terrence Brannon


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

Date: Fri, 24 Nov 2000 14:40:32 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: HTTP Post Help
Message-Id: <slrn91th1g.9p.tadmc@magna.metronet.com>


[ alt.perl removed from Newsgroups ]


Randall Woodman <wrwoodman@yahoo.com> wrote:

>So, my question becomes, how do I call some program on another system using
>http post via port 80?


That is the normal port for web servers, so just pretend there
was no mention of port numbers  :-)

ie. They are basically saying that it is a Regular Old Webserver.


>What modules do I use?  


LWP::UserAgent probably.

That is part of the 'libwww' bundle from CPAN.


>What functions do I call? Where would I find these
>functions documented?  


After you have installed the module:

   perldoc LWP::UserAgent 


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 24 Nov 2000 16:47:55 -0500
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Need help with LPW
Message-Id: <8vmnmb$i68@junior.apk.net>

In article <1ekm9vu.1cfhp0ci7fv70N@p3e9ed366.dip.t-dialin.net>,
Florian Oefinger <FlorianOefinger@web.de> wrote:
>require LWP::UserAgent;
>
>$ua = new LWP::UserAgent;
>
>$request = new HTTP::Request('POST', 'http://www.etc.com/login.cgi',
>[username =>'Name',password =>'Pass',]);
>$response = $ua->request($request);
>
>If i try to run this script reports:
>Can't call method "clone" on unblessed reference.
>File 'lib:HTTP:Message.pm'; Line 47
>
>What's wrong in my code? Is it the way i pass the POST values?

I would say you're missing -w and use strict.



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

Date: Fri, 24 Nov 2000 18:07:47 GMT
From: "Jean" <jean.zoch@utoronto.ca>
Subject: Re: Perl "save file" formatting text ... please assist
Message-Id: <G4JJp0.EoH@campus-news-reading.utoronto.ca>

Hello,


> My write code :
>
> open(TOFILE,">../special.dat");
>   print TOFILE $FORM_DATA{"special"};
> close(TOFILE);

I would try:

#code

# this replaces all line breaks  with <BR>
$FORM_DATA{"special"} =~ s/\n/\<BR\>/g;

open(TOFILE,">../special.dat");
 print TOFILE $FORM_DATA{"special"};
close(TOFILE);

#end code

- Jean




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

Date: Fri, 24 Nov 2000 14:22:10 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl "save file" formatting text ... please assist
Message-Id: <slrn91tfv2.9p.tadmc@magna.metronet.com>

Jean <jean.zoch@utoronto.ca> wrote:

># this replaces all line breaks  with <BR>
>$FORM_DATA{"special"} =~ s/\n/\<BR\>/g;
                               ^   ^
                               ^   ^

Angle brackets are not special in regular expressions, and
therefore do not need to be backslashed.


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 24 Nov 2000 14:33:14 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: perl options
Message-Id: <slrn91tgjq.9p.tadmc@magna.metronet.com>


[ Yet anotherJeopardectomy performed ]


Flint Slacker <flint@flintslacker.com> wrote:

>On Fri, 24 Nov 2000 12:20:43 -0500, tadmc@metronet.com (Tad McClellan)
>wrote:
>>
>>[ Jeopardectomy performed ]
>>
>>Flint Slacker <flint@flintslacker.com> wrote:
>>>On Thu, 23 Nov 2000 14:03:44 -0500, tadmc@metronet.com (Tad McClellan)
>>>wrote:
>>>
>>>>Flint Slacker <flint@flintslacker.com> wrote:
>>>>
>>>>>can improve performance by turning off certain things
>>>>                            ^^^^^^^^^^^
>>>>>like syntax checking
>>>>      ^^^^^^^^^^^^^^^
>>>>
>>>>Is that a joke?
>>>>
>>>>(if so, you forgot the smiley. if not, then you have a severe
>>>> dearth of knowledge about how programming computers works.
>>>>)
>>
>>>No reason to be an asshole Tad!
>>
>>I guess then, that I can imply that you did not forget a smiley?
>>
>>In that case, we could help you out by describing why "turning
>>off syntax checking" is an absurd concept.
>>
>>But I'm disinclined to help now anyway, you seem determined to
>>maintain your current level of knowledge. 

>You didn't help Tad, 


Well yes. Because I couldn't tell if you were joking or not.
(and the only other help would have been pointing out
 perlrun.pod, and someone had already done that, so I
 didn't repeat it.
)

So I asked if you were joking or not.


>you tried to make an ass of me


No I didn't.

I said that you did not know something (the role of "syntax"
in computer programming).

Not knowing something does not make you an ass.

Everybody "doesn't know something" when they set out to learn
something new. It's to be expected. Getting mad when someone
says that there is something that you don't know about is an
unproductive attitude.

If, rather than resorting to name calling, you had said:

   so tell me what I don't know about programming computers.

Then I would have explained a programming fundamental that
you appear unaware of.

But instead you only got killfiled.

Good luck though!


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 24 Nov 2000 20:37:09 GMT
From: "W. Chad Smith" <wcsmith6@home.net>
Subject: Problem w/ Meta Characters
Message-Id: <VjAT5.112841$hD4.27710239@news1.rdc1.mi.home.com>

I'm reading in information that may contain meta characters ( /, (, ),
etc.)...  So I am using the quotemeta function:

            $accountnoweb = quotemeta $accountnoweb;

            foreach $line(@lines)
                {

                 ($laccountno, $lcompany, $laddress1, $laddress2, $lcity,
$lstate, $lzip, $lphone1, $lfax,
                  $lkey1, $lkey4) = split /~/,$line;

              $laccountno = quotemeta $laccountno;

              print "'$laccountno' '$accountnoweb'<BR>";

              if ( $laccountno =~ $accountnoweb ) {

When I use it however I do not get matches even when the print line comes
out as:

'99072348895\%Q9F3\+' '99072348895\%Q9F3\+'

ie... It's a match but Perl isn't thinking so....


TIA

Chad




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

Date: 24 Nov 2000 16:57:44 -0500
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Restrict HTTP daemon to a list of IP addresses
Message-Id: <8vmo8o$k95@junior.apk.net>

In article <slrn91kdst.gsf.rgarciasuarez@rafael.kazibao.net>,
Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
>I'm writing a small HTTP daemon using the HTTP::Daemon class. I want to
>know what is the preferred way to restrict it to accept connections only
>from a specified list of IP addresses (e.g. 127.0.0.1 and 1.2.3.*).
>
>Is the following code correct?
>
>  while (my $c = $daemon->accept) {
>    if ($c->peerhost !~ /^(127\.0\.0\.1|1\.2\.3\.\d+)$/) {
>      close $c; next;
>    }
>    # Handle connection...
>  }

That seems to be close to right.

But think about how the compiler will parse

       \.1|1\.

in your regexp.



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

Date: Fri, 24 Nov 2000 17:18:36 GMT
From: "John P. Linderman" <jpl@research.att.com>
Subject: Re: Sort runtime 5.005 vs 5.004
Message-Id: <3A1EA2EC.2FE32862@research.att.com>

Jim Harrison wrote:

> Hi, I work for Texas Instruments.  We have been using perl for many years.
> We current are running production batch jobs where we sort large files with
> Perl, by reading into an array, sorting the array and writing out array.
> The code in question is:
>
> ########################################################
> # Read stdin into array
> @array = (<STDIN>);
>
> # sort array using normal sort
> # and print to stdout
>
> print sort(@array);
> ##########################################################
>
> We are sorting a file that is 162.5 MB with 638,278 records.
>
> Running the above on Solaris 2.6 using perl 5.00404 it takes    56 SECONDS
> to run.
>
> Running the above on Solaris 2.6 using perl 5.00503 it takes 3360 SECONDS to
> run.
>
> Using /usr/proc/bin/pstack against the program when it is running I see:
>    - Perl 5.00404 module 'Perl_pp_sort' is calling 'qsort'
>    - Perl 5.00503 module 'Perl_pp_sort' is calling 'sortsv'
>
> Now obviously 'qsortsv' isn't as good for our situation as 'qsort'.  Is
> there anyway to build 5.005 so that it calls the old qsort?
>
> Regards,
> Jim Harrison

To get behavior spreads of this magnitude (including those posted
elsewhere about Sun's /bin/sort), I'd have to guess that your input
is not random to start with, and, in fact, exhibits a lot of pre-exisiting
order that is triggering some well-documented problems with
various qsort implementations.  You *could* try randomizing the
array before sorting it, and seeing if that (O(N)) step reduces the
sort time.

In answer to your original question, you *can* do a sort transplant
on pp_ctl.c.   But if you go this path, you might want to transplant
the merge sort that will (eventually) replace the existing qsort,
so you're relying on an implementation that isn't there yet,
instead of one that's no longer there :-).  Take this offline and
contact me by email if you want to give that a shot.  -- jpl



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

Date: Fri, 24 Nov 2000 23:04:58 +0000 (UTC)
From: elmo@iii.org.tw
Subject: Re: Sort runtime 5.005 vs 5.004
Message-Id: <8vms6q$dej$1@news.seed.net.tw>

John P. Linderman <jpl@research.att.com> wrote:
[snip]
> In answer to your original question, you *can* do a sort transplant
> on pp_ctl.c.   But if you go this path, you might want to transplant
> the merge sort that will (eventually) replace the existing qsort,
> so you're relying on an implementation that isn't there yet,
> instead of one that's no longer there :-).  Take this offline and
> contact me by email if you want to give that a shot.  -- jpl

I know that there are some qsort implementations which are
inefficient under certain situation, but there are others
that solve these problems.  One of the better qsort implementations
I'm aware of is the one in *BSD:

ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/src/lib/libc/stdlib/qsort.c

For comparison-based sort, due to my limited knowledge, I can
hardly believe there's faster sort than quicksort in terms of
real world performance.  Is there a freely available merge
sort implementation so that I can test it?

Thanks in advance.

Chih-Cherng Chin
elmo@iii.org.tw


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

Date: Fri, 24 Nov 2000 20:16:11 GMT
From: "Jean" <jean.zoch@utoronto.ca>
Subject: Splitting Strings
Message-Id: <G4Jpn1.1n2@campus-news-reading.utoronto.ca>

Hello all,

Anyone have any ideas on how I can split a string that looks like:

$string = BLAH BLAH <BODY stuff="stuff" foo="bar"> BLAH BLAH ";

into an array that looks like:

('BLAH BLAH <BODY stuff="stuff" foo="bar">', ' BLAH BLAH ');

I.E. I would like to split the string right after the close of the BODY tag.

Thanks a bunch!

Jean




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

Date: Fri, 24 Nov 2000 14:31:52 -0500
From: Matt <softh@bellsouth.net>
Subject: Re: Strange behavior from localtime() Oct31 2000 or later
Message-Id: <3A1EC228.A09D7532@bellsouth.net>

This is a multi-part message in MIME format.
--------------0397CA9360873608546D2285
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi Bart,
It may be on the DST date, I haven't heard of it before. I haven't had the
time to try and take localtime() to another decimal place. I believe there
are only about 100 possibilities so its not a huge task. I can't help
thinking that some of the more skilled folks here are quietly chuckling
about my post, as I am sure there is a much simple way to approach this,
but I am just learning programming. Hey Joe I might try your script later
tonight, gotta attend the turkey now, I know a day late, I worked at the
day job yesterday.

Later
Matt

Bart Lateur wrote:

> Matt wrote:
>
> >But dang if things
> >don't seem to fall apart on/around Halloween 2000.
>
> I've seen this mentioned before. Daylight Savings Time? Isn't that the
> weekend...
>
> --
>         Bart.

--------------0397CA9360873608546D2285
Content-Type: text/x-vcard; charset=us-ascii;
 name="softh.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Matt
Content-Disposition: attachment;
 filename="softh.vcf"

begin:vcard 
n:Hill;Matthew
x-mozilla-html:TRUE
url:everyquest.net
org:EveryQuest.Net
adr:;;address confidental for now;Manitou;Ky;;
version:2.1
email;internet:matt@everyquest.net
title:COO
fn:Matt
end:vcard

--------------0397CA9360873608546D2285--



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

Date: 24 Nov 2000 16:50:37 -0500
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Stripping carriage returns
Message-Id: <8vmnrd$iq2@junior.apk.net>

In article <GmyT5.4462$FO1.145352@brie.direct.ca>,
Marcus <marcus@allinonemortgage.com> wrote:
>Illegal character \015 (carriage return) at ./Library/web_store.setup.db
>line 4.
>(Maybe you didn't strip carriage returns after a network transfer?)

Well, um, did you strip carriage returns after a network transfer?

>Here is line 4 in the main script:
>
>&require_supporting_libraries (__FILE__, __LINE__,
>       "./Library/web_store.setup.db");
>
>Does this make any sense to anyone. It is probably something I am
>overlooking. Any help or direction appreciated. If you need more info please
>let me know. Thanks.

Perl doesn't like seeing carriagereturn/linefeed at the end of line of
code.  Perl wants to see just a linefeed.



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

Date: Fri, 24 Nov 2000 14:47:36 -0800
From: "Marcus" <marcus@allinonemortgage.com>
Subject: Re: Stripping carriage returns
Message-Id: <n9CT5.4711$FO1.149753@brie.direct.ca>

I know it might sound like another stupid question to you but how would I
strip carriage returns after a network transfer (I have looked for
documentation on how to do this and can't find any)? I have never run into
this I write all my perl code in a plain text file and upload using cuteftp.
I have never had a problem like this before. Thanks in advance.

"Mark W. Schumann" <catfood@apk.net> wrote in message
news:8vmnrd$iq2@junior.apk.net...
> In article <GmyT5.4462$FO1.145352@brie.direct.ca>,
> Marcus <marcus@allinonemortgage.com> wrote:
> >Illegal character \015 (carriage return) at ./Library/web_store.setup.db
> >line 4.
> >(Maybe you didn't strip carriage returns after a network transfer?)
>
> Well, um, did you strip carriage returns after a network transfer?
>
> >Here is line 4 in the main script:
> >
> >&require_supporting_libraries (__FILE__, __LINE__,
> >       "./Library/web_store.setup.db");
> >
> >Does this make any sense to anyone. It is probably something I am
> >overlooking. Any help or direction appreciated. If you need more info
please
> >let me know. Thanks.
>
> Perl doesn't like seeing carriagereturn/linefeed at the end of line of
> code.  Perl wants to see just a linefeed.
>




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

Date: Fri, 24 Nov 2000 20:12:55 GMT
From: webqueen, queen of the web <webqueen@my-deja.com>
Subject: substituting a hash value with a regex?
Message-Id: <8vmi46$eij$1@nnrp1.deja.com>



  $cat=s/dog/$h{k}/;
nor
  $cat=s/dog/$h\{k\}/;

produce the desired substitution, and man perlre seems to offer no
illumination. I'm using:

  $h=$h{k};
  $cat=s/dog/$h/;

Surely the gurus herein can enlighten this wayward PerlChild?



--
Time is nature's way of preventing everything from happening at once.


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


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

Date: Fri, 24 Nov 2000 14:56:17 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: substituting a hash value with a regex?
Message-Id: <slrn91thv1.gi.tadmc@magna.metronet.com>

webqueen, queen of the web <webqueen@my-deja.com> wrote:
>
>
>  $cat=s/dog/$h{k}/;
       ^
       ^
>nor
>  $cat=s/dog/$h\{k\}/;
       ^
       ^
>produce the desired substitution, and man perlre seems to offer no
>illumination. I'm using:
>
>  $h=$h{k};
>  $cat=s/dog/$h/;
       ^
       ^
>Surely the gurus herein can enlighten this wayward PerlChild?


   s/=/ =~ /;   # and try it again with the proper operators :-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 24 Nov 2000 21:04:12 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: substituting a hash value with a regex?
Message-Id: <7ay9y95bg2.fsf@merlin.hyperchip.com>


webqueen, queen of the web <webqueen@my-deja.com> writes:

>   $cat=s/dog/$h{k}/;
> nor
>   $cat=s/dog/$h\{k\}/;
> 
> produce the desired substitution, 

Well, what is your desired substitution?
Here, you are setting $cat to the result of the substitution on the $_
variable. Perhaps you meant:

	$cat =~ s/dog/$h{k}/;

(you forgot the tilde ~).

>                                   and man perlre seems to offer no
> illumination. I'm using:

It tells you to check perlop, which pretty much describes everything.

>   $h=$h{k};
>   $cat=s/dog/$h/;
> 
> Surely the gurus herein can enlighten this wayward PerlChild?

You should read perlop and perlre again to understand the difference
between = and =~. You should also start using the '-w' switch, which
would have warned you about this (if $_ was undefined).

--Ala


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

Date: Fri, 24 Nov 2000 21:18:09 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: substituting a hash value with a regex?
Message-Id: <lWAT5.1614$xb1.97854@eagle.america.net>

On Fri, 24 Nov 2000 20:12:55 GMT, webqueen, queen of the web
<webqueen@my-deja.com> wrote:
>  $cat=s/dog/$h{k}/;
>nor
>  $cat=s/dog/$h\{k\}/;
>
>produce the desired substitution, 

Each of those substitute in the $_ variable and set $cat to the number
of substitutions made or the null string, if no substitution was made.  
I suspect you did not want that, but it's not clear.  

You probably wanted

  $cat =~ s/dog/$h{k}/;

which would alter the string $cat.  

Your second version is really confused.  It asks for the value of $h
followed by the string `{k}' to be substituted in $_.  The second part
of the s/// operator is just a string similar to double quoted
strings.  (Usually, that is.)  

Enabling warnings and use strict would probably have been
enlightening on that second try.  

See the perlop manual page for details.  

>and man perlre seems to offer no
>illumination. I'm using:
>
>  $h=$h{k};
>  $cat=s/dog/$h/;

Again, the substitution is done in the $_ variable's value -- not in
$cat.  The perlop manual page discusses the binding operator `=~'.  

-- 
Garry Williams


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

Date: Fri, 24 Nov 2000 19:56:28 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: test post - dont read
Message-Id: <pvht1tcdcsj6nesb41igr8bk083sm5r09m@4ax.com>

Anno Siegel wrote:

>There are newsgroups for testing.  They have "test" in their name.

Yeah, like "alt.comp.lang.perl.test".           ;-)

-- 
	Bart.


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

Date: 24 Nov 2000 20:34:27 -0200
From: Jorge Godoy <godoy@conectiva.com>
Subject: Re: Test to see if a file exists?
Message-Id: <3a1eecf3$1@news.terra.com.br>

On Fri, 24 Nov 2000, rev260@home.com wrote:
> If $date_1.jpg exists I want to print out a link to it...how can I
> check if it does?

perldoc perlfunc


See you,
-- 
Godoy. <godoy@conectiva.com>

Departamento de Publicações       Conectiva S.A.
Publishing Department             Conectiva Inc.


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

Date: Fri, 24 Nov 2000 19:28:17 GMT
From: Randall Woodman <rwoodman@home.com>
Subject: UPS Tools
Message-Id: <3A1EC1A6.7A4B3DF1@home.com>

Has anyone used the UPS E-Commerce tools using perl?  If so, I have some
questions.

Thanks
-=} Randall {=-



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

Date: 24 Nov 2000 17:01:00 -0500
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: writing system error messages to a logfile...
Message-Id: <8vmoes$kug@junior.apk.net>

In article <8vc476$s2$1@nnrp1.deja.com>,  <akothek@my-deja.com> wrote:
>newbie q?
>
>i'm trying to run a simple perl program in which the system error
>messages (on unix) are written to a logfile...
>
>here's what i do
>open(LOGFILE, "> logfile.log">) || die "couldn't open logfile";
>print LOGFILE $!

That won't even compile.

>this does not do anything and the error message is written to the
>shell...how do i get it to write out (pipe)the message to the
>logfile???

What makes you say it doesn't do anything?  Have you looked in the
file?  Have you checked for compile-time errors?  Have you used -w
and strict?



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

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


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