[9830] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3423 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 12 00:07:33 1998

Date: Tue, 11 Aug 98 21:00:15 -0700
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, 11 Aug 1998     Volume: 8 Number: 3423

Today's topics:
        $SIG{ALRM} question <maryesme@mail.localaccess.com>
        Beginners problem? <hluukkala@bigfoot.com>
    Re: CGI for managing web site??? <j_pipes@tolstoy.mdc.com>
    Re: comp.lang.perl.announce redux (David Adler)
    Re: dates in excess of 2037 (A Problem???) (Ilya Zakharevich)
    Re: File updating question <REPLY_TO_lastronin@earthlink.net>
    Re: How to handle food properly (Martien Verbruggen)
    Re: html arborescence in iso9660 (Mark-Jason Dominus)
    Re: LOCK DATABASE FILES? (Martien Verbruggen)
    Re: printing remote host (Martien Verbruggen)
    Re: Regexp this! (if possible anyhow...) (Abigail)
    Re: search text in specific columns (Patrick Timmins)
    Re: Test your Javascript and HTML knowledge (Miguel Cruz)
    Re: Windows 95 perl and long-directory names. (Martien Verbruggen)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 11 Aug 1998 20:51:27 -0700
From: Mark Lybrand <maryesme@mail.localaccess.com>
Subject: $SIG{ALRM} question
Message-Id: <35D1113F.24E9@mail.localaccess.com>

Hello again,

You guys were such a big help with understanding what was being done
with that "grep" function...

In any event, in the example script from Lincoln Stein's CGI.pm book,
located at:

http://www.wiley.com/compbooks/stein/text/guestbook.txt

I am having a problem understanding what the following code snippet is
doing:

local($msg, $oldsig);
my $handler = sub { $msg = 'timed out'; $SIG{ALRM} = $oldsig; };
($oldsig, $SIG{ALRM}) = ($SIG{ALRM}, $handler);
alarm($TIMEOUT);

In the text he states that the anonymous sub only sets the $msg
variable.  I guess my problem is understanding what is returned by the
anonymous sub (this would go into $SIG{ALRM}, right?).  So, $oldsig
takes the value that $SIG{ALRM} had and $SIG{ALRM}???   Also, why are we
even holding on to the old signal, since the script does not seem to
return this to $SIG{ALRM} except in the sub.  Is that it?  Does the
$SIG{ALRM} just stay the same?  In that case... $oldsig gets $SIG{ALRM}
THEN the sub runs, sets $msg and then $SIG{ALRM} gets set back??  I
still don't get how that is the return value from the sub.

Oh well, I will quit rambling and let the PERL gurus out there set me on
the right path.

TIA

Mark :)


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

Date: Wed, 12 Aug 1998 05:29:11 +0300
From: Heikki Luukkala <hluukkala@bigfoot.com>
Subject: Beginners problem?
Message-Id: <35D0FDF5.274D@bigfoot.com>

How can I make words beginning with http:// to work as links?

$text = "Some text http://www.domain.com/page.html some more text."

How can I change it to:
"Some text <A
HREF=http://www.domain.com/page.html>http://www.domain.com/page.html</A>
some more text."

Something like $text =~ s/?/?/g ?


Thanks,
Heikki Luukkala


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

Date: Tue, 11 Aug 1998 18:28:17 GMT
From: "Jerry A. Pipes" <j_pipes@tolstoy.mdc.com>
To: Michael Mosher <mmosher@ibm.net>
Subject: Re: CGI for managing web site???
Message-Id: <35D08D41.7DE1@tolstoy.mdc.com>

Michael Mosher wrote:
> Does anyone know of a script for uploading and deleting files 
> without using FTP? I'd like one that's easy to set up. Please 
> post or email your suggestions.

Try this:
http://www.terminalp.com/scripts/file_upload.shtml

I haven't used it myself, but it sounds like what you wanted.

l8r,
-- 
  Jerry A. Pipes                                  &oo{
                                                /      \
       _____ ___ _ _____ _____ ____ __   __    /--------\
      |  ___|   | |  ___| | | | __ |\ \ / /   /__________\
      |___  | | | |  ___| | | |  __| \   /      |______|
   ---|_____|_|___|_____|_____|_|-----|_|-------|______|----
 -------------------------------------------------------------
  j_pipes@tolstoy.mdc.com                       snewpy@mo.net
 -------------------------------------------------------------


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

Date: 12 Aug 1998 03:29:23 GMT
From: dha@panix.com (David Adler)
Subject: Re: comp.lang.perl.announce redux
Message-Id: <6qr26j$pvk@news1.panix.com>

On 03 Aug 1998 09:51:44 -0600, Nathan Torkington <gnat@frii.com> wrote:
>Is PerlMongers a registered non-profit?

a) Perl Mongers is two words... :-)

and

b) Yes.

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Perhaps the Monty Python Scholar in America today"
	-New Yorker magazine 13mar89


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

Date: 12 Aug 1998 03:21:58 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: dates in excess of 2037 (A Problem???)
Message-Id: <6qr1om$io7$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Craig Berry
<cberry@cinenet.net>],
who wrote in article <6qq6ib$2v6$1@marina.cinenet.net>:
> The point is that localtime() et all treat their 32-bit argument as a
> signed value

No, they do not.  They treat it as time_t.  It is unsigned long here
(EMX port):

>perl -le "print scalar localtime 3*2**30"
Thu Jan 28 08:51:12 2072
>perl -le "print scalar localtime 7*2**30"
Thu Jan 28 08:51:12 2072

Ilya


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

Date: Tue, 11 Aug 1998 23:19:21 -0400
From: "Ha" <REPLY_TO_lastronin@earthlink.net>
Subject: Re: File updating question
Message-Id: <6qr0v2$ctm$1@oak.prod.itd.earthlink.net>

This is a multi-part message in MIME format.

------=_NextPart_000_0115_01BDC57E.794BBDC0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


Ketan Patel wrote in message <35D0D15D.F04F568E@mathworks.com>...
>This is similar to the 'updating array' problem, but only one file is
>opened/updated/closed (instead of open/update/write to new)... I =
believe the
>"slurping of a file into a fat array" that I am doing is causing some =
problems
>considering this is run on a website after every hit... How would I go =
about
>'optimizing' this process?
>
>$dataPath =3D "sites.txt"; #sites.txt is a ~100 line text file (~25k) =
in which
>fields are separated by "|"'s
>
>sub check_status{
>    open(DATA,"<$dataPath");
>    flock DATA, 2;
>    @databaseArray =3D <DATA>;
>    close(DATA);



i don't understand why you're using flock() on file read. it's =
unnecessary. even so, if you use flock 2, remember to flock 8 (unlock =
it) before closing FILE. you might also want to do || die or || print or =
something after open() to give yourself a message if anything goes =
wrong. this is just good Perl habit.


>    $x =3D 0;
>
>    foreach (@databaseArray) {
>        @sitesArray =3D split(/\|/,$databaseArray[$x]);
>        [do stuff to each element of @sitesArray]
>        $databaseArray[$x] =3D join("\|",@sitesArray);
>        $x++;
>    }



okay, i see a lot of problems here. i'm sure it works, but it's =
unconventional as heck. Perl gives us a lot of clean ways to do what =
you're trying to do in the chunk of code above. i'll give a few =
examples. you should go through perldocs and all the man pages. heck, =
pick up Tom Christian's turquoise camel book. it's great.

1) you don't need to start a counter and increment if you're doing a for =
or foreach. that's exactly what these fun functions do for you. to =
access elements of an array:

    foreach $somescalarname(@array)    # this is the proper syntax for a =
foreach()
    {
        $somescalarname =3D [... do something];
    }

    or ...

    for $array_pos(0 .. $#array)                # $array_pos counts from =
zero to number of elements in list
    {
        $array[$array_pos] =3D [... do something];
    }

2) to avoid slurping into @array, open to read source file, open to =
write destination file, work on $_.

    # rename datafile to something temporary
    $temppath =3D '/cgi-bin/foo/bar/sitesX.txt';
    $datapath =3D '/cgi-bin/foo/bar/sites.txt';
    rename $datapath, $temppath;

    open(TEMP, "<$temppath")
        || print ("Mommy, I'm not coming home.");

    open(DATA, ">$datapath")
        || print ("Son, it's not my fault.");
    flock(DATA, 2);

    while (<TEMP>)      # for clarity, you may want to do ($line =3D =
<TEMP>)
    {
        chomp $_;
        @stuff =3D split(/\|/, $_);
        for $i(0 .. $#stuff)
        {
            [do something to $stuff[$i] ...]
        }
        $_ =3D join '|', @stuff;
        $_ .=3D "\n";                       # put newline back on

        print DATA $_;
    }

    close(TEMP);                          # close them in order they =
were opened
    flock(DATA, 8);                       # unlock file
    close(DATA);
    unlink($temppath);                    # delete original

3) well, a time wherein @array =3D <FILE> is efficient is if FILE is not =
too large and you have plenty of memory to spare. 100 lines of 25K is =
not bad. do similar to above if you want to slurp:

    open(blah blah < ); ....
    @array =3D <FILE>;
    close(); ....

    for $i(0 .. $#array)                 # positions in array
    {
        chomp $array[$i];
        @line =3D split(/\|/, $array[$i]);
        foreach $field(@line)            # items (here called 'field')
        {                                # in position (called 'line') =
of array
            $field =3D [do something...];
        }
        $array[$i] =3D join '|', @line;
        $array[$i] .=3D "\n";
    }

    open (blah blah > ); ...
    flock(FILE, 2);
    print FILE @array;
    flock(FILE, 8);
    close(FILE);

hope that helped.
cheers,
ha quach
mailto:info@r-go.com


>    open(DATA,">$dataPath");
>    flock DATA, 2;
>    print DATA @databaseArray;
>    close(DATA);
>}
>

------=_NextPart_000_0115_01BDC57E.794BBDC0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY>
<DIV>&nbsp;</DIV>
<DIV>Ketan Patel<KPATEL@MATHWORKS.COM> wrote in message &lt;<A=20
href=3D"mailto:35D0D15D.F04F568E@mathworks.com">35D0D15D.F04F568E@mathwor=
ks.com</A>&gt;...</DIV>
<DIV>&gt;This is similar to the 'updating array' problem, but only one =
file=20
is<BR>&gt;opened/updated/closed (instead of open/update/write to new)... =
I=20
believe the<BR>&gt;&quot;slurping of a file into a fat array&quot; that =
I am=20
doing is causing some problems<BR>&gt;considering this is run on a =
website after=20
every hit... How would I go about<BR>&gt;'optimizing' this=20
process?<BR>&gt;<BR>&gt;$dataPath =3D &quot;sites.txt&quot;; #sites.txt =
is a ~100=20
line text file (~25k) in which<BR>&gt;fields are separated by=20
&quot;|&quot;'s<BR>&gt;<BR>&gt;sub =
check_status{<BR>&gt;&nbsp;&nbsp;&nbsp;=20
open(DATA,&quot;&lt;$dataPath&quot;);<BR>&gt;&nbsp;&nbsp;&nbsp; flock =
DATA,=20
2;<BR>&gt;&nbsp;&nbsp;&nbsp; @databaseArray =3D=20
&lt;DATA&gt;;<BR>&gt;&nbsp;&nbsp;&nbsp; close(DATA);<BR></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>i don't understand why you're using flock() on file read. it's =
unnecessary.=20
even so, if you use flock 2, remember to flock 8 (unlock it) before =
closing=20
FILE. you might also want to do || die or || print or something after =
open() to=20
give yourself a message if anything goes wrong. this is just good Perl=20
habit.</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&gt;&nbsp;&nbsp;&nbsp; $x =3D =
0;<BR>&gt;<BR>&gt;&nbsp;&nbsp;&nbsp;=20
foreach (@databaseArray) =
{<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
@sitesArray =3D=20
split(/\|/,$databaseArray[$x]);<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
[do stuff to each element of=20
@sitesArray]<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$databaseArray[$x] =3D=20
join(&quot;\|&quot;,@sitesArray);<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;=20
$x++;<BR>&gt;&nbsp;&nbsp;&nbsp; }<BR></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>okay, i see a lot of problems here. i'm sure it works, but it's=20
unconventional as heck. Perl gives us a lot of clean ways to do what =
you're=20
trying to do in the chunk of code above. i'll give a few examples. you =
should go=20
through perldocs and all the man pages. heck, pick up Tom Christian's =
turquoise=20
camel book. it's great.</DIV>
<DIV>&nbsp;</DIV>
<DIV>1) you don't need to start a counter and increment if you're doing =
a for or=20
foreach. that's exactly what these fun functions do for you. to access =
elements=20
of an array:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; foreach =
$somescalarname(@array)&nbsp;&nbsp;&nbsp; # this=20
is the proper syntax for a foreach()</DIV>
<DIV>&nbsp;&nbsp;&nbsp; {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $somescalarname =3D [... =
do=20
something];</DIV>
<DIV>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; or ...</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp; for $array_pos(0 ..=20
$#array)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;=20
# $array_pos counts from zero to number of elements in list</DIV>
<DIV>&nbsp;&nbsp;&nbsp; {</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $array[$array_pos] =3D =
[... do=20
something];</DIV>
<DIV>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>2) to avoid slurping into @array, open to read source file, open to =
write=20
destination file, work on $_.</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; # rename =
datafile to=20
something temporary</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; $temppath =
=3D=20
'/cgi-bin/foo/bar/sitesX.txt';</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; $datapath =
=3D=20
'/cgi-bin/foo/bar/sites.txt';</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; rename =
$datapath,=20
$temppath;</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; open(TEMP,=20
&quot;&lt;$temppath&quot;)</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
|| print (&quot;Mommy, I'm not coming home.&quot;);</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; open(DATA,=20
&quot;&gt;$datapath&quot;)</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
|| print (&quot;Son, it's not my fault.&quot;);</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; flock(DATA,=20
2);</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; while=20
(&lt;TEMP&gt;)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # for clarity, you may want =
to do=20
($line =3D &lt;TEMP&gt;)</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; =
{</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
chomp $_;</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
@stuff =3D split(/\|/, $_);</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
for $i(0 .. $#stuff)</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{</FONT></DIV>
<DIV><FONT face=3D"Courier New"=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p; [do=20
something to $stuff[$i] ...]</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$_ =3D join '|', @stuff;</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$_ .=3D=20
&quot;\n&quot;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
# put newline back on</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
print DATA $_;</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; =
}</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp;=20
close(TEMP);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;=20
# close them in order they were opened</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; flock(DATA,=20
8);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
# unlock file</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp;=20
close(DATA);</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp;=20
unlink($temppath);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
# delete original</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>3) well, a time wherein @array =3D &lt;FILE&gt; is efficient is if =
FILE is=20
not too large and you have plenty of memory to spare. 100 lines of 25K =
is not=20
bad. do similar to above if you want to slurp:</DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; open(blah =
blah &lt; );=20
 ....</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; @array =3D=20
&lt;FILE&gt;;</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; close();=20
 ....</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; for $i(0 ..=20
$#array)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
# positions in array</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; =
{</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
chomp $array[$i];</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
@line =3D split(/\|/, $array[$i]);</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
foreach=20
$field(@line)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;=20
# items (here called 'field')</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
# in position (called 'line') of array</FONT></DIV>
<DIV><FONT face=3D"Courier New"=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p; $field=20
=3D [do something...];</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$array[$i] =3D join '|', @line;</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$array[$i] .=3D &quot;\n&quot;;</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; =
}</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; open (blah =
blah &gt; );=20
 ...</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; flock(FILE,=20
2);</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; print FILE=20
@array;</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; flock(FILE,=20
8);</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp;=20
close(FILE);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>hope that helped.</DIV>
<DIV>cheers,</DIV>
<DIV>ha quach</DIV>
<DIV><A href=3D"mailto:info@r-go.com">mailto:info@r-go.com</A></DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&gt;&nbsp;&nbsp;&nbsp;=20
open(DATA,&quot;&gt;$dataPath&quot;);<BR>&gt;&nbsp;&nbsp;&nbsp; flock =
DATA,=20
2;<BR>&gt;&nbsp;&nbsp;&nbsp; print DATA=20
@databaseArray;<BR>&gt;&nbsp;&nbsp;&nbsp;=20
close(DATA);<BR>&gt;}<BR>&gt;</DIV></BODY></HTML>

------=_NextPart_000_0115_01BDC57E.794BBDC0--



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

Date: 12 Aug 1998 02:53:51 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How to handle food properly
Message-Id: <6qr03v$4v6$1@nswpull.telstra.net>

In article <998222410380.8059590448@earthlink.net>,
	dgo4th@earthlink.net writes:

> Any opinions?

Yes. Go away, and I am struggling not to use a more expletive way of
expressing that opinion. What a totally transparent attempt at hiding
a silly spam.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: 11 Aug 1998 23:27:25 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: html arborescence in iso9660
Message-Id: <6qr22t$4h8$1@monet.op.net>

In article <35D0C2C5.1C0DD835@dial.pipex.com>,
Bob Newman  <Noggs@dial.pipex.com> wrote:
>I deem it to be already standard English.

Sure, but perhaps not in this context.  I'd never heard `arborescence'
used to refer to HTML before.  Did I miss out on a common locution?

`Editor' is standard English too, but if you're the first person to
use it to refer to a certain kind of computer program, that's a new
coinage.




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

Date: 12 Aug 1998 02:56:01 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: LOCK DATABASE FILES?
Message-Id: <6qr081$4v6$2@nswpull.telstra.net>

In article <6qmcor$m1n$1@news.cde.net>,
	"Sleepy_Z" <zelo@cde.com> writes:
> I am writing a database file that will only be READ and not WRITTEN to. Do I
> need to lock that database or will it be ok without it?

That seems impossible. You are writing a database file that will not
be written to? Do you mean that you are writing a script that accesses
a database in a read-only manner? And that the database will not be
changed at all?

In that case you shouldn't need to lock anything.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: 12 Aug 1998 02:43:45 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: printing remote host
Message-Id: <6qqvh1$4md$1@nswpull.telstra.net>

In article <35CDCCCC.F21688DC@crocker.com>,
	Thomas Emery <temery@crocker.com> writes:
> I have a message board (and the people) want to list all poster's IP
> address.  I am assuming that it is as simple as finding the file that
> right now generates the messages and put in a line that says something
> like print Remote_Host or something like that.

I am not sure about what you are trying to do... Is this a CGI
program? Are you trying to find out how to get the IP address of the
client in a CGI program? You really should ask that on a CGI group
next time, somewhere in comp.infosystems.www.*. 

A few hints: $ENV{REMOTE_ADDR}. If any of your users is using a proxy
you will get the proxy's IP address, not the user's. IOW: It's pretty
useless to do that.

If you also need to know how to change your scripts to do that, well,
you will have to do that yourself. We won't be able to do that for
you, especially since we don't see your code here (which is not an
invitation to send all your code here). Please try implementing it
yourself first.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: 12 Aug 1998 03:43:16 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Regexp this! (if possible anyhow...)
Message-Id: <6qr30k$i3o$1@client3.news.psi.net>

Niklas Matthies (matthies@fsinfo.cs.uni-sb.de) wrote on MDCCCVI September
MCMXCIII in <URL: news:6qqhl5$5g3$1@hades.rz.uni-sb.de>:
++ I got a tough parsing task. Consider a text file, collapsed in a single
++ scalar (i.e. a string containing newlines). It may contain C-style comments
++ ("/* ... */"), Pascal(?)-style comments ("(* ... *)") and/or C++-style
++ comments ("// ... \n"). These may be freely nested and intermixed, and
++ may (except the C++-style comments) span multiple lines. Now, I need the
++ first line matching /^[ \t]* KEYWORD [ \t]+ (\w+) [ \t]*$/x that is _not_
++ contained in any comment. More precisely, I need the word following the
++ KEYWORD, plus the line number of that line, plus the remaining lines.
++ 
++ Example:
++ 
++ $a = <<EOT;
++     we fewr we we (* ewr
++     gqer *) qer gqe /* qer // KEYWORD bla wrt wrth
++     (* qerg KEYWORD blarg qe *) qerg qe */ .
++     wrt wrtb b   wrtrwtb
++     df;we wef wef // KEYWORD bloerg wefd wef
++     wfefwef(* KEYWORD bluwef qe //we ew*)wef wef wef
++     we we f
++     KEYWORD foo
++     wer qerg (* eqrg ewtw r KEYWORD /* wet wr KEYWORD argl erg re */ r
++     wrth *)gqerg  // KEYWORD qwrqe  qerg qer  qer
++     eq eqr qegq ergqerg eq
++ EOT
++ 
++ What I'd want here is 'foo', 8 (the line number), and <<EOT;
++     wer qerg (* eqrg ewtw r KEYWORD /* wet wr KEYWORD argl erg re */ r
++     wrth *)gqerg  // KEYWORD qwrqe  qerg qer  qer
++     eq eqr qegq ergqerg eq
++ EOT
++ 
++ The crucial question is: Can I somehow use regexps that keep track of
++ comment nesting levels _and_ line numbers,


Yes. Under the assumption "nested" comments are /* /* ... */ */ and
(* (* ... *) *), but // // ... \n, that is, as many /* and */, as
many (* as *), but many // can be terminated by a single \n:


#!/usr/local/bin/perl -w

use strict;

my $line = <<EOT;
    we fewr we we (* ewr
    gqer *) qer gqe /* qer // KEYWORD bla wrt wrth
    (* qerg KEYWORD blarg qe *) qerg qe */ .
    wrt wrtb b   wrtrwtb
    df;we wef wef // KEYWORD bloerg wefd wef
    wfefwef(* KEYWORD bluwef qe //we ew*)wef wef wef
    we we f
    KEYWORD foo
    wer qerg (* eqrg ewtw r KEYWORD /* wet wr KEYWORD argl erg re */ r
    wrth *)gqerg  // KEYWORD qwrqe  qerg qer  qer
    eq eqr qegq ergqerg eq
EOT


my $regex = join '|', "(?:\n)", map {"(?:\Q$_\E)"} qw ~ /* */ (* *) // ~;

$regex .= "|(?:[ \t]*KEYWORD[ \t]+(\\w+)[ \t]*\$)";

my ($c_count, $c_plus_plus_count, $pascal_count, $line_count);


MAIN:
while ($line =~ m /\G.*?($regex)/gom) {
    foreach ($1) {
        /\n/   && do {   $c_plus_plus_count = 0;
                      ++ $line_count;                     next;};
        /\/\// && do {++ $c_plus_plus_count;              next;};
        /\/\*/ && do {++ $c_count;                        next;};
        /\*\// && do {-- $c_count       if $c_count;      next;};
        /\(\*/ && do {++ $pascal_count;                   next;};
        /\*\)/ && do {-- $pascal_count  if $pascal_count; next;};

        # Must match keyword.
        unless ($c_count || $c_plus_plus_count || $pascal_count) {
            # Line count started at 0, need one more for humans.
            $line_count ++;
            print "What I'd want here is '$2', $line_count (the line number), ";
            print "and <<EOT;\n";
            print substr $line, 1 + pos $line;  # +1, skip over newline.
            print "EOT;\n";
            last MAIN;
        }
    }
}

__END__
-- 
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
          for (s;s;s;s;s;s;s;s;s;s;s;s)
              {s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'


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

Date: Wed, 12 Aug 1998 03:37:33 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: search text in specific columns
Message-Id: <6qr2lu$ekf$1@nnrp1.dejanews.com>

In article <6qqele$e2u$1@nnrp1.dejanews.com>,
  stevenba@carr.org wrote:
> Hi.  I'm very new to Perl, so please excuse me if this is not the correct
> forum or the answer is obvious.
>
> Can anyone tell me if (and if so, how & where) to search a text file in
> specific columns? or search beginning in column X? Are there any existing
> tools to do this? Are there any such 'window'-like facilities?	(like
samples
> I saw in 'widgets') after I installed Perl?
>
> Thanks in advance.
>
> Steve Barbash
>
[snip]

Very 'awk'ward, in my experience. Use awk, if you can. Otherwise,
lots of substr(), and 'for' loops to create hashes of hashes. Probably
wouldn't be nearly so difficult if you don't have "holes" in your data,
like I usually do. eg (from an actual example that I use "in-house"):


while (<>) {

# load the column headers
    if (/   ^CUP\ ACC\ \#           # make sure were on the correct line


            .+?TECH             # anything after ACC # matched non-greedily
                                # up to TECH. That way we can have a test code
                                # of 'TECH' and not break the script.


            \s+                 # white space


        (                       # begin capture of $1 - used anonymously below
                                # to capture all tests listed on the worksheet
            .+                  # one or more of any characters into $1
        )                       # end capture of $1 (the test_list string)


            $                   # capture everything in $1 up to the EOL


            /x) {               # end of extended regex; end of conditional;
                                # beginning of "true" block

# Create a "search index for each column header.
# Each "column" for each test is 6 characters wide

        for ($i; $i<25; $i++) {
            $test_index = 49+$i*6;
            $test = substr $_, $test_index, 6;
            chomp $test;
            $test =~ s/ //g;
            if ($test ne '') {
                $find_test_index{$test_index} = $test;
            }
        }
        $i = 0;

    }

#load rows of data into columns
    if (/(                      # begin 'if' conditional and capture $1 - the
                                # entire line

            ^\s+HOSP\ ID:\      # make sure we're on the correct line; note
                                # the literal space at the end of the match

        (                       # begin capture #2 - the hospital ID
            \S+                 # the hospital ID itself
        )                       # end capture of hospital ID


            \s+                 # white space


        (                       # begin capture of $3 - the tech id number
            \d+                 # the tech id number itself
        )?                      # end capture of tech id number and make it
                                # optional (in case result is 'DEL')



            \s+                 # white space


        (                       # begin capture of $4 - the rest of the line
            \ .+                # the rest of the line itself
        )                       # end capture of the rest of the line


            $                   # make the rest of the line ($4) match to the
                                # end of the line

        )                       # end capture of the whole line ($1)


            /x) {               # end of extended regex; end of conditional,
                                # and beginning of "true" block


        $specimen{$acc_no}{referrer} = $2;
        $specimen{$acc_no}{run_by} = $3;


  for ($i; $i<25; $i++) {  $result_index = 49+$i*6;  $result = substr $_,
$result_index, 6;  chomp $result;  $result =~ s/ //g;  if ($result ne '') { #
we don't want any of the holes 
$specimen{$acc_no}{result}{$find_test_index{$result_index}} = $r esult;

            }
        }
        $i = 0;

    }

}


while (($key,$value) = each %{ $specimen{$id}{result} }  ) {
        print "$key = $value\n";
    }

    print "\n\n\n";
}



I'm actually kicking around attempting some sort of a module to make it
easier to do this type of thing (COLUMNS.pm ?): eg call a function
(or use split in combination with regex and substr() to identify a
specific columnar data format (offset, column width, column headers,
etc), then another function to load data into that format. So what was
accomplished in all that mess above could be done with something like:

use COLUMNS; $matrix1 = new COLUMNS; while (<>) {  if (/(s)o(m)e (r)e(g)ex/)
{  $matrix1->headers($1, $2, $3, $4);  }  if (/another regex, line count,
(row id), etc/) {  $new_row = $matrix1->load_row($1);  &addrow($new_row);  }
} print $matrix1->data(by_row);  # print out data row by row in column=data
pairs print $matrix1->data(by_column) # print any data for the first column,
then  # second, etc


Good Luck!

Patrick Timmins
U. Nebraska Medical Center

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 11 Aug 1998 22:55:55 GMT
From: mnc@diana.law.yale.edu (Miguel Cruz)
Subject: Re: Test your Javascript and HTML knowledge
Message-Id: <6qqi5r$o5o$1@news.ycc.yale.edu>

Tom Phoenix  <rootbeer@teleport.com> wrote:
>> Subject: Test your Javascript and HTML knowledge
>
> This wasn't appropriate for a Perl newsgroup the first time you posted it
> today, albeit under a different Subject line. But, even if it were
> on-topic, that's no reason to post it twice!

And once you see the test (if it's anything like it was when he spammed it a
couple months ago), you won't think it's appropriate for any newsgroup.

miguel


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

Date: 12 Aug 1998 03:01:00 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Windows 95 perl and long-directory names.
Message-Id: <6qr0hc$4v6$3@nswpull.telstra.net>

In article <35CEC224.4CC5CAEE@altair.com>,
	"Peter P. Mikelonis" <mikeloni@altair.com> writes:
> I am having difficulty doing existence checking, (-e), if my string
> contains a path with
> an item greater than 8 characters. Has any one else experienced this and
> is

On Solaris, perl 5.004_04, observe:

# perl -e 'print "got it\n" if -e "/u/mgjv/enlightenment"'
got it

No problem there.

> there a work around. The script was developed on NT and works fine.

Now.. What you are saying doesn't actually make sense. First you say
that your script doesn't work. Then you say it does work. Are you
running this on NT or aren't you? Does it work on NT, but not on
something else? Which version of perl are you using? What sort of
errors, if any, does perl produce? Have you checked to see what $!
contains after it fails? Is this a DOS or win95 box? What is the exact
content of the path you feed to -e?

You really should give a bit more information.

Martien

> Please e-mail me if you can

Nope. Post here, read here.

Martien
-- 
Martien Verbruggen                      |
Webmaster www.tradingpost.com.au        | "In a world without fences,
Commercial Dynamics Pty. Ltd.           |  who needs Gates?"
NSW, Australia                          |


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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