[11530] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5130 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 14 06:07:25 1999

Date: Sun, 14 Mar 99 03:00:18 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 14 Mar 1999     Volume: 8 Number: 5130

Today's topics:
    Re: Accessing Files from another server (Abigail)
    Re: Array lengths (Tad McClellan)
    Re: Array lengths (Ronald J Kimball)
    Re: Can't Increment Counter in FILE Using http:// (Tad McClellan)
    Re: Can't Increment Counter in FILE Using http:// (Abigail)
    Re: command-line CGI (Ronald J Kimball)
    Re: complicated reg-exp question <thrase@slip.net>
    Re: complicated reg-exp question <alex@kawo2.rwth-aachen.de>
    Re: debugger mystery... (Ronald J Kimball)
        Help: File locking. networks@skynet.co.uk
        How can I change the 2-dimension array value? <au_aaron@hongkong.com>
        How can I count the 2 dimenion array element? <au_aaron@hongkong.com>
    Re: How can I count the 2 dimenion array element? (Hans-Georg Rist)
    Re: Learn the truth - In Dear Recruiter we establish ex <trashcan@david-steuber.com>
    Re: localtime (brian d foy)
    Re: newbie: how do I read in binary file, modify bytes  (Tad McClellan)
    Re: newbie: how do I read in binary file, modify bytes  (Abigail)
    Re: Output to file - Thanks - but it still don't work! (Hans-Georg Rist)
    Re: Regex $1 behavior (Tad McClellan)
    Re: Regular expression question (Bart Lateur)
        Search engine question. <nobody@replay.com>
    Re: use diagnostics problem? <horizon@internetexpress.com.au>
    Re: use diagnostics problem? (Bart Lateur)
    Re: Where can I find fakessi.pl? (Ronald J Kimball)
    Re: Win32::Registry::RegConnectRegistry Questions <kimntodd@dontspamus.execpc.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 14 Mar 1999 10:17:50 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Accessing Files from another server
Message-Id: <7cg2ce$b02$2@client2.news.psi.net>

Christopher Fairbairn (lgcl01@es.co.nz) wrote on MMXX September MCMXCIII
in <URL:news:921374020.275538@inv.ihug.co.nz>:
?? Hi,
?? 
?? I have a slight problem. I am wanting to make a little "search engine" which
?? will search through all the *.html files on my website and return links to
?? any files which contain a specific string or regex.
?? 
?? Sounds easy? Well thats because it is until I tell you that my "search
?? engine" script has to reside on another server than the one with all the
?? html files.
?? 
?? Why is this the case? Well I have access to two webservers one with CGI and
?? one with out CGI access. I can't use the one with CGI as it already has a
?? project on it which is no removable (ie people associate it with url) and if
?? I place the website on the server without CGI I can't use a CGI script to
?? search it.
?? 
?? The problem I keep comming up against is that to search I use GREP on each
?? individual file (I know its slow but its a very small website) but GREP
?? won't accept a file from another server, it wants a local file.
?? 
?? If I place the CGI script on the server with CGI and PERL I can't access the
?? web pages stored on the other web server.
?? 
?? Is there any way I can get around this?


use Net::ESP;


The Net::ESP package lets your applications "sense" what is in files
stored on other servers. 



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=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: Sat, 13 Mar 1999 19:37:46 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Array lengths
Message-Id: <qc0fc7.ktc.ln@magna.metronet.com>

Bill Binkley (bwb@dowebpages.com) wrote:
: @ppw = ();
: @ppw[0]=();
  ^
  ^

   You should use the -w switch to enable warnings on *all*
   of your Perl programs.

   Really.

   All of them.


: $ppw[0][0]="adm\/";
                 ^
                 ^  that backslash is not needed. It serves no purpose.

: $ppw[0][1]="adm.htm";
: $ppw[0][2]="detail.htm";
: $ppw[0][3]="help.htm";
: @ppw[1]=();
: $ppw[1][0]="all\/";

: Length of @ppw can be obtained with $#ppw


   No it can't.

   The last subscript of @ppw can be obtained with $#ppw

   The last subscript is not the length.


: Is there a corresponding way to get the length of $#ppw[0] and
: $#ppw[1]


      print $#{$ppw[0]}, "\n";


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


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

Date: Sun, 14 Mar 1999 01:53:18 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Array lengths
Message-Id: <1domv3y.q49ha084hvcwN@bay2-157.quincy.ziplink.net>

Bill Binkley <bwb@dowebpages.com> wrote:

> @ppw = ();
> @ppw[0]=();
> $ppw[0][0]="adm\/";
> $ppw[0][1]="adm.htm";
> $ppw[0][2]="detail.htm";
> $ppw[0][3]="help.htm";
> @ppw[1]=();
> $ppw[1][0]="all\/";
> 
> Length of @ppw can be obtained with $#ppw
> 
> Is there a corresponding way to get the length of $#ppw[0] and
> $#ppw[1]

$#{ $ppw[0] }
$#{ $ppw[1] }

The thing to remember is that $ppw[0] contains a reference to an array,
so you need to dereference it.

$ppw[0][1]
${$ppw[0]}[1]
@{$ppw[0]}
$#{$ppw[0]}

Those are all ways of dereferencing an array reference.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 13 Mar 1999 19:19:15 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Can't Increment Counter in FILE Using http://
Message-Id: <3avec7.ktc.ln@magna.metronet.com>

George Crissman (strads@tmisnet.com) wrote:
: On 12 Mar 1999 15:41:38 GMT,  (Abigail) wrote:
: >George Crissman (strads@tmisnet.com) wrote on MMXIX September MCMXCIII in
: ><URL:news:36e88bb1.12273154@news2.tmisnet.com>:
: >`` I thought maybe Perl worked differently when called by a
: >`` browser as compared to the command line.
: >Of course not. That would be stupid. Besides, Perl cannot know whether
: >it's called from a browser.

: That still leaves me wondering why the program works great when 
: called from the command line but not when called by the browser.


   Because the program has different environments when run
   as different users.

   Perl does not control the environment. It just takes what
   it gets.


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


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

Date: 14 Mar 1999 10:15:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Can't Increment Counter in FILE Using http://
Message-Id: <7cg27a$b02$1@client2.news.psi.net>

George Crissman (strads@tmisnet.com) wrote on MMXXI September MCMXCIII in
<URL:news:36ec413a.28423812@news2.tmisnet.com>:
** On 12 Mar 1999 15:41:38 GMT,  (Abigail) wrote:
** >George Crissman (strads@tmisnet.com) wrote on MMXIX September MCMXCIII in
** ><URL:news:36e88bb1.12273154@news2.tmisnet.com>:
** >`` I thought maybe Perl worked differently when called by a
** >`` browser as compared to the command line.
** >Of course not. That would be stupid. Besides, Perl cannot know whether
** >it's called from a browser.
** 
** That still leaves me wondering why the program works great when 
** called from the command line but not when called by the browser.


Perhaps you haven't configured how to call your helper applications
appropriately.


(What other programs does a browser call? Certainly not CGI programs.)



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: Sun, 14 Mar 1999 01:53:20 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: command-line CGI
Message-Id: <1domv8e.nag01q140udzcN@bay2-157.quincy.ziplink.net>

Peter Moore <pmoore@interaccess.com> wrote:

> however the ^D did not work for me on my w32 machine only from the unix box.

On Windows machines, you should use ^Z<return> rather than ^D.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 13 Mar 1999 22:58:12 -0800
From: Paul Cameron <thrase@slip.net>
To: Alex Farber <alex@kawo2.rwth-aachen.de>
Subject: Re: complicated reg-exp question
Message-Id: <36EB5E04.A8A20910@slip.net>

Alex Farber wrote:

> Hi,

Hi Alex, you seem to have an interesting problem on your hands :-)

> I must extract all the function names from some MATLAB files.
> So I am going first remove all names between quotes, since
> these are not function names. But the problem is to recognize
> escaped quotes which are double quotes ('') in MATLAB:
>
>     'blah'              ->    ''
>     'Say ''Hello!'''    ->    ''
>
> So I have tried the following regular expression:
>
>     s/ (?<![]})\w])      # not preceeded by a closing bracket or \w
>        '                 # opening quote
>        .+?               # anything (not greedy)
>        (?<!') ' (?!')    # closing quote (not surrounded by another quotes)
>        / '' /gx;         # remove everything between quotes

> But unfortunately it does not work on 'Say ''Hello!'''
> Any ideas? What I actually would like to say instead of .+? is

You have to understand, I'm no Abigail when it comes to re's, so I may be
wrong!
There goes the disclaimer, anyhow.

Well, lets look at:
       (?<!') ' (?!')    # closing quote (not surrounded by another quotes)
For the closing quote, we have  ... <Hello!'''>

Now, you have a negative look behind assertion, which basically means it'll
look at the last quote, and see there is a quote before it (two in fact), and
will say "screw that, not going to match it". It looks further, and sees at the
end two quotes (located at the end of the string), <''>, the lookbehind and
lookahead assertions kick in, and you get no match.

Let me try with a solution:
$_ = qq['Say ''Hello!'''    ->    ''\n];

s/ (?<![]})\w])        # As per your instructions
   '                   # Start with a quote
   [^']*               # 1: Non quoted text
   (''[^']*'' [^']*)*  # 2: Optionally match double quoted text, and
                       #    and trailing non quotes after it
                       #    multiple times
   '                   # 3: And match the ending quote
/ '' /gx;              # ker-chunk!

print $_;

Let me say, *very tentatively*, it seems to work.
Will catch stuff like <'This is a ''quoted'' test and ''more quotes'' final
quote'> too. But note, it'll match null quotes as well (changing this so
doesn't isn't too hard).

> "anything (non greedy), including double (but not single) quotes"
>
> Thank you!
> /Alex
>
> PS: The lookbehind expression (?<![]})\w]) is needed, because A'
>     or for example [1 0 0]' mean transposed matrices in MATLAB.

Fair enough.

Paul.



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

Date: Sun, 14 Mar 1999 10:40:17 -0500
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: Paul Cameron <thrase@slip.net>
Subject: Re: complicated reg-exp question
Message-Id: <36EBD861.94AA7849@kawo2.rwth-aachen.de>

[posted + mailed]

Paul Cameron wrote:
> 
> s/ (?<![]})\w])        # As per your instructions
>    '                   # Start with a quote
>    [^']*               # 1: Non quoted text
>    (''[^']*'' [^']*)*  # 2: Optionally match double quoted text, and
>                        #    and trailing non quotes after it
>                        #    multiple times
>    '                   # 3: And match the ending quote
> / '' /gx;              # ker-chunk!
> 
> Will catch stuff like <'This is a ''quoted'' test and ''more quotes''
> final quote'> too. But note, it'll match null quotes as well 

Hi Paul,

thanks for your help! Nice solution, but it has unfortunately one problem:
(''[^']*'' [^']*)* means that all the escaped quotes must be matched (occur 
even number of times). So your regular expression won't work for MATLAB 
string concatenation: <str = [  'My name is '''     name     '''!'    ]>
And it will also change  <'ab''cd'>  to  < '' '' > instead of < '' >


I have found a regular expression, which seems to work for me so far
(you can never be 100%-sure with these damn beasties :-)


  s/ (?<![]})\w])        # not preceeded by a closing bracket or \w

     '                   # opening quote

     ( [^'] | '' )+?     # match (non greedy) anything - including 
                         # double quotes and excluding single quotes

     ' (?!')             # closing quote (not followed by another quote)

   / '' /gx;             # remove everything between quotes


Regards
Alex

--
http://www.simplex.ru/pref.html


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

Date: Sun, 14 Mar 1999 01:53:21 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: debugger mystery...
Message-Id: <1domvav.7hgcmn11kn8zbN@bay2-157.quincy.ziplink.net>

Matthew O. Persico <mpersico@bestweb.net> wrote:

> To my experience, it just displays the wrong line. For example, given:
> 
>   while (<>) {
> 
>   # stuff in here
> 
>   }
> 
>   my$foo = 6;
> 
> The debugger will show the while, the my$foo = 6 and then the first
> line in the loop.  Sometimes it jumps to the closing brace and not
> the line following it.  Again, it is annoying, but it is a 
> visual only - the right code gets executed in the desired order.

Exactly.  So John Chambers is blowing the problem out of proportion.
It's annoying, but it hardly makes the debugging session worthless.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 14 Mar 1999 09:26:37 GMT
From: networks@skynet.co.uk
Subject: Help: File locking.
Message-Id: <36eb7cbe.2319433@news.skynet.co.uk>

Hi,

I've read the other messages posted in the group about locking files.
Everyone seems to use FLOCK, but I've been studing some code by
commercial programmer which does this:

	open (LOCK,">$classdir/$short_category_name.lock");
	close LOCK;
	.....
	unlink("$classdir/$short_category_name.lock");

Whats the difference between using FLOCK and $short_category_name.lock
The file I wish to lock is a tab delimited text file  - I don't know
if that matters.

Can someone coment on this please. Thanks in advance :)




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

Date: Sun, 14 Mar 1999 16:59:52 +0800
From: Aaron Au <au_aaron@hongkong.com>
Subject: How can I change the 2-dimension array value?
Message-Id: <36EB7A88.19DAF534@hongkong.com>

@array = ([0,1,2],[3,4,5]);

I want to change the $array[0][0] to '8'.
@array = ([8,1,2],[3,4,5]);
How to do it? Thanks!
--
Cheers,
Aaron Au




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

Date: Sun, 14 Mar 1999 17:13:43 +0800
From: Aaron Au <au_aaron@hongkong.com>
Subject: How can I count the 2 dimenion array element?
Message-Id: <36EB7DC7.20556507@hongkong.com>

@array = ([1,2,3,4],[5,6,7,8]);

How can I count how many elements in this array?
--
Cheers,
Aaron Au




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

Date: Sun, 14 Mar 1999 10:57:41 GMT
From: hans-georg@rist.net (Hans-Georg Rist)
Subject: Re: How can I count the 2 dimenion array element?
Message-Id: <36eb9466.1426456@news.uni-ulm.de>

Aaron Au <au_aaron@hongkong.com> wrote:

>@array = ([1,2,3,4],[5,6,7,8]);
>
>How can I count how many elements in this array?

this depends of what you want: 2 or 8 elements?

print scalar( @array ), "\n";                # 2 elements (references)

print scalar( map{ @$_ } @array ), "\n";     # 8 elements (numbers)

# or:

$c = 0;
foreach my $e ( @array ) {
   $c += @$e;
}
print $c, "\n";                              # 8 elements (numbers)


HTH,
HG

-- 
Hans-Georg Rist
hans-georg@rist.net


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

Date: 13 Mar 1999 04:49:51 -0500
From: David Steuber <trashcan@david-steuber.com>
Subject: Re: Learn the truth - In Dear Recruiter we establish exactly what a recruiter does.
Message-Id: <m3hfrpg1mo.fsf@solo.david-steuber.com>

Please don't keep posting this stuff here.  I'm sure there is a much
more appropriate group for job related articles.

This is a technical group.

-- 
David Steuber
http://www.david-steuber.com
s/trashcan/david/ to reply by mail

Where was it you said you wanted to go today?  Sorry, you can't get
there from here.


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

Date: Sun, 14 Mar 1999 01:17:52 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: localtime
Message-Id: <comdog-ya02408000R1403990117520001@news.panix.com>

In article <7cfgsk$sq5$1@nnrp1.dejanews.com>, Jennifer <webmaster@momsathome.on.ca> posted:

> Could someone tell me what the last element in localtime is?

you have to look at the defintion of a tm struct:

% man localtime

[snip]
The members of the tm structure are:

          int  tm_sec;        /* seconds after the minute - [0, 61] */
                              /* for leap seconds */
          int  tm_min;        /* minutes after the hour - [0, 59] */
          int  tm_hour;       /* hour since midnight - [0, 23] */
          int  tm_mday;       /* day of the month - [1, 31] */
          int  tm_mon;        /* months since January - [0, 11] */
          int  tm_year;       /* years since 1900 */
          int  tm_wday;       /* days since Sunday - [0, 6] */
          int  tm_yday;       /* days since January 1 - [0, 365] */
          int  tm_isdst;      /* flag for alternate daylight savings time */

[snip]

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


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

Date: Sat, 13 Mar 1999 19:15:54 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: newbie: how do I read in binary file, modify bytes and write out?
Message-Id: <q3vec7.ktc.ln@magna.metronet.com>

Joe (painter2000@Cybernex.Net) wrote:

: [our email address is 'painter2000@Cybernex.Net' but WITHOUT
:  the numbers and with all letters lowercase.
                        ^^^^^^^^^^^^^^^^^^^^^

    Normally, case doesn't matter in domain names.

    How did you get it so that it matters for your site?


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


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

Date: 14 Mar 1999 10:26:23 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: newbie: how do I read in binary file, modify bytes and write out?
Message-Id: <7cg2sf$b02$3@client2.news.psi.net>

Joe (painter2000@Cybernex.Net) wrote on MMXXI September MCMXCIII in
<URL:news:7cf4nf$3uf$1@news.cybernex.net>:
:: I checked FAQ and dejanews and haven't seen this discussed. "Programmin Perl"
:: doesn't really explain it.  My goal is to read an MP3 file, analyze the 
:: data, then modify it and write it as a new MP3 file. It seems like a simple
:: thing to do but HOW DOES ONE DO IT???


undef $/;
local *MP3;
open MP3, "+< file.mp3" or die "Oopsie: $!";
my $mp3 = <MP3>;
seek MP3, 0, 0 or die "Oopsie: $!";
$mp3 =~ s/..../...../g;
 .... # Other modifications to the text.
print MP3 $mp3;
close MP3 or die "Ooopsie: $!";



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: Sun, 14 Mar 1999 10:40:44 GMT
From: hans-georg@rist.net (Hans-Georg Rist)
Subject: Re: Output to file - Thanks - but it still don't work!
Message-Id: <36eb91ec.792227@news.uni-ulm.de>

"William H. Asquith" <asquith@macconnect.com> wrote:

>A really good practice is to always check for error conditions on system 
>interaction.
>
>open(SAVE, ">$save") or die "Could not open $save because $!\n";
>
>If your script dies then, you have a system problem and not a script.
>However, note that ">$save" is an explicit open to write and NOT read like
>your doing with print.  Use "<$save" instead.

reading with print ????????????????

HG

-- 
Hans-Georg Rist
hans-georg@rist.net


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

Date: Sat, 13 Mar 1999 16:15:09 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Regex $1 behavior
Message-Id: <tgkec7.3ib.ln@magna.metronet.com>

the jackal (hdiwan@diwanh.stu.rpi.edu) wrote:
: In article <slrn7ej4n4.cbq.jalovel@dogbert.orl.ilstu.edu>, Jeff Lovell wrote:
: >Ok, I'm sure I must be missing something fairly obvious here, but I can't
: >seem to find it.  When I use the $1 backreference in s/// it doesn't seem
:                                   ^ <------- inside a regexp, this needs to be 

   That is true enough...


: >$address =~ s/((\d+\.)*)/$1/;
: $address =~ s/((\d+\.)*)/\1/; # ****!!!!
                           ^^
                           ^^

   ... but that is NOT inside of a regexp.

   That is a replacement string.


: Make the change marked with a '# ****!!!!' above and you will get the result 
: you seek.


    If he makes the change recommended, he will get exactly
    the same output, along with a warning that he wasn't
    getting when he did it the Right Way using $1


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


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

Date: Sun, 14 Mar 1999 09:44:24 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Regular expression question
Message-Id: <36eb8218.545679@news.skynet.be>

Tom Wood wrote:

>I am trying convert all upercase character to lowercase unless they are
>quote encapsulated.
>
>for example:
>
>strings such as "THIS", 'THIS SENTENCE' and " THAT " would be excluded
>from the conversion.

#! perl -w
$_ = <<;
STRINGS SUCH AS "THIS", 'THIS SENSTENCE' AND " THAT " WOULD BE EXCLUDED 
FROM THE CONVERSION.

s/("[^"]*"|'[^']*')|([^"']+)/$1 || lc $2/ge;
print;
__END__
strings such as "THIS", 'THIS SENSTENCE' and " THAT " would be excluded 
from the conversion.

	Bart.


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

Date: Sun, 14 Mar 1999 08:22:34 +0100 (CET)
From: Anonymous <nobody@replay.com>
Subject: Search engine question.
Message-Id: <199903140722.IAA18422@mail.replay.com>

Sorry for the wrong title in the last post...

I use this perl script below to search in an image database its a simple
search script that will return all lines where the search word is contained 

Database file:

kjdhlkgfd  szdffjjsdf keyword sdf sfdwe sdf 
ljfds sdf sdf   sdf  dsf  dsf  saa
hdsfjs keyword skdng xzkcn

If you search for "keyword" the script will return:

kjdhlkgfd  szdffjjsdf keyword sdf sfdwe sdf 
hdsfjs keyword skdng xzkcn

This works fine but I would like the modify the script so the result will
be returned like this:

<tr><td>1. Line</td><td>2. Line</td><td>3. line</td></tr> 
<tr><td>4. Line</td><td>5. Line</td><td>6. line</td></tr> 
<tr><td>1. Line</td><td>2. Line</td><td>3. line</td></tr> 
and so on...

So how do I make the script count 1 2 3 and input </tr><tr> count 1 2 3 and
input  </tr><tr> count  1 2 3 and input  </tr></tr> and so on...

I don't know to much about perl programing so please show be how to modify
the code.

Hope someone can help me, if you know of a better way to search in a image
database please let me know. If you post a reply I would be very grateful
is you could go to the trouble and email the message to me at:
webmaster@photographynews.com

Bjarne Christiansen
webmaster@photographynews.com


Here is the script I use:

#!/usr/bin/perl

#============================================================#
#  Author: Vladimir Geshanov    Email: info@websigh.com      #
#  Online documentation: http://www.hotarea.com/web/scripts  #
#============================================================#

require 'search02.conf';

$delimiter = "<!--begin-->";
$count1 = "0";
$count2 = "0";
$comp = "0";
$id = "Web Office";
$font = "font size=2 face=Verdana";

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
   ($name, $value) = split(/=/, $pair);
   $value =~ tr/+/ /;
   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
   $value =~ s/<!--(.|\n)*-->//g;
   $FORM{$name} = $value;
   $word1 = $FORM{'T1'};
   $word2 = $FORM{'T2'};
   $query1 = $FORM{'D1'};
   $query1 =~ tr/[A-Z]/[a-z]/; }

open (TEMP,"$template") || die "Can't Open $template: $!\n";
      @TEMP_LINES=<TEMP>;
      close(TEMP);
      $TEMP_SIZE=@TEMP_LINES;

#Start printing the HTML output
   print "Content-Type: text/html\n\n";
for ($i=0;$i<=$TEMP_SIZE;$i++)     { 
        $TEMP_LINES[$i] =~ s/\cM/\n/g;
        $_=$TEMP_LINES[$i];
    if (/$delimiter/) {&search_database;}
  else {print "$TEMP_LINES[$i]";}   }
exit;

sub search_database {                      # One word without OR / AND
   if ($id eq "Web Office")  {
   if ($FORM{'T1'} && !$FORM{'T2'}) {
       $count1 = `$fgrepprog -i -n -s $word1 $database/* | wc -l`;
chop($count1);
     open (SEARCH1, "$fgrepprog -i -n -s $word1 $database/* |");
        print "<p><font size=\"2\" face=\"MS Sans Serif\">\n";
        print "Searching for <b><u>$word1</u></b> ...<br>\n";
        print "Total matches: <b>$count1</b><br><hr>\n";
     while (<SEARCH1>) {
   if ( ($file1, $number1, $line1) = m|^(/\S+)([\-:])\d+\2(.*)| ) {
        print "$line1 <br>\n";
     next;
     close (SEARCH1) ;     }    }
        print "<hr><p><center><a href='$ENV{HTTP_REFERER}'>";
        print "<$font><b>Back to the Main Page</b></a>\n";
        print "<p><hr width=300>\n";
        print "<font size=-2>Powered by <a
href='http://www.hotarea.com/web'>$id</a>";
        print "</body>\n</html>\n";      }   }

                                            # Two words plus AND
   if ($id eq "Web Heaven")  {
   if ($FORM{'T1'} && $FORM{'T2'} && $FORM{'c'} eq "news") {
    $count1 = `$fgrepprog -i -n -s $word1 $database/* | $fgrepprog -i -n -s
$word2 | wc -l`; chop($count1);
     open (SEARCH2, "$fgrepprog -i -n -s $word1 $database/* | $fgrepprog -i
-n -s $word2 |");
        print "<p><font size=\"2\" face=\"MS Sans Serif\">\n";
        print "Searching for <b><u>$word1</u></b> AND <b><u>$word2</u></b>
 ..<br>\n";
        print "Total matches: <b>$count1</b><br><hr>\n";
    while (<SEARCH2>) {
   if ( ($file1, $number1, $line1) = m|^\d+[\-:](/\S+)([\-:])\d+\2(.*)| ) {
        print "$line1 <br>\n";
    next;
    close (SEARCH2) ; }    }    
        print "<hr><p><center><a href='$ENV{HTTP_REFERER}'>";
        print "<$font><b>Back to the Main Page</b></a>\n";
        print "<p><hr width=300>\n";
        print "<font size=-2>Powered by <a
href='http://www.hotarea.com/web'>$id</a>";
        print "</body>\n</html>\n";      }     }

                                           # Two words plus OR
   if ($id eq "Web Heaven")  {
   if ($FORM{'T1'} && $FORM{'T2'} && $FORM{'c'} eq "guide") {
    open (SEARCH1, "$fgrepprog -i -h -s $word1 $database/* |");
          @lines1=<SEARCH1>;
    close(SEARCH1);
    open (SEARCH2, "$fgrepprog -i -h -s $word2 $database/* |");
          @lines2=<SEARCH2>;
        print "<p><$font>\n";
        print "Searching for <b><u>$word1</u></b> OR <b><u>$word2</u></b>
 ..<br><hr>\n";
    foreach $newline1 (@lines1)  {  $comp = "0";
    foreach $newline2 (@lines2)  {
   if ( $newline1 eq $newline2 )   {  $comp = $comp + 1;  }
else { $comp = $comp + 0;  }    }
   if ( $comp eq 0 )            { print "$newline1<br>\n"; }       }
    foreach $newline2 (@lines2) { print "$newline2<br>\n"; }       
    close(SEARCH2);   
        print "<hr><p><center><a href='$ENV{HTTP_REFERER}'>";
        print "<$font><b>Back to the Main Page</b></a>\n";
        print "<p><hr width=300>\n";
        print "<font size=-2>Powered by <a
href='http://www.hotarea.com/web'>$id</a>";
        print "</body>\n</html>\n";      }      }

                                           # No OR / AND specified
   if ($FORM{'T1'} && $FORM{'T2'} && !$FORM{'c'}) {
        print "<p><$font>\n";
        print "<b>Well, you have two options - clear one of the ";
        print "words or select options AND/OR :-)</b><br>\n";  }

                                           # No word are specified
   if (!$FORM{'T1'} && !$FORM{'T2'}) {
        print "<p><$font>\n";
        print "<b>What the hell are you doing? Type some word for God sake
 ..</b><br>\n"; }
}





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

Date: Sun, 14 Mar 1999 17:46:26 +1100
From: Mick <horizon@internetexpress.com.au>
To: Ronald J Kimball <rjk@linguist.dartmouth.edu>
Subject: Re: use diagnostics problem?
Message-Id: <36EB5B42.856CB7B@internetexpress.com.au>

> You can't compare Carp and diagnostics for their formats.  They do
> completely different things.
>

Ok....

> What output do you get when you run your script from the command line?
>

Script works fine from DOS prompt with use diagnostics line commented out, but
-Output is...(with use diagnostics line), from DOS prompt...C:\Program
Files\Apache Group\Apache\cgi-bin>perl account.plcouldn't find diagnostic data
in C:\Perl\5.00502\lib/pod/perldiag.pod C:\PERL\5.
00502\lib/MSWin32-x86-object C:\PERL\5.00502\lib
C:\PERL\site\5.00502\lib/MSWin3
2-x86-object C:\PERL\site\5.00502\lib C:\PERL\site\lib . account.pl at
C:\PERL\5
 .00502\lib/diagnostics.pm line 229, <POD_DIAG> chunk 533.
BEGIN failed--compilation aborted at account.pl line 5, <POD_DIAG> chunk 533.

Am I missing perldiag.pod?

Thanks for the reply,
Mick



> --
>  _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
> ( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
>     /                                  http://www.ziplink.net/~rjk/
>         "It's funny 'cause it's true ... and vice versa."



--
----------------------------------------------------------------
HORIZON Software Solutions

Visit Site - http:www.deakin.edu.au/~bellears/horizon/index.html
e-mail     - mailto:horizon@internetexpress.com.au

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




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

Date: Sun, 14 Mar 1999 09:44:26 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: use diagnostics problem?
Message-Id: <36ec83ec.1009191@news.skynet.be>

Mick wrote:

>Why would use diagnostics cause premature end of script header?

Because now the program fails to compile?

Try sending fatals to browser, BEFORE doing antything else.

   HTH,
   Bart.


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

Date: Sun, 14 Mar 1999 01:59:58 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Where can I find fakessi.pl?
Message-Id: <1domw01.c59frb133srf5N@bay2-157.quincy.ziplink.net>

Geoff Wilkins <GeoffW@wordsmith.demon.co.uk> wrote:

> The source for the utility fakessi.pl is everywhere given as 
> 
>         http://sw.cse.bris.ac.uk/WebTools/fakessi.html
> 
> but I can't reach this.  Does anyone know an alternative source?


Aren't search engines great?

http://www.icaadvertising.co.uk/scripts/fakessi.pl
http://www.emerald-isle.com/emerald/scripts/fakessi.pl


Thanks, HotBot!


-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 14 Mar 1999 00:09:43 -0600
From: "End User" <kimntodd@dontspamus.execpc.com>
Subject: Re: Win32::Registry::RegConnectRegistry Questions
Message-Id: <7cfjsk$gad@newsops.execpc.com>

After searching the web, I located information that was able to help me. For
those that are interested, here is an example that searches a remote
registry, and gives back the serial (license number) for a remotely
possible/32 client.

use Win32::Registry;
my ($node) = '\\\\172.16.1.5';
my ($hNode, $hKey, %vals);
$HKEY_LOCAL_MACHINE->Connect($node,$hNode) || die "cannot connect to
$node\n";
$hNode->Open("SOFTWARE\\Avalan\\Remotely Possible/32\\General",$hKey);
$hKey->GetValues(\%vals);
foreach $k (keys %vals){
 $key = $vals{$k};
 if ($$key[0] =~ /license/ig) {
  print "$$key[2]\n";}
   }

I hope this helps someone if they are also facing this challenge.

Thanks,




End User wrote in message <7ccs7n$n9m@newsops.execpc.com>...
>Ok, so I found the entire two sentences that were dedicated to accessing
>remote NT registries (well, NT and 95, but I really only use NT so there
you
>go). There is one terrible example that I cannot seem to make sense of:
>
>use Win32::Registry;
>Win32::Registry::RegConnectRegistry("\\\\somemachine", HKEY_LOCAL_MACHINE,
>$key) || die "connect: $!";
>
>I understand some of this. I get the use comand, and the Win32::reg... and
>the somemachine, and the hkey_local_machine, but what is with the $key
part?
>how do I now go about slicing and dicing the remote registries based on
>this? I am not a great programmer, just an admin. though I have quickly
>surpassed those that have taught me. Sorry, I digress.
>
>Do I need to do something like this:
>
>use Win32::Registry;
>Win32::Registry::RegConnevtRegistry("\\\\172.16.1.5", HKEY_LOCAL_MACHINE,
>$SSD);
>$SSD=GetVal(\%vals);
>foreach $k (keys %vals){
>    if ($keys =~ /cpqssd/i){
>        print "$vals{$k}\n";}
>                                    }
>
>in order to get a value for a particular key from a remote machine?
>
>If I this is close, but not quite there, please tell me. If this isnt even
>on the same planet, I need to know that too.
>
>Thanks a million times in advance,
>
>
>--
>Todd Hayward
>Global Analyst, Systems Engineer
>MCSE, Compaq ACT
>noc at bakernet dot com
>
>




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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 5130
**************************************

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