[10305] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3898 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 6 01:07:14 1998

Date: Mon, 5 Oct 98 22:00:26 -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           Mon, 5 Oct 1998     Volume: 8 Number: 3898

Today's topics:
    Re: Data Search Question (Snowhare)
        forms with perl <sgoodyear@genxsys.com>
    Re: Help with mutilple HTML lines <jbharvey@auspex.net>
    Re: How do I generate a GIF <jbharvey@auspex.net>
    Re: How do you use the perl compiler? <joseph@5sigma.com>
    Re: How to make your perl CGI programs multipage <clancytc@rose-hulman.edu>
        Image format conversion, resizing <admin@hatsoft.com>
    Re: Keeping a running list of the top n values retrieve (Mark-Jason Dominus)
    Re: Matching Smallest Instance of a Pattern <psdspss@execpc.com>
    Re: ms access databases <mikei@ix.netcom.com>
        NEEDED: A good perl programer to... (MTNBIKE151)
        newbie trying to parse one file into three <quartz@nospam.idiom.com>
        Page Break in a report <psdspss@execpc.com>
    Re: Page Break in a report <joseph@5sigma.com>
    Re: Page Break. <jbharvey@auspex.net>
    Re: please check my CGI.pm/Perl Syntax (Martien Verbruggen)
    Re: please check my CGI.pm/Perl Syntax (Tad McClellan)
    Re: please check my CGI.pm/Perl Syntax <eugene@vertical.net>
    Re: Reaction Times <jbharvey@auspex.net>
    Re: Reaction Times (Tad McClellan)
    Re: Redirect Question <jbharvey@auspex.net>
    Re: Redirect Question <eugene@vertical.net>
    Re: regular expression <egwong@netcom.com>
    Re: regular expression (Ronald J Kimball)
    Re: regular expression <rick.delaney@shaw.wave.ca>
    Re: regular expression <sford@home.com>
    Re: regular expression (Ronald J Kimball)
    Re: regular expression <jbharvey@auspex.net>
    Re: regular expression (Tad McClellan)
    Re: script: scriptMangle! <Russell_Schulz@locutus.ofB.ORG>
    Re: Too late for "-T" option ? <liz@cookwood.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 6 Oct 1998 04:24:17 GMT
From: snowhare@devilbunnies.org (Snowhare)
Subject: Re: Data Search Question
Message-Id: <6vc61h$rd0$1@nnrp4.snfc21.pbi.net>



Nothing above this line is part of the signed message.

In article <MPG.1082deffc4bd23969897e0@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>[Posted to comp.lang.perl.misc and a copy mailed.]
>
>In article <36192956.269950618@nntp.cts.com> on Mon, 05 Oct 1998 20:29:29 
>GMT, Garrett Casey <nospamno_adms1@cts.com> says...
>> I have 1,000,000 character strings that are 10 random A-Z characters
>> in length. For example:
>> 
>> JSUWIGKROD
>> KIWPLODGQF
>> WOQPLIFJSK
>> OQPALSNEUG
>> ISOPQKEOSP
>> etc... 
>> 
>> A user inputs his own 10 character A-Z string:
>> 
>> UQPALRIEOF
>> 
>> And the program returns the closest match.  The match, though, must be
>> based on PER CHARACTER comparision - not the string as a whole.
>> 
>> For instance,
>> 
>> UQPALRIEOF would match UQPALRIDOF 90% because 9 out of the 10
>> characters are the same.
>> 
>> In your opinion, what is the most efficient data structure I can use
>> to store the 1,000,000 strings, and the most efficient way to search
>> for such a comparison in that data structure?
>
>The best I can do is an array and a linear search.  I'd love to be 
>shown a better way.

Another approach would be to transform the problem. It can
be represented as a ten dimensional array that has an edge of
26 locations on every axis. You are then looking for things with 
certain geometrical properties. By examining only about 250 locations 
in the array you can find all 90% matches. All 80% matches can be 
found by examining around 62K locations.  For storage efficiency, 
store the data as a btree and then access the btree as if it were a 
multidimensional array (essentially, use the btree as a sparse array). 
Then use the geometric properties of the array to 'look for nearby 
stuff'.

Taking what I said above and boiling it down to a spec:

1) Store the data in a btree.

2) Look for an exact match of the search string (100% match)

3) If an exact match wasn't found, take the search string and generate 
   all the variants that differ in only one letter. Look in the btree 
   for exact matches for those variants. (90% match) There are 250 
   variants on the single letter level.

4) If nothing was found, generate all the variants that differ in
   exactly two letters. Look in the btree for those variants. (80% 
   match) There are around 62K variants to be examined on the two 
   letter level.

5) If you haven't found a match yet, do a linear search through the 
   btree because a 70% search this way takes longer than a linear 
   scan through a million items does.

Assuming the filling density for only 1E6 items is sufficient to
make an 80% or better match at all likely (it probably isn't -
I estimate that there is only about 1 chance in 2 billion of
an 80% match for only a million 10 letter strings) it will be faster 
than a straight linear search. The performance cross-over happens
around 1.6 million records when 70% searches become less time
consuming than linear searches. You immediately move into the
realm of a statistical performance improvement that gets better
the more records to be searched until it reaches something on
the order of 1E-14K x # of records (linear but with a miniscule
constant caused by the number of records needing to be returned).

So, in summary: For < 1.6E6 10 letter records, use a linear search.
                For > 1.6E6 10 letter records, use a geometric search.

Benjamin Franz


Version: 2.6.2

iQCVAwUBNhmcoujpikN3V52xAQFFmAQAmBJvfNNmGJMhwyWo5e53F4IaekSrP0C6
Zn2dK/FR++D2pMPA775+c0j7UbrMc1lSvP5SQ98ADtQjZpNK2IsOF8l6Ev9qxUiF
ui5YEXcOH8lsbx/nYSFtRhqEEJP4+PBY9DqFRhvucpuuuVGwXBQ5IO74uhMtvlxD
GU/bPzQvdkg=
=dxB6
-----END PGP SIGNATURE-----


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

Date: Mon, 05 Oct 1998 07:28:42 -0400
From: Steve Goodyear <sgoodyear@genxsys.com>
Subject: forms with perl
Message-Id: <3618AD6A.42D2F98D@genxsys.com>

Essentially I need to replace a standard HTML form using the POST method
with a perl script...

I'm not real sure where to start....






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

Date: Tue, 06 Oct 1998 03:42:40 GMT
From: Justin Harvey <jbharvey@auspex.net>
Subject: Re: Help with mutilple HTML lines
Message-Id: <361991A2.78BA077D@auspex.net>

Check into setting $/ to something.  Here is a paste from the manpage
perlvar, it may or may not be your answer.  

> $/
> 
>      The input record separator, newline by default. Works like awk's RS variable, including treating
>      empty lines as delimiters if set to the null string. (Note: An empty line cannot contain any spaces or
>      tabs.) You may set it to a multi-character string to match a multi-character delimiter, or to undef to
>      read to end of file. Note that setting it to "\n\n" means something slightly different than setting it
>      to "", if the file contains consecutive empty lines. Setting it to "" will treat two or more
>      consecutive empty lines as a single empty line. Setting it to "\n\n" will blindly assume that the
>      next input character belongs to the next paragraph, even if it's a newline. (Mnemonic: / is used to
>      delimit line boundaries when quoting poetry.) 
> 
>          undef $/;
>          $_ = <FH>;          # whole file now here
>          s/\n[ \t]+/ /g;
> 
>      Remember: the value of $/ is a string, not a regexp. AWK has to be better for something :-) 
> 
>      Setting $/ to a reference to an integer, scalar containing an integer, or scalar that's convertable to
>      an integer will attempt to read records instead of lines, with the maximum record size being the
>      referenced integer. So this: 
> 
>          $/ = \32768; # or \"32768", or \$var_containing_32768
>          open(FILE, $myfile);
>          $_ = <FILE>;
> 
>      will read a record of no more than 32768 bytes from FILE. If you're not reading from a
>      record-oriented file (or your OS doesn't have record-oriented files), then you'll likely get a full
>      chunk of data with every read. If a record is larger than the record size you've set, you'll get the
>      record back in pieces. 
> 
>      On VMS, record reads are done with the equivalent of sysread, so it's best not to mix record and
>      non-record reads on the same file. (This is likely not a problem, as any file you'd want to read in
>      record mode is proably usable in line mode) Non-VMS systems perform normal I/O, so it's safe to
>      mix record and non-record reads of a file. 


Gala Grant wrote:
> 
> I am trying to write a perl program that among other things searchs an HTML
> file for a text match.  The problem I am having is that what HTML and perl
> think is a line is different.  So what I am searching for spreads over 2
> lines in HTML, so when I do
>         if ($line = /$match/)
> it won't match.  I tried removing theline delimiter, but that created a
> whole new buch of problems.  If anyone can help it would be greatly
> appreciated.
> Gala Grant
> gala@sonic.net

--
Justin B. Harvey			http://www.auspex.net/jbharvey
jbharvey@auspex.net			Mountain View, CA

		   use Perl || die "trying";


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

Date: Tue, 06 Oct 1998 03:22:26 GMT
From: Justin Harvey <jbharvey@auspex.net>
Subject: Re: How do I generate a GIF
Message-Id: <36198CE4.8DDBA46@auspex.net>

Try the GD library, find it at CPAN
ftp://ftp.digital.com/pub/plan/perl/CPAN/modules/by-module/GD/

A snippet from the readme:
> GD.pm A perl5 interface to Thomas Boutell's gd library.
> 
> ABSTRACT:
> 
> This is a autoloadable interface module for libgd, a popular library
> for creating and manipulating GIF files.  With this library you can
> create GIF images on the fly or modify existing files.  Features
> include:
> 
> a.  lines, polygons, rectangles and arcs, both filled and unfilled
> b.  flood fills
> c.  the use of arbitrary images as brushes and as tiled fill patterns
> d.  line styling (dashed lines and the like)
> e.  horizontal and vertical text rendering
> f.  support for transparency and interlacing
> 
> For full information on usage, see the accompanying man and html
> documentation.

Reiner wrote:
> 
> I want to generate a GIF from a table of data (not a graph). I have
> looked at Jeffrey Friedl's gif.pl and it does what I want except not in
> color and I don't have the perl skills (yet) or GIF format information
> to modify it to allow x colors. Something like gd.pm might do what I
> want but it is too excessive. I just want to write a string of pixels,
> no fancy drawing or anything.
> 
> Any help/sourc/url appreciated.
> 
> -Reiner

--
Justin B. Harvey			http://www.auspex.net/jbharvey
jbharvey@auspex.net			Mountain View, CA

		   use Perl || die "trying";


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

Date: Mon, 05 Oct 1998 21:45:30 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: How do you use the perl compiler?
Message-Id: <3619A046.676D8BAC@5sigma.com>

Last time I checked on my Unix box, perlcc is broken if your PATH
environment variable doesn't point to the right places.  Even
though you're on a different platform, you might take a look at that.

	-joseph

Chris Anderson wrote:
> 
> I have the ActiveState Perl v5.00.502 on Windows 95 (I've also tried on
> NT 4.0) and I can't get the compiler to work. All the documentation I've
> seen makes it sound pretty idiot proof- just type "perlcc a.pl" and
> you'll get an executable. So, I guess I'm an idiot because it's not
> working. The perl syntax checks out OK, and it creates the code but
> chokes on compiling with the message "Couldn't open !"- it's missing a
> filename in the error message.
> It seems like there must be some setup required (and I'm guessing that's
> what I'm missing), but I haven't seen any documentation on that.
> Any help would be appreciated

--
Joseph N. Hall, prop., 5 Sigma Productions       mailto:joseph@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com
Perl Training  . . . . . . . . . . . . . . .  http://www.perltraining.com


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

Date: Mon, 5 Oct 1998 22:57:46 -0500
From: "Charles Clancy" <clancytc@rose-hulman.edu>
Subject: Re: How to make your perl CGI programs multipage
Message-Id: <6vc4fh$pr4$1@solomon.cs.rose-hulman.edu>

This is a multi-part message in MIME format.

------=_NextPart_000_008F_01BDF0B3.915B8BB0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

The easiest way is do to have two .pl files.  The first one generates a =
form that calls the second.  Here's some code fragments:

----HTML Page that calls the first script-----
<html>
<form action=3D/cgi-bin/script1.pl method=3Dpost>
<input type=3Dtext name=3Dtxt1>
<input type=3Dtext name=3Dtxt2>
<input type=3Dsubmit value=3DGo>
</form></html>
---------- script1.pl --------------
#!/usr/local/bin/perl
# Parse your input
$pass=3D"123";  # Variable to be passed to second script
print "Content: text/html\n\n";
print "<html><form action=3D/cgi-bin/script2.pl method=3Dpost>\n";
print "Your first text was: $Incoming{'txt1'}, and the second was: =
$Incoming{'txt2'}\n";
print "<br><input type=3Dtext name=3Dtxt3>\n";
print "<input type=3Dsubmit value=3DGo>\n";
print "<input type=3Dhidden name=3Dpass value=3D$pass>\n";
print "</form></html>\n";
---------- script2.pl --------------
#!/usr/local/bin/perl
# Parse your input
print "Content: text/html\n\n";
print "<html>\n";
print "Your third text was: $Incoming{'txt3'}, and pass equals: =
$Incoming{'pass'}\n";
print "</html>\n";
----------------------------------------

I hope that helps.  I have an implementation of a similar setup at =
http://despina.advanced.org/17531/test.html
if you want to take a look at it.
_______________________________________
Charles Clancy, clancytc@rose-hulman.edu
Computer Science Department Manager
Rose-Hulman Institute of Technology

    Anthony Smith wrote in message <6uunqd$9np$1@blue.hex.net>...
    Heres my question, all the previous programs I have made have been =
all contained on a single html page that never went anywhere except to =
html documents.  How can I link to another part of the script that I =
have stored in a variable using either an html link or a button.  Does =
it require a subroutine or what?
    Heres a litte bit of my code so you know what im talking about:
   =20
    ##############

    #   Page A   #

    ##############

    print "

    <html><head><title>$title</title></head>

    <body bgcolor=3D\"$bgcolor\" text=3D\"$textcolor\" =
link=3D\"$linkcolor\" vlink=3D\"$vlinkcolor\" alink=3D\"$alinkcolor\">

    <font face=3D\"$font\"><center><h1>$title</h1></center><p>

    $startuppage

    <center><h1></h1></center>

    $cpyrtfoot

    </body></html>\n";

    ###########

    # Page B  #

    ###########

    $gamepage =3D "

    <html><head><title>$title</title></head>

    <body bgcolor=3D\"$bgcolor\" text=3D\"$textcolor\" =
link=3D\"$linkcolor\" vlink=3D\"$vlinkcolor\" alink=3D\"$alinkcolor\">

    <font face=3D\"$font\"><center><h1>$title</h1></center><p><img =
src=3D\"$basedir/$card1\">

    $cpyrtfoot

    </body></html>\n";

    Basically all I want to do is to make part A link to part B somehow.
   =20
    Feel free to help me, even if it means critisizm :)
   =20
    Anthony Smith

------=_NextPart_000_008F_01BDF0B3.915B8BB0
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><!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 =
HTML//EN">
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2>The easiest way is do to have two =
 .pl=20
files.&nbsp; The first one generates a form that calls the second.&nbsp; =
Here's=20
some code fragments:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>----HTML Page that calls the first =
script-----</FONT></DIV>
<DIV><FONT size=3D2>&lt;html&gt;</FONT></DIV>
<DIV><FONT size=3D2>&lt;form action=3D/cgi-bin/script1.pl=20
method=3Dpost&gt;</FONT></DIV>
<DIV><FONT size=3D2>&lt;input type=3Dtext name=3Dtxt1&gt;</FONT></DIV>
<DIV><FONT size=3D2>&lt;input type=3Dtext name=3Dtxt2&gt;</FONT></DIV>
<DIV><FONT size=3D2>&lt;input type=3Dsubmit value=3DGo&gt;</FONT></DIV>
<DIV><FONT size=3D2>&lt;/form&gt;&lt;/html&gt;</FONT></DIV>
<DIV><FONT size=3D2>---------- script1.pl --------------</FONT></DIV>
<DIV><FONT size=3D2>#!/usr/local/bin/perl</FONT></DIV>
<DIV><FONT size=3D2># Parse your input</FONT></DIV>
<DIV><FONT size=3D2>$pass=3D&quot;123&quot;;&nbsp; # Variable to be =
passed to second=20
script</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>print &quot;Content:=20
text/html\n\n&quot;;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>print &quot;&lt;html&gt;&lt;form=20
action=3D/cgi-bin/script2.pl method=3Dpost&gt;\n&quot;;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT><FONT size=3D2>print =
&quot;Your first text=20
was: $Incoming{'txt1'}, and the second was:=20
$Incoming{'txt2'}\n&quot;;</FONT></DIV>
<DIV><FONT size=3D2></FONT><FONT color=3D#000000 size=3D2>print=20
&quot;&lt;br&gt;&lt;input type=3Dtext =
name=3Dtxt3&gt;\n&quot;;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT><FONT size=3D2>print =
&quot;&lt;input=20
type=3Dsubmit value=3DGo&gt;\n&quot;;</FONT></DIV>
<DIV><FONT size=3D2>print &quot;&lt;input type=3Dhidden name=3Dpass=20
value=3D$pass&gt;\n&quot;;</FONT></DIV>
<DIV><FONT size=3D2>print =
&quot;&lt;/form&gt;&lt;/html&gt;\n&quot;;</FONT></DIV>
<DIV><FONT size=3D2></FONT>
<DIV><FONT size=3D2>---------- script2.pl --------------</FONT></DIV>
<DIV><FONT size=3D2>#!/usr/local/bin/perl</FONT></DIV>
<DIV><FONT size=3D2># Parse your input</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>print &quot;Content:=20
text/html\n\n&quot;;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>print =
&quot;&lt;html&gt;\n&quot;;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT><FONT size=3D2>print =
&quot;Your third text=20
was: $Incoming{'txt3'}, and pass equals: =
$Incoming{'pass'}\n&quot;;</FONT></DIV>
<DIV><FONT size=3D2>print &quot;&lt;/html&gt;\n&quot;;</FONT></DIV>
<DIV><FONT =
size=3D2>----------------------------------------</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I hope that helps.&nbsp; I have an implementation of =
a similar=20
setup at <A=20
href=3D"http://despina.advanced.org/17531/test.html">http://despina.advan=
ced.org/17531/test.html</A></FONT></DIV>
<DIV><FONT size=3D2></FONT><FONT color=3D#000000 size=3D2>if you want to =
take a look=20
at it.</FONT></DIV>
<DIV>
<DIV><FONT color=3D#000000=20
size=3D2>_______________________________________<BR>Charles Clancy, <A=20
href=3D"mailto:clancytc@rose-hulman.edu">clancytc@rose-hulman.edu</A><BR>=
Computer=20
Science Department Manager<BR>Rose-Hulman Institute of=20
Technology</FONT></DIV></DIV></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 solid 2px; MARGIN-LEFT: 5px; PADDING-LEFT: =
5px">
    <DIV>Anthony Smith<ANTY_84@YAHOO.COM> wrote in message &lt;<A=20
    =
href=3D"mailto:6uunqd$9np$1@blue.hex.net">6uunqd$9np$1@blue.hex.net</A>&g=
t;...</DIV>
    <DIV>Heres my question, all the previous programs I have made have =
been all=20
    contained on a single html page that never went anywhere except to =
html=20
    documents.&nbsp; How can I link to another part of the script that I =
have=20
    stored in a variable using either an html link or a button.&nbsp; =
Does it=20
    require a subroutine or what?</DIV>
    <DIV>Heres a litte bit of my code so you know what im talking =
about:</DIV>
    <DIV>&nbsp;</DIV><FONT color=3D#000000 face=3D"Lucida Console" =
size=3D1>
    <P><FONT face=3D"Courier New"><FONT =
size=3D2>##############</FONT></FONT><FONT=20
    size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT size=3D2>#&nbsp;&nbsp; Page =
A&nbsp;&nbsp;=20
    #</FONT></FONT><FONT size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT =
size=3D2>##############</FONT></FONT><FONT=20
    size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT size=3D2>print =
&quot;</FONT></FONT><FONT=20
    size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT =
size=3D2>&lt;html&gt;</FONT></FONT><FONT=20
    face=3D"Courier New"><FONT=20
    =
size=3D2>&lt;head&gt;&lt;title&gt;$title&lt;/title&gt;&lt;/head&gt;</FONT=
></FONT><FONT=20
    size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT size=3D2>&lt;body=20
    bgcolor=3D\&quot;$bgcolor\&quot; text=3D\&quot;$textcolor\&quot;=20
    link=3D\&quot;$linkcolor\&quot; vlink=3D\&quot;$vlinkcolor\&quot;=20
    alink=3D\&quot;$alinkcolor\&quot;&gt;</FONT></FONT><FONT =
size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT size=3D2>&lt;font=20
    face=3D\&quot;$font\&quot;&gt;</FONT></FONT><FONT face=3D"Courier =
New"><FONT=20
    =
size=3D2>&lt;center&gt;&lt;h1&gt;$title&lt;/h1&gt;&lt;/center&gt;&lt;p&gt=
;</FONT></FONT><FONT=20
    size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT =
size=3D2>$startuppage</FONT></FONT><FONT=20
    size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT=20
    size=3D2>&lt;center&gt;&lt;h1&gt;</FONT></FONT></FONT><FONT =
color=3D#000000=20
    face=3D"Lucida Console" size=3D1><FONT face=3D"Courier New"><FONT=20
    size=3D2>&lt;/h1&gt;&lt;/center&gt;</FONT></FONT><FONT =
size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT =
size=3D2>$cpyrtfoot</FONT></FONT><FONT=20
    size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT =
size=3D2>&lt;/body&gt;</FONT></FONT><FONT=20
    face=3D"Courier New"><FONT =
size=3D2>&lt;/html&gt;\n&quot;;</FONT></FONT><FONT=20
    size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT =
size=3D2>###########</FONT></FONT><FONT=20
    size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT size=3D2># Page B&nbsp; =
#</FONT></FONT><FONT=20
    size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT =
size=3D2>###########</FONT></FONT><FONT=20
    size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT size=3D2>$gamepage =3D=20
    &quot;</FONT></FONT><FONT size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT =
size=3D2>&lt;html&gt;</FONT></FONT><FONT=20
    face=3D"Courier New"><FONT=20
    =
size=3D2>&lt;head&gt;&lt;title&gt;$title&lt;/title&gt;&lt;/head&gt;</FONT=
></FONT><FONT=20
    size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT size=3D2>&lt;body=20
    bgcolor=3D\&quot;$bgcolor\&quot; text=3D\&quot;$textcolor\&quot;=20
    link=3D\&quot;$linkcolor\&quot; vlink=3D\&quot;$vlinkcolor\&quot;=20
    alink=3D\&quot;$alinkcolor\&quot;&gt;</FONT></FONT></P>
    <P><FONT face=3D"Courier New"><FONT size=3D2></FONT></FONT><FONT=20
    face=3D"Courier New"><FONT size=3D2>&lt;font=20
    face=3D\&quot;$font\&quot;&gt;</FONT></FONT><FONT face=3D"Courier =
New"><FONT=20
    =
size=3D2>&lt;center&gt;&lt;h1&gt;$title&lt;/h1&gt;&lt;/center&gt;&lt;p&gt=
;</FONT></FONT><FONT=20
    face=3D"Courier New"><FONT size=3D2>&lt;img=20
    src=3D\&quot;$basedir/$card1\&quot;&gt;</FONT></FONT><FONT =
size=3D2></FONT></P>
    <P><FONT face=3D"Courier New"><FONT =
size=3D2>$cpyrtfoot</FONT></FONT></P>
    <P><FONT face=3D"Courier New"><FONT size=3D2></FONT></FONT><FONT=20
    face=3D"Courier New"><FONT size=3D2>&lt;/body&gt;</FONT></FONT><FONT =

    face=3D"Courier New"><FONT =
size=3D2>&lt;/html&gt;\n&quot;;</FONT></FONT><FONT=20
    size=3D2></FONT></P></FONT>
    <DIV>Basically all I want to do is to make part A link to part B=20
    somehow.</DIV>
    <DIV>&nbsp;</DIV>
    <DIV>Feel free to help me, even if it means critisizm :)</DIV>
    <DIV>&nbsp;</DIV>
    <DIV>Anthony Smith</DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_008F_01BDF0B3.915B8BB0--



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

Date: Mon, 5 Oct 1998 21:12:01 -0700
From: "Henry Wolff" <admin@hatsoft.com>
Subject: Image format conversion, resizing
Message-Id: <3619982b.0@news.greatbasin.net>

Does anyone know of a perl 5 routine/module that will for instance, take a
gif file and convert it to jpeg and viseversa, or one that will resize both
or one format?  (The image will be a local)

If not, does someone want to earn some money writing such?

Since there are so many posts on this newsgroup, could you please email me
at admin@hatsoft.com

thanks,
Henry Wolff
Send Some Virtual Postcards - FREE
http://www.hatsoft.com/webcard/index.html




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

Date: 6 Oct 1998 00:04:21 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Keeping a running list of the top n values retrieved
Message-Id: <6vc4s5$3dh$1@monet.op.net>

In article <1dgef8x.nm3n0zv9tqbaN@bay1-358.quincy.ziplink.net>,
Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
>A quick hack:

My hack is funnier, and is likely to be be more efficient.

	sub insert {
	  my $t=[9,[4,[2,[0,0,1],[3,[2,2,3],4]],
		    [7,[5,5,6],[8,[7,7,8],9]]],
		 [14,[12,[10,10,11],[13,[12,12,13],14]],
		  [17,[15,15,16],[18,[17,17,18],[19,19,20]]]]];
	  my($n,$a) = @_;
	  $t = $t->[$n>$a->[$t->[0]]?1:2] while ref $t;  # LOD
	  splice(@$a, $t, 0, $n);
	  pop @$a;
	}

If $r is a number, and @q is a array with 20 numbers in decreasing
order, then

	insert($r, \@q) 

inserts $r into the appropriate position of @q, removes the smallest
element from @q, and returns it.

Here's a harness:

	@q = (0) x 20;  # Initialize @q to contain 20 items in decreasing order
	for $i (1..25) {
	  my $r = int(100*rand());
	  my $l = insert($r, \@q);
	  print "$r replaces $l: @q\n";
	}
	
Sample output:

5 replaces 0: 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
12 replaces 0: 12 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
39 replaces 0: 39 12 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
28 replaces 0: 39 28 12 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
60 replaces 0: 60 39 28 12 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
61 replaces 0: 61 60 39 28 12 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0
19 replaces 0: 61 60 39 28 19 12 5 0 0 0 0 0 0 0 0 0 0 0 0 0
12 replaces 0: 61 60 39 28 19 12 12 5 0 0 0 0 0 0 0 0 0 0 0 0
31 replaces 0: 61 60 39 31 28 19 12 12 5 0 0 0 0 0 0 0 0 0 0 0
17 replaces 0: 61 60 39 31 28 19 17 12 12 5 0 0 0 0 0 0 0 0 0 0
37 replaces 0: 61 60 39 37 31 28 19 17 12 12 5 0 0 0 0 0 0 0 0 0
12 replaces 0: 61 60 39 37 31 28 19 17 12 12 12 5 0 0 0 0 0 0 0 0
25 replaces 0: 61 60 39 37 31 28 25 19 17 12 12 12 5 0 0 0 0 0 0 0
64 replaces 0: 64 61 60 39 37 31 28 25 19 17 12 12 12 5 0 0 0 0 0 0
70 replaces 0: 70 64 61 60 39 37 31 28 25 19 17 12 12 12 5 0 0 0 0 0
71 replaces 0: 71 70 64 61 60 39 37 31 28 25 19 17 12 12 12 5 0 0 0 0
59 replaces 0: 71 70 64 61 60 59 39 37 31 28 25 19 17 12 12 12 5 0 0 0
28 replaces 0: 71 70 64 61 60 59 39 37 31 28 28 25 19 17 12 12 12 5 0 0
80 replaces 0: 80 71 70 64 61 60 59 39 37 31 28 28 25 19 17 12 12 12 5 0
54 replaces 0: 80 71 70 64 61 60 54 59 39 37 31 28 28 25 19 17 12 12 12 5
99 replaces 5: 99 80 71 70 64 61 60 54 59 39 37 31 28 28 25 19 17 12 12 12
64 replaces 12: 99 80 71 70 64 64 61 60 54 59 39 37 31 28 28 25 19 17 12 12
7 replaces 7: 99 80 71 70 64 64 61 60 54 59 39 37 31 28 28 25 19 17 12 12
42 replaces 12: 99 80 71 70 64 64 61 60 54 59 42 39 37 31 28 28 25 19 17 12
69 replaces 12: 99 80 71 70 69 64 64 61 60 54 59 42 39 37 31 28 28 25 19 17

The main loop in your version runs 10 times per insertion, on average.
My main loop only runs about 4 times per insertion.

The best thing about this program is that it might be instructive.

:)






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

Date: Mon, 05 Oct 1998 22:15:45 -0500
From: Deva Seetharam <psdspss@execpc.com>
Subject: Re: Matching Smallest Instance of a Pattern
Message-Id: <6vc1cj$rqp@newsops.execpc.com>

I made a typo in my previous message. The Regex should be

Since the pattern matching operators are greedy, they try to match as
much
as possible. So mark the string that needs to be replaced.

Try this
$str =~ s(graphics/(.)+.gif) (graphics/abc.gif)i;
Here graphics serves a marker and parenthesis is used as a delimiter.

Hope this helps.
Deva

Jim McAtee wrote:

> How do I match the smallest instance of a pattern?  I'm trying to
> replace a filename within an html image tag as follows.  The pattern
> I've tried below matches from the first '/' through the end of the
> '.gif' file extension.
>
> $_ = '<a href="/alpha/beta/gamma.htm"><img src="/graphics/xyz.gif"
> width=110 height=29></a>'
>
> s|/.*?\.gif|/abc.gif|;
>
> Thanks,
> Jim





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

Date: Mon, 05 Oct 1998 23:34:27 -0400
From: Lyubov Ignatovsky <mikei@ix.netcom.com>
Subject: Re: ms access databases
Message-Id: <36198FC3.ECA72F04@ix.netcom.com>

Check out Win32::ODBC.

Klaus Reiger wrote:

> does anyone have experiences with perl and ms access databases ?
> thank you for answering.
>
> Klaus.Reiger@tic-tac-toe.com





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

Date: 6 Oct 1998 04:18:12 GMT
From: mtnbike151@aol.com (MTNBIKE151)
Subject: NEEDED: A good perl programer to...
Message-Id: <19981006001812.17212.00003895@ng32.aol.com>


Hello,

I am in need of a good perl/cgi programmer to write a script to search a
flat-file database containing 4 fields (2 of which need to be searchable i.e.
Part No. & Description Of Part... and the other 2 fields are Prices) 

Requirements:
1. Limit the search to 25 listings
2. Bring the Most Relevant Listings at the top of the search results.
3. No "Wildcarding" the search i.e. (type in a "Space" at the description field
and bring up all records containing a "Space" in their description)

Please E-mail
webmaster@rubenssewingmachine.com
or my personal e-mail: Mtnbike151@aol.com


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

Date: Mon, 5 Oct 1998 21:34:23 -0700
From: "Larry Quantz" <quartz@nospam.idiom.com>
Subject: newbie trying to parse one file into three
Message-Id: <6vc6h4$f90$1@news.idiom.com>



    I've got a text file with various records in it.  Each record is on an
individual line, and each record is comma delimited.

    I need to take this file, and put (let's say) fields one, four and seven
of each record into a file.  Likewise, I need to put fields two and five
into another file, while fields three and six go into a third file.

    I've got a rough idea on what to do, but what Perl statements/code will
best allow me to do so?  I'd like to have a solid footing to go on before I
start.  Thanks for any and all help.




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

Date: Mon, 05 Oct 1998 23:25:26 -0500
From: Deva Seetharam <psdspss@execpc.com>
Subject: Page Break in a report
Message-Id: <6vc5f8$rqp@newsops.execpc.com>

I need to produce a report using Perl.

In the header portion of the report, there is a variable
information(Dept No).
Whenever the Dept No changes, a page break(new page) should be induced.

How to do this ?

Deva






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

Date: Mon, 05 Oct 1998 21:42:58 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Page Break in a report
Message-Id: <36199FAF.F5EBF901@5sigma.com>

A page break is a "form feed" character in most environments.

  print "Here is a form feed:\n\f";
  print "This is a new page.\n";

	-joseph

Deva Seetharam wrote:
> 
> I need to produce a report using Perl.
> 
> In the header portion of the report, there is a variable
> information(Dept No).
> Whenever the Dept No changes, a page break(new page) should be induced.
> 
> How to do this ?s


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

Date: Tue, 06 Oct 1998 03:30:53 GMT
From: Justin Harvey <jbharvey@auspex.net>
Subject: Re: Page Break.
Message-Id: <36198EDF.1F5456C4@auspex.net>

Perhaps one of the easiest work arounds would be to do a seperate report
for each dept.

Deva Seetharam wrote:
> 
> I need to produce a report using Perl.
> 
> In the header portion of the report, there is a variable
> information(Dept No).
> Whenever the Dept No changes, a page break(new page) should be induced.
> 
> How to do this ?
> 
> Deva

--
Justin B. Harvey			http://www.auspex.net/jbharvey
jbharvey@auspex.net			Mountain View, CA

		   use Perl || die "trying";


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

Date: Tue, 06 Oct 1998 03:34:42 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: please check my CGI.pm/Perl Syntax
Message-Id: <mdgS1.47$tR1.242397@nsw.nnrp.telstra.net>

In article <36198EBA.247CE507@mkt2mkt.com>,
	madame philosophe <mp@mkt2mkt.com> writes:
> Is this syntax correct?

Did you know that Perl comes with a syntax checker, called perl? Just put it in a script, say "test.script", type

# perl -cw test.script

and see what it produces.

Suggested literature:

# perldoc perlrun

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | 
Commercial Dynamics Pty. Ltd.       | Curiouser and curiouser, said Alice.
NSW, Australia                      | 


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

Date: Mon, 5 Oct 1998 21:59:18 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: please check my CGI.pm/Perl Syntax
Message-Id: <621cv6.8sj.ln@flash.net>

madame philosophe (mp@mkt2mkt.com) wrote:

: Is this syntax correct?


   No it isn't.


: Thanks in advance!


   You're welcome.


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


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

Date: Tue, 06 Oct 1998 00:13:01 -0500
From: Eugene Sotirescu <eugene@vertical.net>
Subject: Re: please check my CGI.pm/Perl Syntax
Message-Id: <3619A6C6.12F7C161@vertical.net>

 sysopen(LOG, "$activity_path", O_WRONLY|O_APPEND, 0660) ||
log_error('LOGTRACK_ERR',$spy_entry);

 flock(LOG, LOCK_EX);

 $spy_entry->save($log_row);  #here you mean save->(LOG), no? (save only
writes to filehandle)

 close LOG;

 flock(LOG, LOCK_UN);  #this is unnecessary: you've already unlocked the
file when you closed it



madame philosophe wrote:

> Is this syntax correct?
>
> Thanks in advance!
>
> mp
> --------
>
> sub spy {
>
>  local $q = shift;
>  local $activity_path;
>
>  my $spy_entry = new CGI($q);
>  my(@spy_set, $stuff, $log_row);
>
>  foreach ($spy_entry->param() =~
> /^(person|action|contribution|email|date)$/) {
>
>   push(@spy_set, map{ $stuff = $spy_entry->param($_) });
>
>    $log_row = join( ' ][ ', @spy_set);
>
>   }
>
>  sysopen(LOG, "$activity_path", O_WRONLY|O_APPEND, 0660) ||
> log_error('LOGTRACK_ERR',$spy_entry);
>
>  flock(LOG, LOCK_EX);
>
>  $spy_entry->save($log_row);
>
>  close LOG;
>
>  flock(LOG, LOCK_UN);
>
> }#end of spy()





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

Date: Tue, 06 Oct 1998 03:25:23 GMT
From: Justin Harvey <jbharvey@auspex.net>
Subject: Re: Reaction Times
Message-Id: <36198D96.10FC3AB2@auspex.net>

I could be wrong on this, but I believe you could use select, here is a
pasted example from the man of perlfunc.

> You can effect a sleep of 250 milliseconds this way: 
> 
>     select(undef, undef, undef, 0.25);

Your mileage may vary.

j

"K. Finstad" wrote:
> 
> Hi,
> I'm relatively new to Perl, and was wondering if there is anything built
> in (or available as a module) that will let Perl record responses from the
> keyboard or mouse with millisecond resolution.  Any help is appreciated.
> 
> -Kraig Finstad

--
Justin B. Harvey			http://www.auspex.net/jbharvey
jbharvey@auspex.net			Mountain View, CA

		   use Perl || die "trying";


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

Date: Mon, 5 Oct 1998 21:57:35 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Reaction Times
Message-Id: <vu0cv6.8sj.ln@flash.net>

K. Finstad (kfinstad@unm.edu) wrote:

: I'm relatively new to Perl, 

   Welcome!

   That really isn't an excuse for asking a FAQ yet again though...


: and was wondering if there is anything built
: in (or available as a module) that will let Perl record responses from the
: keyboard or mouse with millisecond resolution.  Any help is appreciated.


   Perl FAQ, part 8:

      "How can I measure time under a second?"


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


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

Date: Tue, 06 Oct 1998 03:38:12 GMT
From: Justin Harvey <jbharvey@auspex.net>
Subject: Re: Redirect Question
Message-Id: <36199096.AAEB5F79@auspex.net>

# FH is where it's going
open STDOUT, ">&FH";

Dov wrote:
> 
> Greetings,
> 
> Looking for an answer to the following problem:
> 
> How to redirect STDOUT to a memory buffer so that all print and other
> outputs normally going to STDOUT will be diverted to this buffer (or, is
> there a way to set STDOUT buffer to an internal new buffer).
> 
> What is the right Syntax for solving the above?
> 
> Thanks,
> 
> Yonatan.

--
Justin B. Harvey			http://www.auspex.net/jbharvey
jbharvey@auspex.net			Mountain View, CA

		   use Perl || die "trying";


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

Date: Tue, 06 Oct 1998 00:37:20 -0500
From: Eugene Sotirescu <eugene@vertical.net>
To: Dov <dov1@drive.net>
Subject: Re: Redirect Question
Message-Id: <3619AC78.A34D7E0F@vertical.net>

Dov,

STDOUT is normally buffered in Perl (as with any filehandle, there is an
exception when it's connected to the terminal: then it's autoflushed).
If the default buffer is too small for your needs, you can customize it
using  the setvbuf method provided by the IO::Handle module.

Would maybe be able to help better if I knew more details about the exact
problem you want to solve.

Dov wrote:

> Greetings,
>
> Looking for an answer to the following problem:
>
> How to redirect STDOUT to a memory buffer so that all print and other
> outputs normally going to STDOUT will be diverted to this buffer (or, is
> there a way to set STDOUT buffer to an internal new buffer).
>
> What is the right Syntax for solving the above?
>
> Thanks,
>
> Yonatan.





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

Date: Tue, 6 Oct 1998 03:08:29 GMT
From: Eric Wong <egwong@netcom.com>
Subject: Re: regular expression
Message-Id: <egwongF0Dy25.BGv@netcom.com>

Steven Ford <sford@home.com> wrote:
: shouldn't this regx work?

: if (@achFiles =~ /$file/){
:  Do something....}

I don't think it ought to work that way.  According to the
perlop manpage

  Binary "=~" binds a scalar expression to a pattern match.

and, of course, @achFiles is no scalar expression.

You might try grep() (it's in the perlfunc manpage).

Eric
[cc'd]


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

Date: Mon, 5 Oct 1998 23:09:02 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: regular expression
Message-Id: <1dgg85r.12e7ly0h3n0kN@bay2-204.quincy.ziplink.net>

Steven Ford <sford@home.com> wrote:

> shouldn't this regx work?
> 
> if (@achFiles =~ /$file/){
>  Do something....}

Yes, the regex should work, but not when applied to an array.  An array
in scalar context evaluates to the number of elements in the array.

> I want to check and see if a file is in a list of valid filenames.

> Well, it didn't work for me, any suggestions?

Read the FAQ.

(Specifically perlfaq4.)

-- 
 _ / '  _      /         - aka -         rjk@coos.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: Tue, 06 Oct 1998 03:13:52 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: regular expression
Message-Id: <36198C7B.40DE9791@shaw.wave.ca>

[posted & mailed]

Steven Ford wrote:
> 
> shouldn't this regx work?
> 
> if (@achFiles =~ /$file/){

The =~ operator binds a *scalar* to a pattern, not an array.  Like

    $achFiles =~ /$file/

>  Do something....}
> 
> I want to check and see if a file is in a list of valid filenames. 
> This is how I initialized @achFiles:
> 
> @achFiles = (
>         "filename1.ach",
>         "filename2.ach",
>         "filename3.ach",
>         "filename4.ach");
> 
> Well, it didn't work for me, any suggestions?

Please invoke your script as perl -w.  This will give you very useful
warnings like

    Applying pattern match to @array will act on scalar(@array)

It will also allow you to give better descriptions of your problem than
"didn't work".  

perldoc perlrun
perldoc perldiag

If you want to check a pattern against an array, you can use grep.

    @matches = grep /$file/o => @achFiles;

This is kind of wasteful if you are only going to get one match since
grep will check each element of @achFiles.  

If you want to search a set of unique elements then you are better off
defining the set as a hash.

    %achFiles = (
        filename1.ach => 1,
        filename2.ach => 1,
        filename3.ach => 1,
        filename4.ach => 1,
    );

    if (exists $achFiles{$file} ) {

or just

    if ($achFiles{$file}) { # when values are all true

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Tue, 06 Oct 1998 03:24:01 GMT
From: Steven Ford <sford@home.com>
Subject: Re: regular expression
Message-Id: <36198D4B.75DCE3C1@home.com>

Thanks, I made a hash. Should have done that in the fisrt place.

Rick Delaney wrote:
> 
> [posted & mailed]
> 
> Steven Ford wrote:
> >
> > shouldn't this regx work?
> >
> > if (@achFiles =~ /$file/){
> 
> The =~ operator binds a *scalar* to a pattern, not an array.  Like
> 
>     $achFiles =~ /$file/
> 
> >  Do something....}
> >
> > I want to check and see if a file is in a list of valid filenames.
> > This is how I initialized @achFiles:
> >
> > @achFiles = (
> >         "filename1.ach",
> >         "filename2.ach",
> >         "filename3.ach",
> >         "filename4.ach");
> >
> > Well, it didn't work for me, any suggestions?
> 
> Please invoke your script as perl -w.  This will give you very useful
> warnings like
> 
>     Applying pattern match to @array will act on scalar(@array)
> 
> It will also allow you to give better descriptions of your problem than
> "didn't work".
> 
> perldoc perlrun
> perldoc perldiag
> 
> If you want to check a pattern against an array, you can use grep.
> 
>     @matches = grep /$file/o => @achFiles;
> 
> This is kind of wasteful if you are only going to get one match since
> grep will check each element of @achFiles.
> 
> If you want to search a set of unique elements then you are better off
> defining the set as a hash.
> 
>     %achFiles = (
>         filename1.ach => 1,
>         filename2.ach => 1,
>         filename3.ach => 1,
>         filename4.ach => 1,
>     );
> 
>     if (exists $achFiles{$file} ) {
> 
> or just
> 
>     if ($achFiles{$file}) { # when values are all true
> 
> --
> Rick Delaney
> rick.delaney@shaw.wave.ca


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

Date: Mon, 5 Oct 1998 23:22:01 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: regular expression
Message-Id: <1dgg8s6.7g5a011jev8zN@bay2-204.quincy.ziplink.net>

Eric Wong <egwong@netcom.com> wrote:

> Steven Ford <sford@home.com> wrote:
> : shouldn't this regx work?
> 
> : if (@achFiles =~ /$file/){
> :  Do something....}
> 
> I don't think it ought to work that way.  According to the
> perlop manpage
> 
>   Binary "=~" binds a scalar expression to a pattern match.
> 
> and, of course, @achFiles is no scalar expression.
> 
> You might try grep() (it's in the perlfunc manpage).

But you shouldn't.


>From perlfaq4:

    ...

    Please do not use

         $is_there = grep $_ eq $whatever, @array;

    or worse yet

        $is_there = grep /$whatever/, @array;

    These are slow (checks every element even if the first matches),
    inefficient (same reason), and potentially buggy (what if there are
    regexp characters in $whatever?).


Likewise, you shouldn't suggest it as a solution.

-- 
 _ / '  _      /         - aka -         rjk@coos.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: Tue, 06 Oct 1998 03:28:32 GMT
From: Justin Harvey <jbharvey@auspex.net>
Subject: Re: regular expression
Message-Id: <36198E52.B670BC51@auspex.net>

# Define @achFiles
# I'm assuming $file is some kind of variable defined too.

foreach (@achFiles) {
    if(/$file/) {
         do something;
    }
}

Steven Ford wrote:
> 
> shouldn't this regx work?
> 
> if (@achFiles =~ /$file/){
>  Do something....}
> 
> I want to check and see if a file is in a list of valid filenames. This
> is how I initialized @achFiles:
> 
> @achFiles = (
>         "filename1.ach",
>         "filename2.ach",
>         "filename3.ach",
>         "filename4.ach");
> 
> Well, it didn't work for me, any suggestions?
> 
> - Steven Ford

--
Justin B. Harvey			http://www.auspex.net/jbharvey
jbharvey@auspex.net			Mountain View, CA

		   use Perl || die "trying";


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

Date: Mon, 5 Oct 1998 21:54:04 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: regular expression
Message-Id: <co0cv6.8sj.ln@flash.net>

Steven Ford (sford@home.com) wrote:

: I want to check and see if a file is in a list of valid filenames. 


   Perl FAQ, part 4:

      "How can I tell whether an array contains a certain element?"


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


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

Date: Tue, 6 Oct 1998 00:09:45 -0400
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: script: scriptMangle!
Message-Id: <19981006.000945.6d8.rnr.w164w@locutus.ofB.ORG>

"Elaine -HappyFunBall- Ashton" <eashton@bbnplanet.com> writes:

> Well, take my point, obfuscated perl is not sup3r s33kr3t c0dz. :)

of course not.  you can _read_ sup3r s33kr1t c0d3z.
-- 
Russell_Schulz@locutus.ofB.ORG  Shad 86c


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

Date: Mon, 05 Oct 1998 23:10:22 -0500
From: Liz Castro <liz@cookwood.com>
Subject: Re: Too late for "-T" option ?
Message-Id: <36199829.96C88C61@cookwood.com>

Marc Haber wrote:
> 
> defike@nospam.ilstu.edu (Don) wrote:
> >I have a program using;
> >#!/usr/local/bin/perl -Tw
> >Which returns when run;
> >Too late for "-T" option at line 1
> 
> How is your skript being invoked?
> 

I have this same problem. It's the simplest of scripts and I'm invoking it
from the command line. Still, I get this message. Any thoughts?

Thanks,
Liz


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

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

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