[23442] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5657 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 14 09:05:42 2003

Date: Tue, 14 Oct 2003 06: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)

Perl-Users Digest           Tue, 14 Oct 2003     Volume: 10 Number: 5657

Today's topics:
    Re: cannot use bitwise AND-Operator on hex-scalars from <bart.lateur@pandora.be>
    Re: cannot use bitwise AND-Operator on hex-scalars from <kuujinbo@hotmail.com>
    Re: cannot use bitwise AND-Operator on hex-scalars from (Tad McClellan)
    Re: cannot use bitwise AND-Operator on hex-scalars from <josef.moellers@fujitsu-siemens.com>
    Re: CGI.pm File Upload doesn't work (blocks) on my Serv <flavell@ph.gla.ac.uk>
        How does one move down a line in a file? <no@spam.here>
    Re: How does one move down a line in a file? <abigail@abigail.nl>
    Re: How does one move down a line in a file? (Anno Siegel)
    Re: How does one move down a line in a file? (Anno Siegel)
    Re: How does one move down a line in a file? <no@spam.here>
    Re: How does one move down a line in a file? <HelgiBriem_1@hotmail.com>
    Re: How does one move down a line in a file? (Tad McClellan)
    Re: How to update entries in a file <no@spam.here>
    Re: How to update entries in a file <REMOVEsdnCAPS@comcast.net>
    Re: How to update entries in a file (Tad McClellan)
    Re: How to update entries in a file (Tad McClellan)
    Re: Named Pipe Permissions Question (Anno Siegel)
    Re: perl 5.8.1, Mac OS, and locales (Jim Anderson)
        search result case problem <duffy_ben@hotmail.com>
    Re: search result case problem (Anno Siegel)
    Re: search result case problem <duffy_ben@hotmail.com>
    Re: suggestions for comparing two large data sets reque (Anno Siegel)
    Re: Uploading files (Anno Siegel)
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 14 Oct 2003 10:13:11 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: cannot use bitwise AND-Operator on hex-scalars from ARGV[0]
Message-Id: <jminovkvag77oajpslba4seakb4v2cth07@4ax.com>

ko wrote:

>> #!/usr/bin/perl
>> $var1 = $ARGV[0];
>> $var2 = 0xaffe;
>> $res = $var1 & $var2;
>> print $res;

>> if I start this script from command line like this:
>> 
>> user@host > ./my.perl.test.pl 0xcafe
>> 
>> I get an error message that says: "Argument "0xcafe" isn't numeric in
>> bitwise and (&) in line...

>Try using oct():
>
>$var1 = oct($var1) if $var1 =~ /^0/;

That's the best generic solution. oct() is smart about other prefixes,
so it'll do the right thing with strings that start with "0x" (hex) and
"0b" (binary). 

The test for a leading "0" prevents treating strings like "123" as
octal.

There's only one small problem with it, which is most obvious with
bitwise operators. It doesn't convert a string with a decimal number to
a number. If both operands are strings, the bitwise operators work
differently. Now, with the second argument explicitely entered as a
number, 

>> $var2 = 0xaffe;

this won't give a problem. If both come from user input, it will.

Just to be on the safe side, you can do

	$var1 = $var1 =~ /^0/ ? oct($var1) : 0+$var1;

-- 
	Bart.


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

Date: Tue, 14 Oct 2003 20:11:48 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: cannot use bitwise AND-Operator on hex-scalars from ARGV[0]
Message-Id: <bmglpq$p23$1@pin3.tky.plala.or.jp>

Bart Lateur wrote:
> ko wrote:

[snip]

>>Try using oct():
>>
>>$var1 = oct($var1) if $var1 =~ /^0/;
> 
> 
> That's the best generic solution. oct() is smart about other prefixes,
> so it'll do the right thing with strings that start with "0x" (hex) and
> "0b" (binary). 
> 
> The test for a leading "0" prevents treating strings like "123" as
> octal.
> 
> There's only one small problem with it, which is most obvious with
> bitwise operators. It doesn't convert a string with a decimal number to
> a number. If both operands are strings, the bitwise operators work
> differently. Now, with the second argument explicitely entered as a
> number, 
> 
> 
>>>$var2 = 0xaffe;
> 
> 
> this won't give a problem. If both come from user input, it will.
> 
> Just to be on the safe side, you can do
> 
> 	$var1 = $var1 =~ /^0/ ? oct($var1) : 0+$var1;
> 

Thanks for the pointer :) Didn't think about the numeric vs. string 
difference, and should have also pointed out that oct() is flexible when 
converting numbers.



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

Date: Tue, 14 Oct 2003 07:21:22 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: cannot use bitwise AND-Operator on hex-scalars from ARGV[0]
Message-Id: <slrnbonqi2.46u.tadmc@magna.augustmail.com>

Josef Möllers <josef.moellers@fujitsu-siemens.com> wrote:
> Roland Reichenberg wrote:


>> $var1 = $ARGV[0];

>> user@host > ./my.perl.test.pl 0xcafe


> You have a string, not an integer.
> 
> Use eval($ARGV[0]);


String eval() should be the *last* choice. Use it only when you must,
and we don't need it for this problem as hex() or oct() will do
it without resorting to the evil eval.


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


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

Date: Tue, 14 Oct 2003 15:05:19 +0200
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: cannot use bitwise AND-Operator on hex-scalars from ARGV[0]
Message-Id: <3F8BF48F.74E1D5AF@fujitsu-siemens.com>

Tad McClellan wrote:
> =

> Josef M=F6llers <josef.moellers@fujitsu-siemens.com> wrote:
> > Roland Reichenberg wrote:
> =

> >> $var1 =3D $ARGV[0];
> =

> >> user@host > ./my.perl.test.pl 0xcafe
> =

> > You have a string, not an integer.
> >
> > Use eval($ARGV[0]);
> =

> String eval() should be the *last* choice. Use it only when you must,
> and we don't need it for this problem as hex() or oct() will do
> it without resorting to the evil eval.

hex() or oct() will do only if it is indeed a number.
I added that eval will allow to catch errors.
As an added bonus, eval will also allow expressions ...

But I see your point:
	$arg =3D 'open(X,"> XXX"); close(X);';
	eval ($arg);

One never ceases to learn,

Josef
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Tue, 14 Oct 2003 11:06:11 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: CGI.pm File Upload doesn't work (blocks) on my Server (but works on my Desktop)
Message-Id: <Pine.LNX.4.53.0310141102260.22944@ppepc56.ph.gla.ac.uk>

On Tue, 14 Oct 2003, Bjoern wrote:

> OK, the problem cause is really embarrassing:

Don't worry about it!  We all make mistakes.  Main thing is, you've
learned something about debugging for next time, and we've got the
satisfying sense of closure that comes from hearing how the problem
panned out in the end.

> apparently my desktop
> computers firewall (Kerio) was blocking the file uploads. I still don't
> know why, because it let's other http requests pass, but at least I can
> test my script by temporarily disabling the firewall.
>
> So it wasn't perl-related after all. But for completeness sake

Indeed.  Thanks for posting the update!

> >>----------- Script -----------
> >>
> >>#!/usr/bin/perl
> >
> > Guess who isn't paying proper attention to this group's posting
> > guidelines?  The regulars hate that.  It's demeaning for a human being
> > to be asked to do the job of a machine.
>
> I am not sure what I did wrong here?

Specifically: you didn't have strict and warnings enabled...

all the best


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

Date: Tue, 14 Oct 2003 11:50:05 GMT
From: "John" <no@spam.here>
Subject: How does one move down a line in a file?
Message-Id: <NpRib.150645$bo1.139307@news-server.bigpond.net.au>

I'd like to move down a file and assign each line to a different variable.
How can I skip/move forward a line within the following while loop?

while (<FILE>) {
    first = $_;
    second = $_;
    third = $_;
}

# all below vars have different values
print $first;
print $second;
print $third;


Thanks




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

Date: 14 Oct 2003 12:08:35 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: How does one move down a line in a file?
Message-Id: <slrnbonpq3.r3h.abigail@alexandra.abigail.nl>

John (no@spam.here) wrote on MMMDCXCVI September MCMXCIII in
<URL:news:NpRib.150645$bo1.139307@news-server.bigpond.net.au>:
~~  I'd like to move down a file and assign each line to a different variable.
~~  How can I skip/move forward a line within the following while loop?
~~  
~~  while (<FILE>) {
~~      first = $_;
~~      second = $_;
~~      third = $_;
~~  }

It depend a bit on what you want to do with the last lines if the
file doesn't have a multiple of three lines in the file, but I
would do something like:

    {   my $first  = <FILE> err last;
        my $second = <FILE> err last;
        my $third  = <FILE> err last;

        # Process lines here.

        redo;
    }


Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'


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

Date: 14 Oct 2003 12:20:20 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How does one move down a line in a file?
Message-Id: <bmgpm4$foe$1@mamenchi.zrz.TU-Berlin.DE>

John <no@spam.here> wrote in comp.lang.perl.misc:
> I'd like to move down a file and assign each line to a different variable.

I'm pretty sure you don't really want to do that.  How would you access the
last line of a file of 1234 lines?  $one_thousand_two_hundred_thirty_fourth?

You *may* want to assign the lines to an array with each line in one
position.

> How can I skip/move forward a line within the following while loop?
> 
> while (<FILE>) {
>     first = $_;
>     second = $_;
>     third = $_;
> }

First off, you forgot the "$"s in front of your variables.  A quick test
(perl -c) would have shown your error.  If you post code, please make
sure it is syntactically correct.

Otherwise, the code doesn't do in the least what you want.  It assigns
the *same* line (in $_) into $first, $second and $third.  Then, in the
next iteration, it overwrites the values with the next line.  You end
up with the last line of the file in all three variables.

With an array the solution looks like this:

    my @list;
    while (<FILE>) {
        push @list, $_;
    }

or just

    my @list = <FILE>;

> # all below vars have different values
> print $first;
> print $second;
> print $third;

    print $list[ $_] for 0 .. 2;

Anno


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

Date: 14 Oct 2003 12:26:34 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How does one move down a line in a file?
Message-Id: <bmgq1q$foe$2@mamenchi.zrz.TU-Berlin.DE>

Abigail  <abigail@abigail.nl> wrote in comp.lang.perl.misc:
> John (no@spam.here) wrote on MMMDCXCVI September MCMXCIII in
> <URL:news:NpRib.150645$bo1.139307@news-server.bigpond.net.au>:
> ~~  I'd like to move down a file and assign each line to a different variable.
> ~~  How can I skip/move forward a line within the following while loop?
> ~~  
> ~~  while (<FILE>) {
> ~~      first = $_;
> ~~      second = $_;
> ~~      third = $_;
> ~~  }
> 
> It depend a bit on what you want to do with the last lines if the
> file doesn't have a multiple of three lines in the file, but I
> would do something like:
> 
>     {   my $first  = <FILE> err last;
>         my $second = <FILE> err last;
>         my $third  = <FILE> err last;
> 
>         # Process lines here.
> 
>         redo;
>     }

Ah... you probably understood the OPs intention better than I did
in another reply.

The "err" operator looks interesting.  How is it specified?

Anno


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

Date: Tue, 14 Oct 2003 12:43:21 GMT
From: "John" <no@spam.here>
Subject: Re: How does one move down a line in a file?
Message-Id: <JbSib.150724$bo1.123955@news-server.bigpond.net.au>


"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:bmgpm4$foe$1@mamenchi.zrz.TU-Berlin.DE...
> John <no@spam.here> wrote in comp.lang.perl.misc:
> > I'd like to move down a file and assign each line to a different
variable.
>
> I'm pretty sure you don't really want to do that.  How would you access
the
> last line of a file of 1234 lines?
$one_thousand_two_hundred_thirty_fourth?
>
> You *may* want to assign the lines to an array with each line in one
> position.
>
> > How can I skip/move forward a line within the following while loop?
> >
> > while (<FILE>) {
> >     first = $_;
> >     second = $_;
> >     third = $_;
> > }
>
> First off, you forgot the "$"s in front of your variables.  A quick test
> (perl -c) would have shown your error.  If you post code, please make
> sure it is syntactically correct.
>
> Otherwise, the code doesn't do in the least what you want.  It assigns
> the *same* line (in $_) into $first, $second and $third.  Then, in the
> next iteration, it overwrites the values with the next line.  You end
> up with the last line of the file in all three variables.
>
> With an array the solution looks like this:
>
>     my @list;
>     while (<FILE>) {
>         push @list, $_;
>     }
>
> or just
>
>     my @list = <FILE>;
>
> > # all below vars have different values
> > print $first;
> > print $second;
> > print $third;
>
>     print $list[ $_] for 0 .. 2;
>
> Anno

Thanks Anno. I actually changed to an array solution and it works as I
needed it in a much neater way:
open(FILE, $file);
@lines = <FILE>;
close(FILE);








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

Date: Tue, 14 Oct 2003 12:44:16 +0000
From: Helgi Briem <HelgiBriem_1@hotmail.com>
Subject: Re: How does one move down a line in a file?
Message-Id: <arrnov0l6o3fa5fpnn2cq1eoithg2nb7gl@4ax.com>

On Tue, 14 Oct 2003 11:50:05 GMT, "John" <no@spam.here> wrote:

>I'd like to move down a file and assign each line to a different variable.
>How can I skip/move forward a line within the following while loop?
>
>while (<FILE>) {
>    first = $_;
>    second = $_;
>    third = $_;
>}
>
># all below vars have different values
>print $first;
>print $second;
>print $third;

Don't do that.  Use a hash instead:

#!perl
use warnings;
use strict;
my %line;
while (<DATA>)
{
 $line{$.}= $_;
}

# Have a look at the contents of %line
for (sort { $a <=> $b } keys %line)
{
 print "$_\t$line{$_}";
}


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

Date: Tue, 14 Oct 2003 07:43:40 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How does one move down a line in a file?
Message-Id: <slrnbonrrs.46u.tadmc@magna.augustmail.com>

John <no@spam.here> wrote:

> How can I skip/move forward a line within the following while loop?


By simply reading from the file:


> while (<FILE>) {
>     first = $_;
>     second = $_;
>     third = $_;

   if ( want_to_skip_line() ) {
      <FILE>;               # read and discard line
   }


> }


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


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

Date: Tue, 14 Oct 2003 10:07:04 GMT
From: "John" <no@spam.here>
Subject: Re: How to update entries in a file
Message-Id: <cVPib.150498$bo1.95334@news-server.bigpond.net.au>


"Roland Reichenberg" <r.reichenberg@gmx.de> wrote in message
news:bmgga2$l4i$1@news.nrw.net...
>
> Hi John,
>
> > I have a file entry in the following format:
> > <Employee number="111222">
> >     <Department>Sales</Department>
> >                 <Surname>Jones</Surname>
> >                 <Name>Tom</Name>
> > </Employee number>
>
> This looks like XML-formated data
>
> > Can someone give me some pointers as to where I should start looking?
>
> Have you tried the perl xml module?
> Maybe this module includes the methods that you need.
> Look at www.cpan.org for more information about perl and xml.
>
> Regards,
>
>         Roland
>

Roland,
Yes it is meant to be XML formatted. Unfortunately, I forgot to mention that
I am unable to use any of the CPAN modules. :(
Sorry.




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

Date: Tue, 14 Oct 2003 06:32:51 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: How to update entries in a file
Message-Id: <Xns94144CBBFB6DCsdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"John" <no@spam.here> wrote in
news:cVPib.150498$bo1.95334@news-server.bigpond.net.au: 

> Yes it is meant to be XML formatted. Unfortunately, I forgot to
> mention that I am unable to use any of the CPAN modules. :(
> Sorry.

Why on earth not?  Is this a homework assignment?

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP4ve0mPeouIeTNHoEQJ7wQCdGIr/fDPXGj6HnKEQYcXpXxcTruMAoIDl
TQIlp0am7KaXMGxfd0wK3+dA
=4Igk
-----END PGP SIGNATURE-----


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

Date: Tue, 14 Oct 2003 07:37:10 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to update entries in a file
Message-Id: <slrnbonrfm.46u.tadmc@magna.augustmail.com>

John <no@spam.here> wrote:

> I am unable to use any of the CPAN modules. :(


Why not?


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


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

Date: Tue, 14 Oct 2003 07:41:42 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to update entries in a file
Message-Id: <slrnbonro6.46u.tadmc@magna.augustmail.com>

John <no@spam.here> wrote:


> I recognise that I will probably need to read the old file into a temporary
> one, do my editing there and save the results to a new file. The new file
> will then be renamed to the old file. 


Perl can do all of that "administrative" work for you, see
the -i switch (perlrun.pod) and $^I (perlvar.pod).

   
> Is each line in the file entry meant
> to become a hash element?


Hashes are unordered, but the order of lines matters, so a hash
is not the Right Tool, it will break your data...


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


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

Date: 14 Oct 2003 12:39:37 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Named Pipe Permissions Question
Message-Id: <bmgqq9$foe$3@mamenchi.zrz.TU-Berlin.DE>

mooseshoes  <mooseshoes@gmx.net> wrote in comp.lang.perl.misc:
> 
> Problem resoloved.
> 
> It wasn't a permissions problem but rather "mknod" needed to be
> "/bin/mknod".
> 
> And Mr. Grazzini, if you don't have the answer to a question, your best
> contribution would be silence.

You have just made sure you'll get a lot of silence on clpm.  Mine,
for the forseeable future.

Anno


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

Date: 14 Oct 2003 05:55:57 -0700
From: james.h.anderson@ssmb.com (Jim Anderson)
Subject: Re: perl 5.8.1, Mac OS, and locales
Message-Id: <2cfb060a.0310140455.36be438a@posting.google.com>

jtbellq2f@presby.edu (Jon Bell) wrote in message news:<bmf7s2$75t$1@jtbell.presby.edu>...
> In article <2cfb060a.0310131027.7823b9e7@posting.google.com>,
> Jim Anderson <james.h.anderson@ssmb.com> wrote:
> >I don't know if this is a perl issue or a Mac OS issue. I just
> >installed perl5.8.1 and I getting the following error msgs each time I
> >run any perl script:
> >
> >perl: warning: Setting locale failed.
> >perl: warning: Please check that your locale setting:
> >         LC_ALL = (unset),
> >         LANG = "en_US"
> >     are supported and installed on your system.
> >perl: warning: Falling back to the standard locale ("C").
> 
> It's a Mac OS X issue.  See
> 
> <http://developer.apple.com/internet/macosx/perl.html>.

Thanks! Worded a treat.


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

Date: Tue, 14 Oct 2003 11:36:39 +0100
From: "Ben Duffy" <duffy_ben@hotmail.com>
Subject: search result case problem
Message-Id: <YkQib.10592$jF3.409@news-binary.blueyonder.co.uk>

What perl functions should I use to be able to find a substring in a string,
& replace it with bold text, similar to Google search results highlighting?

for example
search "120gb Hard Disk Drive"  for "disk"    to result in "120gb Hard
<strong>Disk</strong> Drive"

The way I am currently doing this is...
$prodname = "120gb Hard Disk Drive" ;
$where_desc = "disk";
$prodname =~ s/$where_desc/<strong>$where_desc<\/strong>/gi;

which gives...  "120gb Hard <strong>disk</strong> Drive"

The problem is that I want to retain the $prodname's original case.


I have tried using split, to get the string parts before & after the search
word, but can't assign the actual found word to a variable...

($before,$after)= split(/$where_desc/i,$proddesc);
only two variables are returned,
$before = "120gb Hard";
$after = "Drive";

but I can't assign "Disk" to a variable.  If I could, then I could rejoin
after formatting.

Any help would be appeciated.




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

Date: 14 Oct 2003 11:06:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: search result case problem
Message-Id: <bmglc6$cmm$1@mamenchi.zrz.TU-Berlin.DE>

Ben Duffy <duffy_ben@hotmail.com> wrote in comp.lang.perl.misc:
> What perl functions should I use to be able to find a substring in a string,
> & replace it with bold text, similar to Google search results highlighting?
> 
> for example
> search "120gb Hard Disk Drive"  for "disk"    to result in "120gb Hard
> <strong>Disk</strong> Drive"
> 
> The way I am currently doing this is...
> $prodname = "120gb Hard Disk Drive" ;
> $where_desc = "disk";
> $prodname =~ s/$where_desc/<strong>$where_desc<\/strong>/gi;
> 
> which gives...  "120gb Hard <strong>disk</strong> Drive"
> 
> The problem is that I want to retain the $prodname's original case.

Capture the match and use the original:

    $prodname =~ s{($where_desc)}{<strong>$1</strong>}gi;

Anno


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

Date: Tue, 14 Oct 2003 12:12:12 +0100
From: "Ben Duffy" <duffy_ben@hotmail.com>
Subject: Re: search result case problem
Message-Id: <gSQib.11226$jF3.7798@news-binary.blueyonder.co.uk>

That works.  Thank you Anno.


"Ben Duffy" <duffy_ben@hotmail.com> wrote in message
news:YkQib.10592$jF3.409@news-binary.blueyonder.co.uk...
> What perl functions should I use to be able to find a substring in a
string,
> & replace it with bold text, similar to Google search results
highlighting?
>
> for example
> search "120gb Hard Disk Drive"  for "disk"    to result in "120gb Hard
> <strong>Disk</strong> Drive"
>
> The way I am currently doing this is...
> $prodname = "120gb Hard Disk Drive" ;
> $where_desc = "disk";
> $prodname =~ s/$where_desc/<strong>$where_desc<\/strong>/gi;
>
> which gives...  "120gb Hard <strong>disk</strong> Drive"
>
> The problem is that I want to retain the $prodname's original case.
>
>
> I have tried using split, to get the string parts before & after the
search
> word, but can't assign the actual found word to a variable...
>
> ($before,$after)= split(/$where_desc/i,$proddesc);
> only two variables are returned,
> $before = "120gb Hard";
> $after = "Drive";
>
> but I can't assign "Disk" to a variable.  If I could, then I could rejoin
> after formatting.
>
> Any help would be appeciated.
>
>




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

Date: 14 Oct 2003 10:20:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: suggestions for comparing two large data sets requested
Message-Id: <bmgils$anq$1@mamenchi.zrz.TU-Berlin.DE>

John W. Krahn <krahnj@acm.org> wrote in comp.lang.perl.misc:
> "Terry L. Ridder" wrote:
> > 
> > [snip]
> > 
> > the flagged block entries will be check against the bgp routing tables
> > by querying the router for announced routes just to make sure someone
> > is not attempting to use it.
> > 
> > using foreach loops would be braindead given the number of entries.
> > 149190 x 16420. ( which change daily. )
> > 
> > please note:
> > all ip addresses are stored as numbers and *not* as dotted quads.
> 
> It sounds like you could use a bit vector to store the 'holes' data
> which would require a 536,870,912 byte string and have look-ups of O(1).

Ah, the sophistication of brute force :)

It may cost some time to set up the table in the first place.  A (probably
substantial) subset of 8*536,870,912 bits must be set, more or less
individually.

Alternatively, one could use binary search to find the starting and
ending points of a possible enclosing interval.

Anno


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

Date: 14 Oct 2003 12:41:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Uploading files
Message-Id: <bmgqu5$foe$4@mamenchi.zrz.TU-Berlin.DE>

michela rossi <michela_rossi66@hotmail.com> wrote in comp.lang.perl.misc:
> Hi,
> 
> Wonder if anyone can help. I've got a Unix server inside our firewall
> that contains a local version of a website. The live version of the
> website resides on shared webspace elsewhere. We are frequently
> updating the local website on behalf of a client, and so frequently
> upload files using FTP.
> 
> My question is: does anyone know of a script we can run on the local
> server that will automatically synchronise the live server with the
> files on the local server i.e. will only update those files from the
> local server that are out of date?
> 
> Please note that we cannot install any software on the live server.

Why do you ask this question on a Perl forum?

Check out rsync.

Anno


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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

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 V10 Issue 5657
***************************************


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