[17169] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4581 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 11 06:05:33 2000

Date: Wed, 11 Oct 2000 03:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <971258709-v9-i4581@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 11 Oct 2000     Volume: 9 Number: 4581

Today's topics:
        A lot of s///g; feels like a slow idea. <webmaster@ostas.lu.se>
    Re: A lot of s///g; feels like a slow idea. (Björn Nilsson)
    Re: A lot of s///g; feels like a slow idea. (Björn Nilsson)
        A problem with parsing <celliot@tartarus.uwa.edu.au>
        Blank line appending data to file <nige@npay.freeserve.co.uk>
    Re: Convert array to string? <bugfixxer@yahoo.com>
    Re: Convert array to string? (Rafael Garcia-Suarez)
        dababases and problems with 5.6.0 <jlopez@lingua.fil.ub.es>
    Re: Defining Headers for Module Mail::Mailer <dhighley@mail.highley-recommended.com>
    Re: Different Ways to Obtain a Client`s IP ? nobull@mail.com
    Re: how to remove unprintable  chars with Perl script <krahnj@acm.org>
    Re: Is perl object oriented? nobull@mail.com
    Re: Is perl object oriented? (brian d foy)
        Making this match better (que. about regexp and arrayha <webmaster@ostas.lu.se>
    Re: Making this match better (que. about regexp and arr (Rafael Garcia-Suarez)
    Re: mod_perl variables nobull@mail.com
    Re: OPEN file efficiancy issue, nobull@mail.com
    Re: perl 5.6, Net::POP3, database files, and more <jlopez@lingua.fil.ub.es>
    Re: perl resource <lr@hpl.hp.com>
    Re: Problem with duplicate entries in database (Anthony Peacock)
    Re: Reading a whole file into a string <g.soper@soundhouse.co.uk>
        Reg exp help a94eribe@my-deja.com
    Re: substring search <lr@hpl.hp.com>
    Re: Trying to add a service in win32 env. <carvdawg@patriot.net>
    Re: Writing multple lines to a file at once? <lr@hpl.hp.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 11 Oct 2000 10:01:10 +0200
From: Jimmy Lantz <webmaster@ostas.lu.se>
Subject: A lot of s///g; feels like a slow idea.
Message-Id: <39E41E37.3DAA1170@ostas.lu.se>

Hi,
I have the sub below and it's full of s///g; I think I've seen a better
way to do this somewhere,
but since I only pass a little line (with about 20 chars) to it so 
I dont suffer that much but I would still like to improve this sub a little.
So pls. come with suggestions if you know any.
Regards
Jimmy Lantz

sub convertdia2html
{
my($line) = @_ ;
$line =~ s/à/\&agrave;/g;
$line =~ s/á/\&aacute;/g;
$line =~ s/â/\&acirc;/g;
$line =~ s/ä/\&auml;/g;
$line =~ s/à/\&agrave;/g;
$line =~ s/á/\&aacute;/g;
$line =~ s/â/\&acirc;/g;
$line =~ s/ä/\&auml;/g;
$line =~ s/è/\&egrave;/g;
$line =~ s/é/\&eacute;/g;
$line =~ s/ê/\&ecirc;/g;
$line =~ s/ë/\&euml;/g;
$line =~ s/È/\&Egrave;/g;
$line =~ s/É/\&Eacute;/g;
$line =~ s/Ê/\&Ecirc;/g;
$line =~ s/Ë/\&Euml;/g;
$line =~ s/ì/\&igrave;/g;
$line =~ s/î/\&icirc;/g;
$line =~ s/í/\&iacute;/g;
$line =~ s/ï/\&iuml;/g;
$line =~ s/Ì/\&Igrave;/g;
$line =~ s/Î/\&Icirc;/g;
$line =~ s/Í/\&Iacute;/g;
$line =~ s/Ï/\&Iuml;/g;
$line =~ s/ò/\&ograve;/g;
$line =~ s/ó/\&oacute;/g;
$line =~ s/ô/\&ocirc;/g;
$line =~ s/ö/\&ouml;/g;
$line =~ s/ù/\&ouml;/g;
$line =~ s/ú/\&ugrave;/g;
$line =~ s/û/\&uacute;/g;
$line =~ s/ü/\&uuml;/g;
$line =~ s/Ò/\&Ograve;/g;
$line =~ s/Ó/\&Oacute;/g;
$line =~ s/Ô/\&Ocirc;/g;
$line =~ s/Ö/\&Ouml;/g;
$line =~ s/Ù/\&Uuml;/g;
$line =~ s/Ú/\&Ugrave;/g;
$line =~ s/Û/\&Uacute;/g;
$line =~ s/Ü/\&Uuml;/g;  
return $line;
}


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

Date: Wed, 11 Oct 2000 08:24:50 GMT
From: bjorn.nilsson@bct.ericsson.se (Björn Nilsson)
Subject: Re: A lot of s///g; feels like a slow idea.
Message-Id: <39e4239d.518480505@news.ericsson.se>

Hi!

It seems like what you are trying to do is done in the module
HTML::Entities. Browsing that particular file (Entities.pm) seems to
do just about the same as you are doing, except that a hash of all the
entities is defined and then referenced.

Björn

On Wed, 11 Oct 2000 10:01:10 +0200, Jimmy Lantz
<webmaster@ostas.lu.se> wrote:

>Hi,
>I have the sub below and it's full of s///g; I think I've seen a better
>way to do this somewhere,
>but since I only pass a little line (with about 20 chars) to it so 
>I dont suffer that much but I would still like to improve this sub a little.
>So pls. come with suggestions if you know any.
>Regards
>Jimmy Lantz
>
>sub convertdia2html
>{
>my($line) = @_ ;
>$line =~ s/à/\&agrave;/g;
 ...
[snip}
 ...
>$line =~ s/Ü/\&Uuml;/g;  
>return $line;
>}



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

Date: Wed, 11 Oct 2000 08:25:36 GMT
From: bjorn.nilsson@bct.ericsson.se (Björn Nilsson)
Subject: Re: A lot of s///g; feels like a slow idea.
Message-Id: <39e423f3.518565778@news.ericsson.se>

Hi!

It seems like what you are trying to do is done in the module
HTML::Entities. Browsing that particular file (Entities.pm) seems to
do just about the same as you are doing, except that a hash of all the
entities is defined and then referenced.

Björn

On Wed, 11 Oct 2000 10:01:10 +0200, Jimmy Lantz
<webmaster@ostas.lu.se> wrote:

>Hi,
>I have the sub below and it's full of s///g; I think I've seen a better
>way to do this somewhere,
>but since I only pass a little line (with about 20 chars) to it so 
>I dont suffer that much but I would still like to improve this sub a little.
>So pls. come with suggestions if you know any.
>Regards
>Jimmy Lantz
>
>sub convertdia2html
>{
>my($line) = @_ ;
>$line =~ s/à/\&agrave;/g;
 ...
[snip}
 ...
>$line =~ s/Ü/\&Uuml;/g;  
>return $line;
>}



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

Date: Wed, 11 Oct 2000 16:31:58 +0800
From: "Cameron Elliott" <celliot@tartarus.uwa.edu.au>
Subject: A problem with parsing
Message-Id: <39e425dd$0$1464@echo-01.iinet.net.au>

I am having the following problem.

I want to read a file into a string then modify part of it.

I am searching for the \\$rtf_key_ref->[15]
then I want to find the first occurance of \\$rtf_key_ref->[14]
and then copy all the data up until the second occurance of
\\$rtf_key_ref->[14]
then I want to insert $summary_ref->{'BUF'}[$i][$j] in front of each
occurance of \cell incrementing $j each time.
Given.
$rtf_key_ref->[15] = s23
$rtf_key_ref->[14] = s24
$summary_ref->{'BUF'}[0][0] = 'Group'
$summary_ref->{'BUF'}[0][1] = 'Buffer'
$summary_ref->{'BUF'}[1][0] = 'Data'
$summary_ref->{'BUF'}[1][1] = 'Something'
ie..
\s23\sadsadrrwe\s24\asddsasdadsads \cell\sdsad \cell\sdsadsa \cell
=> should end up like
\s23\sadsadrrwe\s24\asddsasdadsads Group\cell\sdsadBuffer\cell\
then save that string and append the result string each time I do it.
Then I want to insert that set of strings back into the original string in
replacement of the string that was taken out.

Thus:
 .....
\s23........(\s24..................)\s24             - get whats in the
brackets
 .......
then
Inside the brackets
\s24......... \cell.....\cell...... ->
\s24......... Group\cell.....Buffer\cell......
then again to
\s24......... Data\cell.....Something\cell..
ending up with
 .....
\s23...\s24..... Group\cell.....Buffer\cell.....\s24....
Data\cell....Something\cell..\s24
 .......

If you can follow that then
This is what I have thus far but Doesn't work:

I want to

    if ($content =~ /\\$rtf_key_ref->[15]/g)
    {
    $temp3 = $content;
    $temp3 =~ /\\$rtf_key_ref->[14](.*?\\$rtf_key_ref->[14])/s;
      $temp1 = $1;
      $temp6 = $temp1;
      foreach $var (keys %summary_ref)
      {
       for ($i=0;$i<=$#{$summary_ref->{'BUF'}};$i++)
       {
       $temp1 = $temp6; # reset the string to the original for editing again
        #insert BUF infront of first occurance of \cell
        $temp1 =~ s/(\\cell[\s|\\]?)/BUF$1/g;
        #insert $summary_ref->{'BUF'}[$i][0] infront of second occurance of
\cell .....
        $temp1 =~ s/(\\cell[\s|\\]?)/$summary_ref->{'BUF'}[$i][0]$1/g;
        $temp1 =~ s/(\\cell[\s|\\]?)/$summary_ref->{'BUF'}[$i][1]$1/g;
        $temp1 =~ s/(\\cell[\s|\\]?)/$summary_ref->{'BUF'}[$i][2]$1/g;
        $temp1 =~ s/(\\cell[\s|\\]?)/$summary_ref->{'BUF'}[$i][3]$1/g;
    #copy the resultant string on the end of $temp2 so it can be inserted
back into the main string at the end
     $temp2 = $temp2.$temp1;
       }
      }
    #substitute the modified string for the string taken originally.
      $content =~
s/\\$rtf_key_ref->[15].*$rtf_key_ref->[14](.*?\\$rtf_key_ref->[14])/$temp2/s
;
    }

Any Help if you cna understand that would be great.
Otherwise I will have to break it into smaller problems..

ta.
Cameron




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

Date: Tue, 10 Oct 2000 18:14:46 +0100
From: "Nige P" <nige@npay.freeserve.co.uk>
Subject: Blank line appending data to file
Message-Id: <8rvips$uog$1@newsg1.svr.pol.co.uk>

Can anyone enlighten me ?
I am returning the contents of a file xxxx until a $ is detected.
This data is then appended into another file yyyy.
 
However each time this occurs I get a blank line between
the data.
 
Many thanks for any input.
Here's the full script....... and it's the last 4 lines which cause the
problem.

use Net::Telnet;
$login = new Net::Telnet ("Host", "host IP here",
   Timeout, 50);

$login->waitfor('/Username: *$/');
$login->print("userid here");
print "Username input\n";
$login->waitfor('/Password: *$/');
$login->print("password here");
print "Password input\n";

$login->waitfor('/\$ *$/');
$login->print("type xxxx");
   ($alertfile) = $login->waitfor('/\$ *$/'); 

   open (LIVEFILE,">>yyyy") || die "Could not open file\n";
   print LIVEFILE "$alertfile";




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

Date: Wed, 11 Oct 2000 11:05:38 +0400
From: "Andrew Tkachenko" <bugfixxer@yahoo.com>
Subject: Re: Convert array to string?
Message-Id: <8s13kd$1ir$1@arcom.rcom.spb.su>


Rafael Garcia-Suarez <rgarciasuarez@free.fr> ÐÉÛÅÔ ×
ÓÏÏÂÝÅÎÉÉ:slrn8u846u.hkt.rgarciasuarez@rafael.kazibao.net...
> Michael wrote in comp.lang.perl.misc:
> >Is is possible to convert an array of characters to a string. I know this
is
> >possible in java via typecast. But I am not able to find anyting in any
book
> >on how to do it in perl.  Does anybody know if this is possible?  If so
how
> >might I go about doing this?
>
> Apparently you don't think in Perl yet.
>
>   $string = join '' => @array;
>

BTW, could you explain me, please - how is it possible to use
>join '' => @array;
instead of
>join '', @array
I mean arrow instead of comma? I thought, that '=>' used only in hashes, but
'=>' works too. Strange, I am puzzled?
Thanks for advance, Andrew




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

Date: Wed, 11 Oct 2000 07:28:22 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Convert array to string?
Message-Id: <slrn8u861o.hqm.rgarciasuarez@rafael.kazibao.net>

Andrew Tkachenko wrote in comp.lang.perl.misc:
>
>Rafael Garcia-Suarez <rgarciasuarez@free.fr> ÐÉÛÅÔ ×
>ÓÏÏÂÝÅÎÉÉ:slrn8u846u.hkt.rgarciasuarez@rafael.kazibao.net...
>> Michael wrote in comp.lang.perl.misc:
>> >Is is possible to convert an array of characters to a string. I know this
>is
>> >possible in java via typecast. But I am not able to find anyting in any
>book
>> >on how to do it in perl.  Does anybody know if this is possible?  If so
>how
>> >might I go about doing this?
>>
>> Apparently you don't think in Perl yet.
>>
>>   $string = join '' => @array;
>>
>
>BTW, could you explain me, please - how is it possible to use
>>join '' => @array;
>instead of
>>join '', @array
>I mean arrow instead of comma? I thought, that '=>' used only in hashes, but
>'=>' works too. Strange, I am puzzled?

The perlop manpage says:
       The => digraph is mostly just a synonym for the comma
       operator.  It's useful for documenting arguments that come
       in pairs.  As of release 5.001, it also forces any word to
       the left of it to be interpreted as a string.

Thus,
  %h = ( a => 1 );
is a synonym for
  %h = ( 'a', 1 );

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 11 Oct 2000 08:19:11 GMT
From: Juan =?iso-8859-1?Q?Jos=E9=20L=F3pez?= <jlopez@lingua.fil.ub.es>
Subject: dababases and problems with 5.6.0
Message-Id: <39E42255.45052F67@lingua.fil.ub.es>


  Hi

  I used to use a DB file tie'ing it with perl 5.0
(the one that comes with Linux RedHat 6.2), but version
5.6.0 (the one with RedHat 7.0) doesn't want to open
the same file.

  The description of the database is:

Berkeley DB 2.X Btree/Big Endian (Version 6,  Logical sequence number:
file - 0, offset - 0, Page Size 8192, Maxkey 0, Minkey 2, Free Page 0)

  Someone can help me?  Thank you in advance


Juanjo.


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

Date: Tue, 10 Oct 2000 23:49:16 -0700
From: David Highley <dhighley@mail.highley-recommended.com>
Subject: Re: Defining Headers for Module Mail::Mailer
Message-Id: <39E40D6C.4EDC924A@mail.highley-recommended.com>

Randy Kobes wrote:

> In comp.lang.perl.misc,
>    David Highley <dhighley@mail.highley-recommended.com> wrote:
> [ ... ]
> > After doing more looking at the two modules Mail::Mailer and Mail::Send
> > I came to the
> > conclusion I should be using Mail::Send instead of Mail::Mailer.  Now it
> > works for a real
> > system,  Solaris, but when I try it on a Windows goober I get the
> > following error:
> >     No mailer program specified (and no default available).
>
> The Mail::Mailer module can send things via SMTP:
>
> my $mailer = new Mail::Mailer 'smtp', Server => $server;
>

If you have a short example where this works I would appreciate it.  I have
tried a
number of different approaches, but have not been able to get the Mailer
module
to work for me.  I had no trouble with the Send module until I tried it on NT
and
then I could not figure out how to tell it what to use for a mailer.

>
> Also, on ActiveState's site is a Win32 faq which has an
> entry describing various ways to send mail on Win32.

Yes, I know.  I'm trying to implement within the constraints of what Rational
delivers
with their ClearCase product so that system administrators would not need to
install
an additional full perl implementation. Until there most recent version the
perl delivered
with the product had no modules.

Thank you.

>
>
> best regards,
> randy kobes

--

Regards,

David Highley
Highley Recommended, Inc.
2927 SW 339th Street
Federal Way, WA 98023-7732

Phone: (206) 669-0081
FAX:   (253) 838-8509
Email: dhighley@highley-recommended.com
WEB:   http://www.highley-recommended.com





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

Date: 10 Oct 2000 19:24:27 +0100
From: nobull@mail.com
Subject: Re: Different Ways to Obtain a Client`s IP ?
Message-Id: <u9bswr23n5.fsf@wcl-l.bham.ac.uk>

Bart Lateur <bart.lateur@skynet.be> writes off-topic

> Philip Lancefield wrote:
> 
> >For security reasons it is
> >important that I obtain the real IP address of the person. 
> 
> You've never heard of PPP?
> 
> In case that is not familiar: this is a dynamic protocol, where every
> time you log on to the Internet, you get a (likely) different temporary
> IP address, from a pool that the ISP has available for this purpose.

Looks like _you_ are not familiar with PPP.  Yes it is true that you
can use dynamic IP on PPP. And yes it is true that most dialup
services do use dymanic IP with PPP.  However you can have dynamic IP
without PPP and you can have PPP without dynamic IP.

BTW: Am I the only person who thinks that having IPCP negotiate IP
addresses is an ugly hack.  IMNSHO IPCP should not negotiate the IP
addresses.  If the IP addresses are not static then why not let IPCP
set up a link with one end set to 0.0.0.0 and let it send a DHCP/BOOTP
request (addressed to 255.255.255.255) to find it's IP address.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 11 Oct 2000 00:42:16 -0700
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: how to remove unprintable  chars with Perl script
Message-Id: <39E419D8.CD9207A@acm.org>

Larry Rosler wrote:
> 
> Despite its apparent popularity hereabouts, 'Perl source' ne 'Perl
> documentation'.
> 

The pod subdirectory has a lot of files that certainly look like Perl
documentation. :-)

John


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

Date: 11 Oct 2000 08:47:57 +0100
From: nobull@mail.com
Subject: Re: Is perl object oriented?
Message-Id: <u9g0m32502.fsf@wcl-l.bham.ac.uk>

"Mark" <mark@mediamasters.net> writes:

> Is perl a object oriented language?

No, not like Java or Smalltalk, but like many languages it has some
facilities to allow an object oriented programming approach.

perldoc perltoot

> What is an object oriented language?

Sorry, that question is off-topic.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 11 Oct 2000 04:45:12 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Is perl object oriented?
Message-Id: <brian-ya02408000R1110000445120001@news.panix.com>

In article <u9g0m32502.fsf@wcl-l.bham.ac.uk>, nobull@mail.com posted:

> "Mark" <mark@mediamasters.net> writes:

> > Is perl a object oriented language?

> No, not like Java or Smalltalk, but like many languages it has some
> facilities to allow an object oriented programming approach.

like Java?  surely you don't that in the same league as Smalltalk.

all the important features needed for OO are in Perl (although some
may miss their favorite features) although the bondage and discipline
are absent.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Wed, 11 Oct 2000 09:35:02 +0200
From: Jimmy Lantz <webmaster@ostas.lu.se>
Subject: Making this match better (que. about regexp and arrayhandling).
Message-Id: <39E41819.29EA3326@ostas.lu.se>

Hi Y'all
I have this sub, which works fine but I see that there's room fore
improvements so I thought I ought to turn it to the braintrust of
perlers (meaning you!).
Grateful for any improvements, suggestions , faqlookups etc.
/ Jimmy Lantz

############## Problem ############
I have the following (see below) if-statement which checks about 3000
lines of text,
i really dont need to check the whole line only the first part (ie.
until the first :) but I havent managed to  construct a regexp better
then checking the whole line.
Would I gain a lot of time if I manage to check only the first part
instead of the whole line ?

if ($line =~ /$hex/)

Below theres an foreach statement within an foreach statement, there
must be a way to make this better ?

NB! This match needs to be (and are) capable of handling more then one match.
############ Example of lines ###########

B8DFC2A5B4F3:hdhfhhdhfdg:jfdjhfyyrettttr
B8DFC2A5:hdhfhhdhfdg:jfdjhfyyrettttr
B8DF:hdhfhhdhfdg:jfdjhfyyrettttr
C2A5B4F3CFC3:hdhfhhdhfdg:jfdjhfyyrettttr
B4F3CFC3:hdhfhhdhfdg:jfdjhfyyrettttr
CFC3:hdhfhhdhfdg:jfdjhfyyrettttr
B8DFB4F3CFC3:hdhfhhdhfdg:jfdjhfyyrettttr
B8DFC2A5CFC3:hdhfhhdhfdg:jfdjhfyyrettttr
B4F3CFC3:hdhfhhdhfdg:jfdjhfyyrettttr
################### SUB ################
sub partialmatch
{
my($line) = @_ ;
my $hex = 'C2A5';
if ($line =~ /$hex/)
   {
my @parts= split /:/, $line ;
my @splittedhex = ($parts[0] =~ /.{4}/g);
#$hex sometimes contains up to 24 chars, so I need to split it up in
chunks by 4 as well.
@splittedhexquerie = ($hex =~ /.{4}/g); 
foreach $splithex (@splittedhex)
						{
foreach $hexquerie (@splittedhexquerie)
{
if($splithex eq $hexquerie)	{ push (@hits, $line);	} 
} 
						} 
   }
}


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

Date: Wed, 11 Oct 2000 09:36:37 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Making this match better (que. about regexp and arrayhandling).
Message-Id: <slrn8u8di7.i9k.rgarciasuarez@rafael.kazibao.net>

Jimmy Lantz wrote in comp.lang.perl.misc:
>Hi Y'all
>I have this sub, which works fine but I see that there's room fore
>improvements so I thought I ought to turn it to the braintrust of
>perlers (meaning you!).
>Grateful for any improvements, suggestions , faqlookups etc.
>/ Jimmy Lantz
>
>############## Problem ############
>I have the following (see below) if-statement which checks about 3000
>lines of text,
>i really dont need to check the whole line only the first part (ie.
>until the first :) but I havent managed to  construct a regexp better
>then checking the whole line.
>Would I gain a lot of time if I manage to check only the first part
>instead of the whole line ?
>
>if ($line =~ /$hex/)

If $hex does not change, you can use
  if ($line =~ /$hex/o)
to get the pattern compiled only once. This improves speed.

>Below theres an foreach statement within an foreach statement, there
>must be a way to make this better ?
>
>NB! This match needs to be (and are) capable of handling more then one match.
>############ Example of lines ###########
>
>B8DFC2A5B4F3:hdhfhhdhfdg:jfdjhfyyrettttr
>B8DFC2A5:hdhfhhdhfdg:jfdjhfyyrettttr
>B8DF:hdhfhhdhfdg:jfdjhfyyrettttr
>C2A5B4F3CFC3:hdhfhhdhfdg:jfdjhfyyrettttr
>B4F3CFC3:hdhfhhdhfdg:jfdjhfyyrettttr
>CFC3:hdhfhhdhfdg:jfdjhfyyrettttr
>B8DFB4F3CFC3:hdhfhhdhfdg:jfdjhfyyrettttr
>B8DFC2A5CFC3:hdhfhhdhfdg:jfdjhfyyrettttr
>B4F3CFC3:hdhfhhdhfdg:jfdjhfyyrettttr
>################### SUB ################
>sub partialmatch
>{
>my($line) = @_ ;
>my $hex = 'C2A5';
>if ($line =~ /$hex/)
>   {
>my @parts= split /:/, $line ;
>my @splittedhex = ($parts[0] =~ /.{4}/g);
>#$hex sometimes contains up to 24 chars, so I need to split it up in
>chunks by 4 as well.
>@splittedhexquerie = ($hex =~ /.{4}/g); 
>foreach $splithex (@splittedhex)
>						{
>foreach $hexquerie (@splittedhexquerie)
>{
>if($splithex eq $hexquerie)	{ push (@hits, $line);	} 
>} 
>						} 
>   }
>}

Apparently you're trying to match 4-char chunks of your pattern against
4-char chunks of your $hex search string.

You can perhaps improve this test by doing:
  if ($line =~ /^([A-F0-9]{4})*$hex/)
that matches $hex only at 4-even positions.
Then, splitting $hex and $line becomes useless.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: 10 Oct 2000 19:04:55 +0100
From: nobull@mail.com
Subject: Re: mod_perl variables
Message-Id: <u9d7h723p5.fsf@wcl-l.bham.ac.uk>

apacheproblems@my-deja.com writes:

> I notice when using %ARRAYS in mod_perl that for new requests previous
> data stored in the %ARRAY are still present. I have declared the
> veriables with my(%ARRAY) = () and still causing problems.Any ideas?

Have you considered the possibility that this problem is not mod_perl
related?  Are you perhaps seeing the persistant field effect of
CGI.pm?

If this is not the case then please produce a minimal script that
actually runs and that will reproduce the effect you are describing
then post it here[1].

[1] By here I mean comp.lang.perl.misc.  There is no such group as
comp.lang.perl.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 11 Oct 2000 09:04:25 +0100
From: nobull@mail.com
Subject: Re: OPEN file efficiancy issue,
Message-Id: <u9em1n248m.fsf@wcl-l.bham.ac.uk>

Jimmy Lantz <webmaster@ostas.lu.se> writes:

> I have some questions about OPEN and efficiancy issues regarding open
> and filehandling.
> I welcome all suggestions for improvements etc.
> Regards.
> Jimmy Lantz
> 
> FIRST: Is it faster to say:

[ use implicit assignment of $_ by <> rather than explicit ] 

If you really care use Benchmark.pm - I doubt it make much odds.  The
maintainability/redability issues are likely to be fat more significant.

> while ($line = <IN>)
>  { part_matchline($line); }

Note: good programming style would put a my in front of the $line
assignment.  It would probably speed things up too.

> Is it faster not to close(IN) and then do a second "while"

Almost certainly the implicit close() by open() will be faster than a
explicit close() since there's less bytecode being interpreted at
run-time.  If you really wany to find out how much faster use
Benchmark.pm.  I wouldn't be supprised if the effect was unmeasurably
small.

Of course if you are really scraping arround to save every possible
CPU cycle then get rid of the subroutine call and simply inline the
code of part_matchline.  As shown is another current thread the cost
of a subroutine call in a trivial loop can be very significant.

> Is it better to read everything into a array and then do an foreach?
> (I've heard this takes up a lot of memory).

For small files I've heard that slurping the whole file into an array
can be faster.  However this is likely to be very sensative to your
exact application so if you really want to know use Benchmark.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 11 Oct 2000 08:19:14 GMT
From: Juan =?iso-8859-1?Q?Jos=E9=20L=F3pez?= <jlopez@lingua.fil.ub.es>
Subject: Re: perl 5.6, Net::POP3, database files, and more
Message-Id: <39E4207E.27883DE1@lingua.fil.ub.es>

Alex Hart escribió:
> 

> 2. Are the database files (hashes opened with dbmopen) done differently
> in perl5.6? I couldn't seem to read my old files with 5.6.  Also, it
> didn't seem to put the ".db" extensions on the files.  Have others
> noticed this?
>
> Alex Hart
> 
> no sig

  Hi, unfortunately I don't have the answer, but the same question.
I've moved from RedHat Linux 6.2 to 7.0 and Perl has moved from 5.0
to 5.6.  Since then, I can't access to my DB files (created with
the old version)

  I'm going mad and can't figure what's the problem. Doing a 
'file fich.db' does the next output:

Berkeley DB 2.X Btree/Big Endian (Version 6,  Logical sequence number:
file - 0, offset - 0, Page Size 8192, Maxkey 0, Minkey 2, Free Page 0)

  I don't know much about this files, only I used to 'tie' the file
and access it via a hash variable.


  PLEASE, I need help because it's impossible to me to recreate
all my database.

Thanx



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

Date: Wed, 11 Oct 2000 00:38:54 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: perl resource
Message-Id: <MPG.144db8e7e7eab85698ae24@nntp.hpl.hp.com>

In article <su6g7n7ifco9bf@corp.supernews.com>, admin@news.dynip.com 
says...
> Hello,
> I realize this may be pure begging. I have a list of city names which is
> composed of one city per line in a plain text file. There are 42,000 lines
> but many duplicate city names (eg. Waco is entered 22 times on 22 lines
> between Wacissa and Waconia) I know perl is probably a great tool to remove
> all the duplicate names but leaving one name, what I don't have is a script
> to do it. I have almost no knowlege of writing scripts (actually none),
> could someone show me the way to a resource for finding such a script? Thank
> You

Everyone else focused on an external command, 'sort -u'.  But this 
question has been dealt with thoroughly in Perl, which is indeed a 
great tool for this purpose.

perlfaq4: "How can I remove duplicate elements from a list or
array?"

Next you have to write a tiny program that uses the appropriate 
technique from the FAQ.

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


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

Date: 11 Oct 2000 08:03:47 GMT
From: a.peacock@chime.ucl.ac.uk (Anthony Peacock)
Subject: Re: Problem with duplicate entries in database
Message-Id: <8s16t3$ck4$1@uns-a.ucl.ac.uk>

In article <8rvq9s$k37$1@nnrp1.deja.com>, michael.segulja@sgi-lsi.com says...
>
>I have written a perl script that reads in a specific directory of mp3
>files and inserts the tag info into a MySql database.  I don't really
>know if this is more of a MySql question or a perl question, so forgive
>me if this is not the appropriate place to ask.
>
>Everything works great except that each mp3 file is entered twice in
>the database.  If I output the tag info to STDOUT, I see each song
>once.  But if I insert the output into my database, each song is
>entered twice.  I have included the perl source to see if that's the
>problem.  I'm using this to learn perl, so I'm pretty clueless on what
>to look for.
>
>I really appreciate any help anybody can give.  If it's a MySql problem
>let me know, and I'll ask in that group.  Something I'm also trying to
>figure out is how to create a unique index on the title column, but
>that's definitely for the MySql group.

<SNIP>

>
>        # Connect to the database mp3db.
>        my $dbh = DBI->connect("DBI:mysql:database=$db;host=$host",
>                        $user, $password, {RaiseError => 1} );
>
>        # Insert MP3 tag info into table mp3main.
>        my $sth=$dbh->prepare("INSERT INTO mp3main
>           (album, artist, title, genre, comment, bitrate, version,
>mpeg_layer, durationM,
>              durationS, year) VALUES (?,?,?,?,?,?,?,?,?,?,?)" );
>
>        $sth->execute($album, $artist, $title, $genre, $comment,
>$bitrate, $version, $layer,
>                        $durationM, $durationS, $year) || die "Insert
>Failed";
>        $sth->execute();

What is this second execute doing?  I am not too sure what calling execute 
with no parameters will do, but it looks wrong to me.

Also why connect to the database and disconnect each time?  Put your 
connection outside the foreach loop.



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

Date: Wed, 11 Oct 2000 08:20:58 +0100
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Re: Reading a whole file into a string
Message-Id: <4a0bb18f7bg.soper@soundhouse.co.uk>

In article <slrn8u700h.krs.bmccoy@chapelperilous.net>,
   Brett W. McCoy <bmccoy@news.speakeasy.org> wrote:
> On Tue, 10 Oct 2000 21:01:26 +0100, Geoff Soper <g.soper@soundhouse.co.uk>
> wrote:

> >The " $var = 'cat $file' " part is the part I got from the FAQ, this
> >doesn't look right to me but I thought I'd try it anyway, I've obviously
> >misunderstood something so if somebody could point out what I'd be most
> >grateful!

> Except that it won't work.  What you want is $var = `cat $file`.  Note
> the backticks rather than single quotes. Otherwise your $var will just
> be holding "cat <contents of $file>".  That will definitely slurp up the

OK, that was easy enough, I'll take care to look closer in future!

> contents into a single scalar.  Think very carefully about whether or
> not you really want to gobble up the entire contents and dump it into a
> textarea (some versions of Netscape, notably on Solaris and Linux, will
> start thrashing the drive because of a buggy textarea implementation
> that chokes when the textarea has a certain amount of text in it),
> requiring you to login in remotely to kill the process!) If you are
> developing a content management kind of thing, you might want to break
> your article up into logical chunks.

The amount of text isn't very big. Up to around 20 lines I'd imagine. It
is a content management situation where the content is short news
articles. Do you think I'll be OK with this kind of length? The page that
uses the text area is the admin page where submitted articles are approved
and edited before going onto the site database. Therefore only admin
people (me currently) will ever see it and the public won't.

Cheers

-- 
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/


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

Date: Wed, 11 Oct 2000 07:26:02 GMT
From: a94eribe@my-deja.com
Subject: Reg exp help
Message-Id: <8s14m6$msn$1@nnrp1.deja.com>

Hi

I´m new to regular expressions and I would like some help.

I need to check that the user submitted a correct quantity.

A correct quantity is numeral and can contain one comma (,).


How would the notation for that be?

Thanks for your help

/Erik




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


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

Date: Wed, 11 Oct 2000 00:25:05 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: substring search
Message-Id: <MPG.144db5affd66af3798ae23@nntp.hpl.hp.com>

In article <8ru80i$b1p$1@nnrp1.deja.com>, jack_1236@hotmail.com says...
> I am new to Perl and have an urgent need to find number of occurrences
> of a given expression like "Runner is done" in a text file *.txt) using
> Perl. how is it done in perl?.

As a newcomer to Perl, you should immediately acquaint yourself with a 
remarkable resource -- the voluminous Perl FAQ, and the command to 
search it.  In this case, the command:

  perldoc -q substring

would have revealed the following in perlfaq4:

How can I count the number of occurrences of a substring within a 
string?

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


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

Date: Wed, 11 Oct 2000 05:51:43 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: Trying to add a service in win32 env.
Message-Id: <39E4382F.E967846D@patriot.net>

> Win32::Lanman???

http://www.perl.com/CPAN-local/authors/id/J/JH/JHELBERG/

> Daemon???

http://www.roth.net/perl/#Win32Daemon

> Can't find anything about them.  Not even a
> hit on CPAN!?!



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

Date: Wed, 11 Oct 2000 01:17:50 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Writing multple lines to a file at once?
Message-Id: <MPG.144dc2039ddc241e98ae25@nntp.hpl.hp.com>

In article <8s01pj$qrj$1@nnrp1.deja.com>, billgerba@my-deja.com says...

 ...

> However, I would like to be able to print many lines at once to the
> file, like I can to the console (or HTML) with:
> 
> print <<OUTFILE;
> la dee da la dee da
> la dee da la dee da
> la dee da la dee da
> la dee da la dee da
> la dee da la dee da
> OUTFILE
> 
> I haven't been able to figure out if there's a syntax that will let me
> do this but send the output to some file $myFileName or something like
> that.  Can it be done?

You might find the other answers easier to understand if you recognize 
that the notation:

<<EOT
blah
blah
EOT

is nothing more than the representation of a string, whose name could be 
used instead of the <<EOT.  Then all normal syntax rules apply.

$foo = <<EOT;
blah
blah
EOT

print $foo;

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


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

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


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