[11517] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5117 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 12 07:07:18 1999

Date: Fri, 12 Mar 99 04:00:22 -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           Fri, 12 Mar 1999     Volume: 8 Number: 5117

Today's topics:
        About accessing databases with perl <fabascal@gredos.cnb.uam.es>
        Are negative array indeces allowed? <eedalf@eed.ericsson.se>
    Re: CGI.pm - parameter count? (Ronald J Kimball)
    Re: CGI.pm - parameter count? <dave@mag-sol.com>
    Re: CGI.pm param persistence question (Ronald J Kimball)
    Re: Database thru Perl (Jonathan Stowe)
    Re: Elegant remote execution of Perl-scripts? mjl@home.ins.de
    Re: FAQ 3.21: How can I hide the source for my Perl pro (Ronald J Kimball)
    Re: flock / sysopen / open confusion (Ronald J Kimball)
    Re: flock / sysopen / open confusion (Ronald J Kimball)
    Re: Getting E-mail addresses from html files? (Ronald J Kimball)
    Re: Getting E-mail addresses from html files? (Jonathan Stowe)
    Re: Help converting perl website to a CD (Ronald J Kimball)
    Re: How to do a Case-insensitive Sort? (Ronald J Kimball)
    Re: IO::SOCKET question: how can my server determine cl (Ronald J Kimball)
        make exe from perl skript <raming@ewh.uni-hannover.de>
    Re: Mysql question (Jonathan Stowe)
    Re: Perl Question (Jonathan Stowe)
    Re: Perl Question (Jonathan Stowe)
    Re: Perl refuses to work in my browser, only in MSDos <dave@californiaic.com>
    Re: problems with readdir (Ronald J Kimball)
        Problems writing data to files <cobalt@dircon.co.uk>
    Re: Requirements to embed perl into C (Personal setting (Tobias Wolff)
        Requirements to embed perl into C nobody@nowhere
    Re: Requirements to embed perl into C <eedalf@eed.ericsson.se>
        Send a mail with Hotmail witless@my-dejanews.com
    Re: Socket programming problem (Ronald J Kimball)
    Re: use diagnostics problem? (Ronald J Kimball)
        Working with single characters <mgs21@columbia.edu>
    Re: Writing to a file (Ronald J Kimball)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 12 Mar 1999 11:26:11 +0100
From: Federico Abascal <fabascal@gredos.cnb.uam.es>
Subject: About accessing databases with perl
Message-Id: <36E8EBC2.64FA0BE1@gredos.cnb.uam.es>

Hello,
Could anybody tell me what is the $dsn that is referred in the DBI man
page? I need to know what it means to configure the drivers to access
the database. Where can I find information about this, please?
Thanks
Fede



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

Date: Fri, 12 Mar 1999 12:43:27 +0100
From: Alex Farber <eedalf@eed.ericsson.se>
Subject: Are negative array indeces allowed?
Message-Id: <36E8FDDF.6CDF54E3@eed.ericsson.se>

Hi,

I have just discovered that perl -e '@x = qw (a b c); print $x[-3]'
prints "a" on my Solaris workstation (perl 5.004_04). So, is a
negative array index allowed? Amazing, I haven't ever read about it
in the 5 perl books I have or in "perldoc perldata"... When was it
introduced? Can I rely on it now?

/Alex


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

Date: Fri, 12 Mar 1999 05:28:31 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: CGI.pm - parameter count?
Message-Id: <1doiu21.kbd1mn21jphcN@bay1-500.quincy.ziplink.net>

[posted and mailed]

<k_mcdermott@my-dejanews.com> wrote:

> I have a couple of scripts that create forms and then have an 'opposite
> number' which processes the output of the form.
> 
> I was wanting to combine these into one script, to create and then process the
> form.
> 
> Is this possible?

Yes, I've written many CGI scripts like that.


I generally use extra path info:

http://www.example.com/cgi-bin/script.pl
# generate the form

http://www.example.com/cgi-bin/script.pl/submit
# process the form submission

http://www.example.com/cgi-bin/script.pl/help
# return some help text

etc.


When the script is executed, it should check the PATH_INFO environment
variable to decide what to do.

When the script generates output, it should include the appropriate
extra path info in the ACTION of any submit buttons, and in the HREF of
any links.

-- 
 _ / '  _      /         - 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: Fri, 12 Mar 1999 11:19:20 GMT
From: Dave Cross <dave@mag-sol.com>
Subject: Re: CGI.pm - parameter count?
Message-Id: <7cat7i$24e$1@nnrp1.dejanews.com>

In article <7c8v51$bt6$1@nnrp1.dejanews.com>,
  k_mcdermott@my-dejanews.com wrote:
> Hi,
>
> I have a couple of scripts that create forms and then have an 'opposite
> number' which processes the output of the form.
>
> I was wanting to combine these into one script, to create and then process the
> form.
>
> Is this possible?
>
> I had thought that the number of parameters would be useful since the creator,
> only has one parameter and the form processor has many, but I can't get
> the number of parameters out?
>
> Can anyone help...

Something along these lines perhaps...

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

use strict;
use CGI;

my $page = CGI->new;

print "Form has ", scalar $page->param, " parameter(s).\n";


Dave..

--
Dave Cross
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 12 Mar 1999 05:28:32 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: CGI.pm param persistence question
Message-Id: <1doiueb.1fl7ib35330wuN@bay1-500.quincy.ziplink.net>

Craig Hogan <chogan@primenet.com> wrote:

> What I don't understand is
> what $Query->hidden is doing for me.  Before I used CGI.pm, I had to
> set every variable in a hidden field to see it next time.  But with
> CGI.pm, you can retain the variable by simply saying:
> 
> print $Query->hidden('myvariable');
> 
> In other words, you don't have to reset the value!  I guess it uses
> the current value as the default.
> 
> Fine.  But I mention this because if I want to CHANGE the value of a
> variable going through hidden, I have to do
> $Query->delete('myvariable') first.

You do?  Can't you just change the value as normal?

$Query->param('myvariable', 'myvalue);


Or specify it in hidden()?

print $Query->hidden('myvariable', 'myvalue');


> My question is: Why do I have to do this if every time the script is 
> invoked I am declaring a new object?  Shouldn't the new object be
> created with all the current hidden values?

Huh?  I thought you just said that the new object _is_ created that way.

> Deleting first works, but 
> it bothers me that I don't understand what's going on.

I don't understand either.


-- 
 _ / '  _      /         - 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: Fri, 12 Mar 1999 11:39:34 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Database thru Perl
Message-Id: <36e8fcb9.10029529@news.dircon.co.uk>

On Thu, 11 Mar 1999 10:50:12 +0000, tszeto <tszeto@mindspring.com>
wrote:

>Is there a good book on how to access and manipulate
>database files (Microsoft Access) using Perl/Cgi ?
>

Win32::ODBC

/J\


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

Date: 12 Mar 1999 11:06:53 GMT
From: mjl@home.ins.de
Subject: Re: Elegant remote execution of Perl-scripts?
Message-Id: <7casgd$814$1@bra.ins.de>

Hi,

G.B. Woeste <GWoeste@yahoo.com> wrote:
> two questions:

> how can I execute a Perl-script, which is initially located on 
> computer A on another computer B? 

With RPC you have a server process running on computer B waiting for
requests from clients. Does that fit your needs?

There are some modules from J. Wiedmann for remote procedure calls. 
I don't have an URL, but if you look for RPC::pClient, RPC::pServer
and Net::Daemon on CPAN, there should be some documentation inside 
the packages.

> How can I transmit values from computer A as commman-line arguments to a
> (then executed) Perl-script on computer B?

You can pass simple variables but nothing complex like references. 
That is a conceptual problem and nothing about perl. But still that
exceeds the power of command line. ;-)

> Both computers are working under Unix and are connected (via TCP/IP).

> The problem for me is, that I don't know much about Networking , Sockets
> and so on. 

The mentioned modules operate on objects and after creating a "server
object" on your client (computer A) you get a local dummy object and
don't need to remember wether it is working local or remote. 

> Does anyone have some example code? That would be very helpfull!

As stated above, there should be documentation and sample code comming
with the module. I have heard a lecture about that, AFAIR there are
some notes, but they are in german and I don't know where to look right
now.

> Thank you!

> Regards,

> Georg Woeste

-- 
Do you want to know more?                                mjl@home.ins.de


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

Date: Fri, 12 Mar 1999 05:28:33 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: FAQ 3.21: How can I hide the source for my Perl program?
Message-Id: <1doix00.1s2t62ndptc0N@bay1-500.quincy.ziplink.net>

John Moreno <planb@newsreaders.com> wrote:

> Tom Christiansen <perlfaq-suggestions@perl.com> wrote:
> 
> >     Security through obscurity, the name for hiding your bugs instead of
> >     fixing them, is little security indeed.
> 
> This isn't true. All security is through obscurity -- it's always about
> limiting access to something.

Not at all.  Limiting access is not the same as obscurity.

For example, you will find very few banks masquerading as fast food
restaurants.  If that were the only security measure a bank took, they
would be easy pickings for anyone who knew where to find them.  That
would be security through obscurity.

Instead, banks have guards, cameras, vaults, alarms, etc.  And even
though everybody knows about most of the security measures, it's not
easy to rob a bank.

-- 
 _ / '  _      /         - 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: Fri, 12 Mar 1999 05:28:35 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: flock / sysopen / open confusion
Message-Id: <1doixx1.1t10mdm1absxvkN@bay1-500.quincy.ziplink.net>

Larry Rosler <lr@hpl.hp.com> wrote:

> In article <1dof9k4.h4z98gq5cxisN@bay2-453.quincy.ziplink.net> on Tue, 9
> Mar 1999 23:50:59 -0500, Ronald J Kimball <rjk@linguist.dartmouth.edu
> >says...
> ...
> > It's too late to lock the file if you've already changed the file
> > contents.  Instead, you need to open the file with a mode of "+>", which
> > does not clobber the file contents.
> 
> Oh, yes it does.  You meant to write "+<".

Yup, that's what I meant.  Very sloppy of me.  :(

-- 
 _ / '  _      /         - 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: Fri, 12 Mar 1999 05:28:51 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: flock / sysopen / open confusion
Message-Id: <1dojg3d.1ymh6f5jdd3pbN@bay1-500.quincy.ziplink.net>

Zenin <zenin@bawdycaste.org> wrote:

>   And how would you suggest opening a file for reading and writing if
>   it doesn't already exist? -Hint: <+ will fail if the file does not
>   exist already.

It will also fail if the actual file name doesn't being with a plus.  ;)

I think you meant +<.  The plus has to be first.

-- 
 _ / '  _      /         - 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: Fri, 12 Mar 1999 05:28:39 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Getting E-mail addresses from html files?
Message-Id: <1doiy3x.1flt9z013f8lekN@bay1-500.quincy.ziplink.net>

Jason T. Breitweg <Jason.Breitweg@desy.de> wrote:

>   if ($line =~ /mailto:([\S^\@]+\@[\S^\@]+(?=\"))/) {

You seem to be confused about character classes.

[\S^\@]

That matches a non-whitespace character, or a literal ^, or a literal @.
(Of course, ^ and @ are already included in \S.)

^ only has a special meaning as the very first character in a character
class.  Otherwise it's just a literal ^.


[^\s@]

That matches any character which is neither whitespace nor a literal @.


Your regex should allow for the use of single quotes instead of double
quotes as the delimiter.

-- 
 _ / '  _      /         - 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: Fri, 12 Mar 1999 10:29:47 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Getting E-mail addresses from html files?
Message-Id: <36e8eb38.5548439@news.dircon.co.uk>

On 11 Mar 1999 17:02:17 +0100, Jason T. Breitweg
<Jason.Breitweg@desy.de> wrote:

>Hi everyone,
>
>I have a bunch of html files that include mailto: tags.  What I want
>to do is get all the E-mail addresses from these files and then send a
>short e-mail to these people (no spam though).
>

Sure.  Then how come you have to extract the addresses from 'a bunch
of html files' rather than a database of the  subscribers to your
wonderful new information service - if its not unsolicited mail then
you should have the addresses already.

>The code that I have written so far is:
>
<snip>
>
>but sometimes I get funny things.  Like if someone had a period at the
>very end of their address.  Stuff like that.  Does anyone have a
>canonical regexp for addresses?  Thanks for the help.
>

Anyhow nearly everything you need to know is addressed (ouch) in
perlfaq9 or has at the very least been discussed in this group before.

/J\


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

Date: Fri, 12 Mar 1999 05:28:40 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Help converting perl website to a CD
Message-Id: <1doiyb0.1ph4wc51wl891nN@bay1-500.quincy.ziplink.net>

<horseyride@hotmail.com> wrote:

> 3. How would I call it from the browser anyway

You can't, not without a web server.

-- 
 _ / '  _      /         - 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: Fri, 12 Mar 1999 05:28:41 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: How to do a Case-insensitive Sort?
Message-Id: <1doiykj.1479f5f1o30fpgN@bay1-500.quincy.ziplink.net>

Larry Rosler <lr@hpl.hp.com> wrote:

> No.  I'm sorry, Greg.  It is demonstrably incorrect.
> 
> A summary for those who might not recall the issue:
> 
> Naive sort:  sub sortsub { lc($a) cmp lc($b) }
> 
> Schwartz Transform (ST) sort:
>     O(n) setup of arrays with lc as second element.
>     sub sortsub { $a->[1] cmp $b->[1] }
>     O(n) recovery of the data from the arrays.
> 
> Simple benchmark of sortsub alone:
> 
> #!/usr/local/bin/perl -w
> use Benchmark;
> 
> my ($a, $b, $c, $d) = ('foo', 'bar', [ 0, 'foo' ], [ 0, 'bar' ]);
> 
> sub Cntrl { $a cmp $b }
> 
> sub Lcase { lc($a) cmp lc($b) }
> 
> sub ST    { $c->[1] cmp $d->[1] }
> 
> timethese(1 << (shift || 0), {
>   Cntrl => \&Cntrl,
>   Naive => \&Naive,
>   ST    => \&ST,
> });
> __END__
> 
> Benchmark: timing 1048576 iterations of Cntrl, Naive, ST...
>      Cntrl:  5 wallclock secs ( 5.41 usr +  0.00 sys =  5.41 CPU)
>      Naive:  8 wallclock secs ( 7.83 usr +  0.00 sys =  7.83 CPU)
>         ST:  8 wallclock secs ( 8.05 usr +  0.00 sys =  8.05 CPU)
> 
> As the two sortsubs take about the same time to execute, the overhead of
> the ST cannot be recovered for any size of the data set.  QED

That's odd, the output I get is:

Ambiguous use of Cntrl => resolved to "Cntrl" => at bench.pl line 13.
Ambiguous use of ST => resolved to "ST" => at bench.pl line 15.
Benchmark: timing 1048576 iterations of Cntrl, Naive, ST...
     Cntrl:  4 secs ( 5.01 usr  0.01 sys =  5.02 cpu)
Undefined subroutine &main::Naive called at (eval 4) line 1.


Clearly, the Schwartzian Transform solution is preferred, because the
Naive solution causes a runtime error.  ;-)


Let's try that again...


#!/usr/local/bin/perl -w
use Benchmark;

my ($a, $b, $c, $d) = ('foo' x 100, 'bar' x 100,
                       [ 0, 'foo' x 100 ], [ 0, 'bar' x 100 ]);

sub cntrl { $a cmp $b }

sub naive { lc($a) cmp lc($b) }

sub st    { $c->[1] cmp $d->[1] }

timethese(1 << (shift || 20), {
  Cntrl => \&cntrl,
  Naive => \&naive,
  ST    => \&st,
});
__END__

Benchmark: timing 1048576 iterations of Cntrl, Naive, ST...
     Cntrl:  7 secs ( 6.38 usr  0.00 sys =  6.38 cpu)
     Naive: 40 secs (40.13 usr  0.00 sys = 40.13 cpu)
        ST:  8 secs ( 8.25 usr  0.00 sys =  8.25 cpu)


ST is constant with regard to the length of the strings.  Naive is not.

-- 
 _ / '  _      /         - 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: Fri, 12 Mar 1999 05:28:43 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: IO::SOCKET question: how can my server determine client's IP address?
Message-Id: <1doizva.1dhlu7l1inicqzN@bay1-500.quincy.ziplink.net>

<jim-h@mailexcite.com> wrote:

> I've managed to get a simple client/server connection using
> IO::Socket, but I want to add security that will allow only clients
> with a certain IP address to connect to the server.
> 
> Where is the variable or method that holds the client's IP number:


The documentation for IO::Socket mentions the following:

    METHODS

    See in the perlfunc manpage for complete descriptions of each of the
    following supported IO::Socket methods, which are just front ends
    for the corresponding built-in functions:

        socket
        socketpair
        bind
        listen
        accept
        send
        recv
        peername (getpeername)
        sockname (getsockname)


So, looking up getpeername() in perlfunc:

    getpeername SOCKET

    Returns the packed sockaddr address of other end of the SOCKET
    connection.

        use Socket;
        $hersockaddr    = getpeername(SOCK);
        ($port, $iaddr) = unpack_sockaddr_in($hersockaddr);
        $herhostname    = gethostbyaddr($iaddr, AF_INET);
        $herstraddr     = inet_ntoa($iaddr);


So, to get the clients IP address via IO::Socket:

    $sockaddr = $client->peername();

and then continue as in the above example.


HTH!


-- 
 _ / '  _      /         - 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: Fri, 12 Mar 1999 11:41:22 +0100
From: Georg Raming <raming@ewh.uni-hannover.de>
Subject: make exe from perl skript
Message-Id: <36E8EF52.B7C43687@ewh.uni-hannover.de>

Hi,

is there an easy way to make an executable from an perl skript under
WinNt?

Thanks,

Georg


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

Date: Fri, 12 Mar 1999 11:06:26 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Mysql question
Message-Id: <36e8f401.7797682@news.dircon.co.uk>

On Thu, 11 Mar 1999 22:49:23 GMT, John@melon17.freeserve.co.uk (John )
wrote:

>On Thu, 11 Mar 1999 13:59:56 -0800, Tobin Fricke
><tobin@cory.eecs.berkeley.edu> wrote:
>
>>I think you're confused.. if you modify the database, the database is
>>modified regardless of how you subsequently access it.
>
>Yes I am confused a little.
>
>I have created a mysql database, can access it
>, but cannot find out/figure  where the file is situated (not
>visible on my web site).
>

Yes - it is likely that the database files are located somewhere
outside of the HTTP servers document root if the person who set it up
has any sense.  

Most of the time you have no reason to access the actual files that
comprise the database because you can access the database via the
usual interface.

Anyhow this is not really anything to do with Perl thus I have set
followups to a more appropriate group ...

/J\


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

Date: Fri, 12 Mar 1999 10:34:06 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Perl Question
Message-Id: <36e8ed11.6021188@news.dircon.co.uk>

On Thu, 11 Mar 1999 18:29:25 -0500, James Tolley <jamesht@idt.net>
wrote:

>#!  /usr/local/bin/perl
>#! /usr/local/tcsh
>
>$searchStr = $ENV{'QUERY_STRING'};

<snip>

>
>This might need some tweaking. The script above assumes that the request is GET and
>that the string is handed to the script as a value called 'param'.
>

Yeah probably the biggest tweak would be to replace the majority of
that code with the functionality provided bu CGI.pm then you can
handle both GET and POST requests transparently.

/J\


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

Date: Fri, 12 Mar 1999 10:59:55 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Perl Question
Message-Id: <36e8ee41.6325143@news.dircon.co.uk>

On Thu, 11 Mar 1999 09:48:41 -0500, Helen Zhou <hzhou@newbridge.com>
wrote:

>Hi All:
>
>I am just starting to learn perl and wondering how to write a script to do this:
>
>I want to create a web page to ask a user to enter a search string.  Then
>I will take this string and do a grep in the local directory to find files
>containing that string.  Then I want to list all the filenames on the web as
>hyperlinks.
>
>The only problem I have is to embed the unix command. If I use tcsh, will
>the following be valid?
>

Er no.

What happened when you tried it ?

If you want to run an external command in Perl then you have to use
one of system(), the backticks or exec depending on your requirements
- see the perlfunc manpage for more on this.

'grep' is a Perl builtin in anyhow so you could do it without using an
external command..  read the grep section of the perlfunc manpage.

Anyhow I posted the majority of the solution that you need last week
see:

<http://www.dejanews.com/[ST_rn=ps]/getdoc.xp?AN=451898535>

All you *need* do is change the bit where it say:

 foreach (@files)         
 {           
             print "<LI>\n";
            print "<A HREF='$me?filename=$_'>$_</A>\n";
            print "</LI>\n";          
} 

To:

foreach (@files}
{
     if ( -T $_ )
      {
          local $/;
          open(FILE,$_ ) || next ; 
          if ( grep /whatever/,<FILE> )
            {
              print "<LI>\n";
              print "<A HREF='$me?filename=$_'>$_</A>\n";
              print "</LI>\n"; 
           }
       }         
} 

You may have noticed that I have conveniently skipped over any
consideration of allowing a search on some user-specified term rather
than hardcoded as at present.  I leave that as an exercise for the
reader after, of course, having read the CGI.pm documentation.

/J\


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

Date: Thu, 11 Mar 1999 15:28:48 -0800
From: "David Eaves" <dave@californiaic.com>
Subject: Re: Perl refuses to work in my browser, only in MSDos
Message-Id: <36e85425.0@news.globalpac.com>

Try this link.  I'm running Activeperl on an NT server it works fine, but
you have to create the association.

http://www.activestate.com/activeperl/docs/perl-win32/perlwin32faq4.html#How
_do_I_associate_Perl_scripts_
Michael Georgiadis wrote in message <7c94c4$g6e$1@nnrp01.iafrica.com>...
>matthew
>
>i'm having the same problem, but with windows nt 4.0 and apache web server.
>i am not sure how to correct it, but i think it is a problem with the way
>that the browser associates files with .pl or .cgi which is different to
how
>dos does it. perhaps we are missing some simple setting somewhere.
hopefully
>some guru will come along and put us out of our nightmare once and for all
>
>best of luck
>
>michael
>
>
>Jay Glascoe wrote in message <36E6D03F.24B342FE@giss.nasa.gov>...
>>[courtesy copy sent to cited author]
>>
>>Matthew Baines wrote:
>>>
>>> This is really getting me down.
>>
>>:o(
>>
>>> When I use Perl in Dos, it works fine.  Any recommendations would be
>greatly
>>> appreciated.
>>
>>The script works off of the command line, right?
>>Since the script itself seems to be working, I think
>>this is a problem suitable for comp.infosystems.www.authoring.cgi
>>(i.e., I have no idea how to help you  ;^)
>>
>>Be sure to read their FAQ (don't don that red suit).
>>http://www.dejanews.com/[ST_rn=ps]/getdoc.xp?AN=451974553
>>
>> Jay Glascoe
>>--
>>"The number of UNIX installations has grown to 10, with more expected."
>>    -- _The UNIX Programmer's Manual_, Second Edition, June, 1972.
>
>




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

Date: Fri, 12 Mar 1999 05:28:45 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: problems with readdir
Message-Id: <1doj46i.1y5o4v92utf2pN@bay1-500.quincy.ziplink.net>

<jstrike@execpc.com> wrote:

> ## I don't like doing this but I don't know of a way to get the length
> of the
> ## arrary that contains the dirlist.

scalar(@array) is the number of elements in @array.  i.e.:

  $count = @array;   # implicit scalar context
  print "There are $count items in @array.\n";


$#array is the index of the last element in @array.  i.e.:

  print "\@array starts at 0 and ends at $#array.\n";


-- 
 _ / '  _      /         - 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: Fri, 12 Mar 1999 11:36:04 -0000
From: "Paul Davies" <cobalt@dircon.co.uk>
Subject: Problems writing data to files
Message-Id: <36e8fa1f.0@newsread3.dircon.co.uk>

I'm trying to write binary data from a variable to a file.

The simple:

print FILE <$var>; or print FILE $var is not working.

Can someone please tell me how to do this?

Thanks

Paul






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

Date: Fri, 12 Mar 1999 09:57:48 GMT
From: T.Wolff@uea.ac.uk (Tobias Wolff)
Subject: Re: Requirements to embed perl into C (Personal settings)
Message-Id: <7caoh8$ju5@cpca3.uea.ac.uk>

Sorry, I forgot to configure my newsreader with my reply address.


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

Date: Fri, 12 Mar 1999 09:50:40 GMT
From: nobody@nowhere
Subject: Requirements to embed perl into C
Message-Id: <7cao3s$ju5@cpca3.uea.ac.uk>

Hi folks,

well, a common problem, I think. I try to embed perl into C. I'm currently 
working under Windows NT with the GNU C Compiler provided by CYGWIN b20 and 
Perl 5.004_02.
I've read the first paragraphs of "perlembed" and tried to find out what I 
need by running "perl -V". Given the output I have some questions:
1. In the section for the Compiler, it is said that I need the "bcc32" 
compiler. Do I really need it, or can I use the gcc from CYGWIN? If not, where 
can I get the "bcc32" compiler.
2. The same with the Linker. "perl -V" tells me to use "tlink32". Do I really 
have to stick to it? Again, where can I get it from?
3. There are some link libraries to include (such as "cw32mti.lib"). I have 
searched my system. They are not there. Do they come with the "bcc32" or 
"tlink32"?

Disregarding all that, I tried to use the "gcc" to compile the simple perl 
interpreter example from "perlembed" ... and, well there were a whole bunch of 
warning about previous declarations and definitions, conflicting types ... and 
errors about undefined symbols. I used the command:

gcc -D_RTLDLL -DWIN32 -I/perl/lib/CORE -c interp.c

For the moment, I refrain from providing any code, makefiles or anything else, 
because it might be that the answers to the questions above may solve my 
problems.

Any hints?
Tobias.


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

Date: Fri, 12 Mar 1999 12:48:15 +0100
From: Alex Farber <eedalf@eed.ericsson.se>
To: Tobias Wolff <T.Wolff@uea.ac.uk>
Subject: Re: Requirements to embed perl into C
Message-Id: <36E8FEFF.4DD1384F@eed.ericsson.se>

Hi,

a very nice book on perl embedding is "Advanced Perl Programming" -
see http://www.oreilly.com/catalog/advperl/

> I've read the first paragraphs of "perlembed" and tried to find out what I
> need by running "perl -V". Given the output I have some questions:
> 1. In the section for the Compiler, it is said that I need the "bcc32"
> compiler. Do I really need it, or can I use the gcc from CYGWIN? If not, where
> can I get the "bcc32" compiler.

Probably the "Borland C++" command line compiler is meant.

> 2. The same with the Linker. "perl -V" tells me to use "tlink32". Do I really
> have to stick to it? Again, where can I get it from?

It's probably "Turbo Link" from "Borland C++"

/Alex


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

Date: Fri, 12 Mar 1999 10:37:52 GMT
From: witless@my-dejanews.com
Subject: Send a mail with Hotmail
Message-Id: <7caqq0$9l$1@nnrp1.dejanews.com>

I have code that logs me onto an email account. What I can't do so far is to
post an email with Hotmail. Can anyone share any info on this?

Thanks

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 12 Mar 1999 05:28:46 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Socket programming problem
Message-Id: <1doj4zt.1tp1eq5qzk4r1N@bay1-500.quincy.ziplink.net>

Mr.unix <Mr.unix@mail.excite.com> wrote:

>  I am trying to modify the perl programs to take data from an interface
> which sends data in a stream and doesn't appear to send a "\n" and doesn't
> appear to close the session or any other delimiting factors. Is there some
> way to read the data on a socket byte by byte, looking for a delimiting
> character (0x1C), so that I may separate records? Does anyone have any code
> examples that may work?

One way might be to set the input record separator to the appropriate
character and use <>.

    $/ = \x1c;
    while (<SOCKET>) {
       ...
    }


But if you're worried about blocking and such, then you'll have to look
into the IO::Select module and all that fun stuff.


-- 
 _ / '  _      /         - 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: Fri, 12 Mar 1999 05:28:47 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: use diagnostics problem?
Message-Id: <1doje70.1ihktod1p8g5hjN@bay1-500.quincy.ziplink.net>

Mick <horizon@internetexpress.com.au> wrote:

> Hi....under win32, when trying to use
> 
> use diagnostics;
> 
> In a web page perl script, I get the 'internal server error'
> 
> which in my error log is
> premature end of script headers.

Are there more errors, or just that?  That's not a very helpful error,
all it means is your script exited before it finished printing the
headers.  But it doesn't say _why_ your script exited early.


> The diagnostics.pm file is there along with Carp.pm etc, I've tested a
> lot of the other modules
> with success, and If  I comment out the use diagnostics; my script runs
> fine?
> 
> Any ideas?

Why do you want to use diagnostics in a CGI script?  It will just fill
up your error log that much more quickly.

You can get the info presented by use diagnostics by looking up specific
errors in the perldiag documentation.

-- 
 _ / '  _      /         - 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: Fri, 12 Mar 1999 05:45:33 -0500
From: Mike Schiraldi <mgs21@columbia.edu>
Subject: Working with single characters
Message-Id: <Pine.GSO.3.95qL.990312053901.27634A-100000@merhaba.cc.columbia.edu>

I'm working on an AI program that does a ton of work with rearranging letters
(it plays Upwords, a Scrabble-like game) 

I'd like it to be pretty efficient, since it's going to be working with some
really big data structures.

I know Perl only uses with numbers and strings, but are there any efficiency
tricks when the only values you'll be working with are [A-Z]? I mean, why
allocate memory for a string or an arbitraily large number when you don't need
it? 

I'm also going to represent the board as a single array of length 64, instead
of an 8 by 8 array, to save on overhead. Should i just store the whole board as
a string?



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

Date: Fri, 12 Mar 1999 05:28:50 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Writing to a file
Message-Id: <1dojfvf.1xu29du23mwplN@bay1-500.quincy.ziplink.net>

Zenin <zenin@bawdycaste.org> wrote:

> olmert@netvision.net.il wrote:
> : I tried to open a file for writing. The unfortunate result is always that
> : the entire file is erased,
> 
>   perldoc -f open
> 
>   You probably wanted to use <+ (instead of +>)

He probably wanted +<.  <+ is not a valid mode specifier.

   open FOO, "<+tmp" or die "$!\n";

opens a file named +tmp for reading.

-- 
 _ / '  _      /         - 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: 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 5117
**************************************

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