[11545] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5145 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 16 03:17:22 1999

Date: Tue, 16 Mar 99 00:00:25 -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           Tue, 16 Mar 1999     Volume: 8 Number: 5145

Today's topics:
    Re: /([_A-Za-z]\w*)(?!\s*=)/ (Tad McClellan)
        Arcserve,Exhange, and Event log perl scripts (Scott)
        Arcserve,Exhange, and Event log perl scripts (Scott)
        Can I carry a variable form 1 page to another? <Doc@goforit.demon.co.uk>
    Re: debugger mystery... (Ronald J Kimball)
    Re: FAQ 8.31: Can I use perl to run a telnet or ftp ses <forrestg@uregina.ca>
    Re: help with pattern matching (Tad McClellan)
    Re: help with pattern matching (Tad McClellan)
    Re: help with pattern matching <thrase@slip.net>
    Re: help with pattern matching (brian d foy)
    Re: help with pattern matching <mfuerst@advancenet.net>
        how to get system date? <globus@infonet.ee>
    Re: how to get system date? (Tad McClellan)
        MSIE Does Not Undestand "IMGSIZE" (Laertis)
    Re: MSIE Does Not Undestand "IMGSIZE" (Sam Holden)
    Re: Need Faster Approach (Ronald J Kimball)
    Re: NewbieQ: if ($dbhost && $dbname !~ m%[/@]%); <hattons@cpkwebser5.ncr.disa.mil>
        Perl Win32::ODBC Error while using MS Access ODBC drive <ykpan@yahoo.com>
        Posting a form data variable to the end of a url <shawncarpenter@MailAndNews.com>
    Re: searching a flat file database <ebohlman@netcom.com>
    Re: Sending a Hotmail email <witless@my-dejanews.com>
    Re: Sending a Hotmail email <ebohlman@netcom.com>
    Re: Syntax errors with PerlShop... (Ronald J Kimball)
    Re: Testing CGI scripts on a standalone <Doc@goforit.demon.co.uk>
        Unable to find load file LS <jkloss@hurontel.on.ca>
    Re: Using Select on STDIN ??? (Ronald J Kimball)
    Re: Using Select on STDIN ??? <forrestg@uregina.ca>
    Re: Using the print << command <ebohlman@netcom.com>
    Re: viewing contents of *.html files (Ronald J Kimball)
    Re: Web Programming (Ronald J Kimball)
    Re: What is wrong with this piece of counter code? (Tad McClellan)
    Re: Where to start with Perl aluben@my-dejanews.com
    Re: Where to start with Perl (Dana Booth)
    Re: Where to start with Perl <ebohlman@netcom.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 15 Mar 1999 17:47:03 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: /([_A-Za-z]\w*)(?!\s*=)/
Message-Id: <7l2kc7.rb6.ln@magna.metronet.com>

Alex Farber (alex@kawo2.rwth-aachen.de) wrote:

: please... it's 02:30 here in Germany... what am I doing wrong?


   Uhhh. Staying up too late?

   :-)


: I would like to extract all function names from a MATLAB file:

: ++$func{$1} while (/([_A-Za-z]\w*)(?!\s*=)/g); # words not followed by =

: But it does not work - "not followed by =" is ignored. However


   It is not ignored.

   The _count_ will be as if it was ignored though.

   Having a look at the actual matched strings instead of
   depending on just a count of the match strings would
   have been revealing:

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

$_ = 'foo bar = baz';

while (/([_A-Za-z]\w*)(?!\s*=)/g) {
   print "$1\n";
}
------------------

output:

foo
ba
baz


   Yep.  

   The string 'ba' is not followed by optional whitespaces
   and an equal sign.

   Perl matches whenever it can, and it could, so it did.

   Perl gave you what you asked for.

   Ask for something else  :-)


      /([_A-Za-z]\w*\b)(?!\s*=)/g
                    ^^
                    ^^

: ++$vars{$1} while (/([_A-Za-z]\w*)(\s*=)/g);

: works... What's the reason?


   Because now it can scan more characters and still match,
   and it "wants" to match.


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


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

Date: Sun, 14 Mar 1999 13:50:36 +1300
From: scott@ncs.co.nz (Scott)
Subject: Arcserve,Exhange, and Event log perl scripts
Message-Id: <MPG.1155cf0414315ed989698@ingate>

I am currently looking at Processing these logs with perl and sending 
emails using 'BLAT' of the results to myself. Rather than reventing the 
wheel, has anyone done this, or something similar with these apps before?

Being fairly new to perl I would appreciate some reusable code/examples 
with respect to this.

Cheers Scott

P.S Please reply by email as well.


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

Date: Mon, 15 Mar 1999 19:39:11 +1300
From: scott@ncs.co.nz (Scott)
Subject: Arcserve,Exhange, and Event log perl scripts
Message-Id: <MPG.115772368744930098969b@ingate>

I am currently looking at Processing these logs with perl and sending 
emails using 'BLAT' of the results to myself. Rather than reventing the 
wheel, has anyone done this, or something similar with these apps before?

Being fairly new to perl I would appreciate some reusable code/examples 
with respect to this.

Cheers Scott

P.S Please reply by email as well.


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

Date: Tue, 16 Mar 1999 07:03:52 +0000
From: Doc <Doc@goforit.demon.co.uk>
Subject: Can I carry a variable form 1 page to another?
Message-Id: <VnoruAAYJg72EwZQ@goforit.demon.co.uk>

Hi
I have a database on a server.  I can build a web page from it 'on the
fly' using a CGI script (+ODBC for win95 etc.).  I want the user to be
able to press a button to call for the next relevant page.  This
requires that the script called for by the button press knows the values
of several variables from the current page.  I presume that my first
script, which formed the current page is now dead.  How can I do this?

I thought of saving the current info to a file but this gives problems
when several people are using the site at once!

Thanks in anticipation,
Doc
-- 
Doc


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

Date: Tue, 16 Mar 1999 00:39:23 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: debugger mystery...
Message-Id: <1doqepd.1m6y1lz14qhtq8N@bay3-145.quincy.ziplink.net>

John Chambers <john.chambers@gte.com> wrote:

> Hmmm ... So when it starts getting the line number wrong, how do you
> manage to follow what it's doing?  I can sorta follow along in the
> source, of course, but every time it hits a branch point, there's a
> major delay while you figure out which branch it took. Since verifying
> that the branching is correct is a major part of debugging, this isn't
> exactly a trivial concern.

Do you have some source code that reliably demonstrates this problem in
the debugger?  I would be very interested to see code that fools the
debugger "every time it hits a branch point".

It is my experience that, on occasion, the debugger will show the line
following a loop, when it is actually executing a line at the beginning
of the loop.  It is generally apparent when this has happened and which
line is actually being executed, and after stepping once the debugger
shows the proper line again.

Are your debugging sessions more confused than that?

-- 
 _ / '  _      /         - 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: Tue, 16 Mar 1999 01:04:27 -0600
From: Greg Forrest <forrestg@uregina.ca>
Subject: Re: FAQ 8.31: Can I use perl to run a telnet or ftp session?
Message-Id: <36EE027A.65F20BC7@uregina.ca>

Hello,
I'm having the same problem as you. I looked at the IO::Select mod and it provides

a clearer description (sort of) and is easier to use (my opinion). However, I
can't
seem to get it to accept STDIN as a value. If you find a solution, I would GREATLY

appreciate knowing how you solved it.

Greg Forrest

rob_liberti@my-dejanews.com wrote:

> In article <36ce3844@csnews>,
>   perlfaq-suggestions@perl.com (Tom and Gnat) wrote:
> > (This excerpt from perlfaq8 - System Interaction
> >     ($Revision: 1.36 $, $Date: 1999/01/08 05:36:34 $)
> > part of the standard set of documentation included with every
> > valid Perl distribution, like the one on your system.
> > See also http://language.perl.com/newdocs/pod/perlfaq8.html
> > if your negligent system adminstrator has been remiss in his duties.)
> >
> >   Can I use perl to run a telnet or ftp session?
> >
> >     Try the Net::FTP, TCP::Client, and Net::Telnet modules (available from
> >     CPAN). http://www.perl.com/CPAN/scripts/netstuff/telnet.emul.shar will
> >     also help for emulating the telnet protocol, but Net::Telnet is quite
> >     probably easier to use..
> >
> >     If all you want to do is pretend to be telnet but don't need the initial
> >     telnet handshaking, then the standard dual-process approach will
> >     suffice:
> >
> >         use IO::Socket;             # new in 5.004
> >         $handle = IO::Socket::INET->new('www.perl.com:80')
> >                 || die "can't connect to port 80 on www.perl.com: $!";
> >         $handle->autoflush(1);
> >         if (fork()) {               # XXX: undef means failure
> >             select($handle);
> >             print while <STDIN>;    # everything from stdin to socket
> >         } else {
> >             print while <$handle>;  # everything from socket to stdout
> >         }
> >         close $handle;
> >         exit;
> >
> > --
> > "IMHO, CAPS LOCK should be somewhere more
> > convenient; e.g., in another building."  --jgreely
> >
>
> Okay, I tried that, and as luck would have it, FORK is not supported on the
> Windows NT version of Perl I'm using.  I know I can do it on a Unix box, but I
> thought hey why can't I use the multiplexing io stuff from the select()
> function?!  The problem is, that everything refers to the same FAQ which
> doesn't supply a very easy to understand example:
>
>     $nfound = select($rout=$rin, $wout=$win, $eout=$ein, undef);
>
> So, for instance, I want to
> (1) read from STDIN and send that to the client file descriptor
> and at the same time
> (2)read from the $handle file descriptor and write to STDOUT.
>
> What do I assign to $rin? $win? and $ein?
> How do I use $rout? $wout? and $eout?
>
> I understand I have to start the $rin, $win, and $ein to ''. I also,
> understand the fileno() and vec() functions. I just can't find an example of
> anyone using the select fucntion for io multiplexing!  BTW I promise to do
> this the easy way (with fork) on a Unix box, I just want to understand
> select()
>
> Thanks for any help,
> Rob
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own



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

Date: Mon, 15 Mar 1999 17:28:56 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help with pattern matching
Message-Id: <8j1kc7.rb6.ln@magna.metronet.com>

Kevin Howe (khowe@performance-net.com) wrote:

: The Variable:
: $var = "<on>this  <off>..........<on>that  <n>  <off>..........<on>
: more<off>";

: What I want to do is eliminate all spaces(\s) and all "<n>" codes that are
: located between the <on><off> pairs in this string. Below is what I want to
: end up with

: $var = "<on>this<off>...<on>that<off>...<on>more<off>";


   Uhhh. Do you really also want all series of dots reduced to 
   three dots or something?

   Because that result does not follow from what your word
   description said...


: I have tried many different pattern matches but I can't seem to get a handle
: on this one.


$var =~ s/(<on>.*?<off>)/
            my $s=$1;
            $s =~ s#(?: |<n>)##g;
            $s;
         /ge;


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


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

Date: Mon, 15 Mar 1999 19:25:34 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help with pattern matching
Message-Id: <ud8kc7.7i6.ln@magna.metronet.com>

brian d foy (comdog@computerdog.com) wrote:
: In article <6kjH2.13528$134.133925@tor-nn1.netcom.ca>, "Kevin Howe" <khowe@performance-net.com> posted:

: > What I want to do is eliminate all spaces(\s) and all "<n>" codes that are
: > located between the <on><off> pairs in this string.
    ^^^^^^^^^^^^^^^

: how about:

: $line = "<on>this  <off>.....<on>that  <n>  <off>....<on>more<off>";

: $line =~ s/<n>//g;


   But that also removes <n> that are _not_ between the delimiters.


   Kevin should have included that case in his test string:

   $line = '<on>this  <off>..<n>...<on>that  <n>  <off>....<on>more<off>';


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


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

Date: Mon, 15 Mar 1999 23:20:25 -0800
From: Paul Cameron <thrase@slip.net>
To: Kevin Howe <khowe@performance-net.com>
Subject: Re: help with pattern matching
Message-Id: <36EE0639.6007E04B@slip.net>

Kevin Howe wrote:

> Hi, can someone please help me with the following:
>
> The Variable:
> $var = "<on>this  <off>..........<on>that  <n>  <off>..........<on>
> more<off>";
>
> What I want to do is eliminate all spaces(\s) and all "<n>" codes that are
> located between the <on><off> pairs in this string. Below is what I want to
> end up with

> $var = "<on>this<off>...<on>that<off>...<on>more<off>";
>
> I have tried many different pattern matches but I can't seem to get a handle
> on this one.

Well, I don't know how to do it in one regular expression, so I cheated.
This works for me, but I haven't tested it extensively. My apologies if
it blows up for you, or is uber inefficient.

$_ = "<on> this  <off>  <on>that   <n> moo <off>  <on> more
<off>";

s{
  <on>             # Match start
    (?:\s+|<n>)*   # Get rid of all text matching whitespace and <n>
      (.*?)        # Match anything else non-greedily
    (?:\s+|<n>)*   # And get rid of following whitespace/<n>
  <off>            # End this match, ignore everything in between
}
{
  (my $rep = $1) =~ s#<n>##g;   # Remove <n> characters between text
  "<on>$rep<off>";              # And reconstruct string
}egsx;

print "$_\n";

So, this yields:

<on>this<off>  <on>that    moo<off>  <on>more<off>


Hope this helps,

Paul.



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

Date: Tue, 16 Mar 1999 02:39:03 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: help with pattern matching
Message-Id: <comdog-ya02408000R1603990239030001@news.panix.com>

In article <ud8kc7.7i6.ln@magna.metronet.com>, tadmc@metronet.com (Tad McClellan) posted:

> brian d foy (comdog@computerdog.com) wrote:
> : In article <6kjH2.13528$134.133925@tor-nn1.netcom.ca>, "Kevin Howe" <khowe@performance-net.com> posted:

> : > What I want to do is eliminate all spaces(\s) and all "<n>" codes that are
> : > located between the <on><off> pairs in this string.
>     ^^^^^^^^^^^^^^^

> : how about:
> : $line = "<on>this  <off>.....<on>that  <n>  <off>....<on>more<off>";
> : $line =~ s/<n>//g;
> 
> 
>    But that also removes <n> that are _not_ between the delimiters.

>    Kevin should have included that case in his test string:
> 
>    $line = '<on>this  <off>..<n>...<on>that  <n>  <off>....<on>more<off>';

even if he had i would have messed it up because i read it wrong (my
fault.  it was explained clearly enough).  sorry about that :(

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


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

Date: Tue, 16 Mar 1999 01:53:00 -0600
From: Michael Fuerst <mfuerst@advancenet.net>
Subject: Re: help with pattern matching
Message-Id: <36EE0DDC.9D061E95@advancenet.net>

Try doing it in two steps,  the first removing all the blanks
 and the second removing the <n>'s found between <on> and <off>

Kevin Howe wrote:

> Hi, can someone please help me with the following:
>
> The Variable:
> $var = "<on>this  <off>..........<on>that  <n>  <off>..........<on>
> more<off>";
>
> What I want to do is eliminate all spaces(\s) and all "<n>" codes that are
> located between the <on><off> pairs in this string. Below is what I want to
> end up with
>
> $var = "<on>this<off>...<on>that<off>...<on>more<off>";
>
> I have tried many different pattern matches but I can't seem to get a handle
> on this one.
>
> Any help would be much appreciated,
> Kevin Howe

--
If this post is a question to a newsgroup, please also reply to me
if you can.   Thanks.

Michael Fuerst
802 N Broadway
Urbana IL 61801

217 239 5844 (H)
    352 6511 (D)




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

Date: Tue, 16 Mar 1999 07:06:39 +0200
From: Gleb Ekker <globus@infonet.ee>
Subject: how to get system date?
Message-Id: <36EDE6DF.AF4EF80A@infonet.ee>

Hi,

I tried to get server system date and time using

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);

The time is correct but the date is always the same - the 15th of
February!  Is it another variant to get the day and month?

Thanks,
Gleb.




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

Date: Mon, 15 Mar 1999 19:19:07 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: how to get system date?
Message-Id: <r18kc7.7i6.ln@magna.metronet.com>

Gleb Ekker (globus@infonet.ee) wrote:

: I tried to get server system date and time using

: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);

: The time is correct but the date is always the same - the 15th of
: February!  


   If $mon is 2, then that is *March* 15th.

   Sounds right if you were doing the testing today...

   :-)



   When having trouble with the behavior of the localtime() function,
   you should go look up the localtime() function in the docs that
   came with your perl distribution (perlfunc.pod).

   Wherein it says:  "C<$mon> has the range C<0..11>"


: Is it another variant to get the day and month?


   Kinda. But the above variant works just fine if you use it correctly.


   You can use localtime() in a scalar context to get a single
   string representing the date:

      print scalar localtime, "\n";

   But that is also mentioned in the description of the localtime()
   function in the docs that came with your perl distribution.


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


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

Date: Tue, 16 Mar 1999 07:31:40 GMT
From: lerna@terna.com (Laertis)
Subject: MSIE Does Not Undestand "IMGSIZE"
Message-Id: <36ee0852.97846426@news.supernews.com>

Opera and Netscape understand the following instruction:

($width,$heights) = imgsize("friend.jpg");

But MSIE does not. Any ideas why?
Thanks a lot.

@@-->>> Soulis
tatabu@ministre.net



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

Date: 16 Mar 1999 07:52:06 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: MSIE Does Not Undestand "IMGSIZE"
Message-Id: <slrn7es3d6.sfl.sholden@pgrad.cs.usyd.edu.au>

On Tue, 16 Mar 1999 07:31:40 GMT, Laertis <lerna@terna.com> wrote:
>Opera and Netscape understand the following instruction:

No they don't...


>
>($width,$heights) = imgsize("friend.jpg");
>
>But MSIE does not. Any ideas why?

Because it is a Perl statement, and none of the browsers you mentioned are
Perl interpreters as far as I know.

-- 
Sam

Fifty years of programming language research, and we end up with C++ ???
                --Richard A. O'Keefe


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

Date: Tue, 16 Mar 1999 00:39:24 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Need Faster Approach
Message-Id: <1doqfbc.6skv47i62smmN@bay3-145.quincy.ziplink.net>

<frogsmock@my-dejanews.com> wrote:

> Here's the way I see it:  if I want, for example, records 75,000 - 75,050 out
> of 100,000, one obvious place to save time is by ignoring everything after
> 75,050 (but I don't know how to do that using my 'split' approach).

Use split()'s third argument:

@array = split(/,/, $_, 75_051);

Then element 75051 will contain everything after the 75050th comma.

> However,
> what I'm hoping for is a faster way (impossible?) to get to the 75,000th item
> instead of splitting off each preceding item.

Don't know if this is faster, but at least it doesn't require the huge
array of unwanted elements.  It finds the 75000th comma, and only splits
the substring from there to the end of the string.

#!/usr/local/bin/perl

$_ = '1';
for ($i=2;$i<=100_000;++$i) {
  $_ .= ",$i";
}

$pos = 0;
$count = 0;

$pos = index($_, ',', $pos) + 1 while (++$count < 75_000 and $pos >= 0);

if ($pos > 0) {
  @records[0..49] = split(/,/, substr($_, $pos), 51);
  print "@records\n";
}

__END__


-- 
chipmunk (Ronald J Kimball) <rjk@linguist.dartmouth.edu>
perl -e 'print map chop, sort split shift, reverse shift
' 'j_' 'e._jP;_jr/_je=_jk{_jn*_j &_j :_j @_jr}_ja)_js$_j
~_jh]_jt,_jo+_jJ"_jr>_ju#_jt%_jl?_ja^_jc`_jh-_je|' -rjk-


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

Date: Tue, 16 Mar 1999 00:19:14 -0500
From: "Steven T. Hatton" <hattons@cpkwebser5.ncr.disa.mil>
Subject: Re: NewbieQ: if ($dbhost && $dbname !~ m%[/@]%);
Message-Id: <36EDE9D2.1546AAD8@cpkwebser5.ncr.disa.mil>

Paul,

Thanks to you and all others who took the time to hepl.  I bought the Nutshell
book.  I suspect you mean the "Programming Perl" book.  I well, I have a
_lot_ of books already.  I may get it in the future.  For now I am trying the
"dive in the deep end" approach.  I have short term requirements to hack some
existing code.

This is what I sent Dr. Jim at work as my spin on all this.  It's funny I
reveived several replies to this question and each one gave me a different
peice of the answer.  Dr. Jim gave me the all good so far, now RTFM answer.

Ok, here's the skiny as I see it.  $string_name =~ /[abc]/ says: return true if

$string_name contains 'a' or 'b' or 'c'.  But in my case $string_name may
contain a '/' so the match expression will get confused if I use '/' as part of

my regular expression and '/' as a delimiter.  I can use any non-alphanum for a

delimiter, but when I do that I must explicitly use 'm' at the beginning of my
matching expression.  Now the !~ is just the negation of =~.  So $string_name
!~ m&[/@]& is the same as $string_name !~ m%[/@]% .  The 'm' for multi-line
matching goes at the end of the line.  e.g.,  $string_name !~ m&[/@]&m .  What
exactly that does for me is not clear but I don't care right now.

So the code is saying: $dbname gets dbname@dbhost as long as dbname doesn't
already have an '@' or a '/'.  This makes sense because dbname@dbhost and
/usr/local/someplace/dbname are both ways of telling the code what the whole
name of my datasourse is.

Thanks a lot for the sanity check.  I still have one problem though.  When the
code executes it finishes with the output: "you appear to be normal."  I'm srue

there is something wrong with that :-/

Steve


Paul Cameron wrote:

> "Steven T. Hatton" wrote:
>
> > Hi,
> >
>
> You asked for it, now you're going to receive 2000 or so replies.
>
> > I'm trying to lean DBD::Informix and perl the hard way.  I am trying to
> > read the test scripts that came with the package.  The one I am
> > currently concerned with is InformixTest.pm, v 58.1 by Johnathan
> > Leffler.   From that script I found a line that doesn't make a lot of
> > sense to me:
>
> Learn Perl the easy way. Buy The Book like everyone else did :-)
>
> > $dbname = $dbname . '@' . $dbhost if ($dbhost && $dbname !~ m%[/@]%);
>
> Doesn't look too bad so far. Should probably have used the .= operator
> though.
>
> > Obviously this is an assignment of a concatonated string to $dbname.
> > This assignment only works if ($dbhost && $dbname !~ m%[/@]%) evalueates
> > to true.  I assume that  $dbhost evaluates to true if it is declared(?)
> > and non-zero.  Is this right?
>
> Yes. If it's not declared, then if C<use strict> (or is that -w ?) is in
> use, the script
> will break in a run-time error (presuming $dbhost has been declared
> somewhere).
>
> Hey, I could be wrong. I didn't write the damn language.
>
> > I also assume $dbname !~ m%[/@]%
> > evaluates to true if $dbname does not match  m%[/@]%.  What I completely
> > don't understand is " m%[/@]% "   What the heck does this mean?
>
> This is using the *m*atch operator, using % signs instead of backslashes (/)
> as
> delimiters. This is perfectly legal.
>
> The rest is obvious. Read perlre. Match if $dbname does not contain a
> backslash and 'at' character. So it would fail for "blah@foo", "blah/foo",
> but match
> for "moo.dog";
>
> Hope this helps,
>
> Paul.

--
http://counter.li.org -User # 79059 | I think.
http://www.suse.com                 | I think I am.
http://www.kde.org                  | Therefore I am.
http://samba.anu.edu.au             | I think? - Moody Blues






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

Date: Mon, 15 Mar 1999 23:32:02 -0700
From: "Eric Pan" <ykpan@yahoo.com>
Subject: Perl Win32::ODBC Error while using MS Access ODBC driver 4.0.
Message-Id: <7cktoe$3i8$1@newsboy.fiber.net>

I am using WindowsNT Server 4.0 SP 4, MS Access ODBC Driver 4.00, Perl
Resource Kit SP1 and MS Office 97 SR-2. But I get the following errors while
trying to insert a row into a MS Access table:

Error: [-20309] [1] [0] "[Microsoft][ODBC Microsoft Access Driver] Operation
not supported on replicable databases that have not been converted to the
current version." Rows affected:

But, I don't have any error retrieving row using SELECT statement. Do you
know why? Please help.




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

Date: Tue, 16 Mar 1999 07:21:16 GMT
From: shawn carpenter <shawncarpenter@MailAndNews.com>
Subject: Posting a form data variable to the end of a url
Message-Id: <MDnH2.47725$rs2.14537078@client.news.psi.net>

I would like to post data from a form to an html file.

Users would input a stock symbol in the form...  like MSFT

then I would like to post the MSFT to the end of the url reference

<a href="http://quote.yahoo/q?s=MSFT">MSFT</a>

http://quote.yahoo.com/q?s=msft

I would anticipate having several links that will need to have the form data 
posted to the end of the url.

what is the code in perl?



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

Date: Tue, 16 Mar 1999 07:40:13 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: searching a flat file database
Message-Id: <ebohlmanF8oFz1.E7t@netcom.com>

William Herrera <posting.account@lynxview.com> wrote:
: I want something faster. This is a BIG database that is growing by 30
: megs a month. I want someting that takes phrases in quotes like
: matching "John Smith" AND pencil and "ballpoint pen" when present in
: the database in any order. The way I do it now is to loop through the
: match for each $s1 ... $sn which is slower than I like.

You could try using the Text::Query::Advanced module available from CPAN, 
which will take a Boolean expression using AND, OR, NOT and NEAR (along 
with parentheses for grouping) and test a string to see if it matches.  
It basically works by creating a regex that uses the techniques discussed 
in Recipe 6.17 of TPC.

However, doing a linear search over 60+ megs of data is going to be pretty
slow even if you only have to do one regex match per record.  About the
only way to speed it up is to create an auxilliary index hash (probably
stored as a DBM file) whose keys are all the words contained in the data
records and whose values are lists of record numbers (or file offsets if
the records aren't fixed-length) for records that contain each word.  With
such a structure, looking up individual words is trivial; looking up an
AND of words is a matter of getting the record lists for all the words and
taking their intersection and looking up an OR of words is a matter of
taking the union of their record lists.  Matching phrases involving more
than one word is harder; either you have to store some sort of
word-position indicators in the record lists, or you have to treat a
phrase as the AND of two words and then do a straight regex match for the
phrase on the selected records. 

Text::Query::Advanced has some methods that could be subclassed to create 
data structures for indexed matching rather than a regex for linear 
searching.



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

Date: Tue, 16 Mar 1999 05:50:07 GMT
From: Witless <witless@my-dejanews.com>
Subject: Re: Sending a Hotmail email
Message-Id: <7ckrec$cb7$1@nnrp1.dejanews.com>

Thanks for your reply. Actually I know the POST request already. What I'm
getting wrong is either the URL or the content cause I keep getting error: 302
-REDIRECTED (which brings me back into the inbox page). Do you know the actual
script that does the posting?


In article <36ECA119.DF91379F@idt.net>,
  James Tolley <jamesht@idt.net> wrote:
> Well, you could:
> 1) copy the html from the Hotmail send-mail form.
> 2) find all of the inputs in that form.
> 3) write a script like the one below to submit the form, based upon the inputs
> you found.
>
> use HTTP::Request;
> use LWP::UserAgent;
>
> $method = 'POST'; # I'm guessing
> $url = 'http://www.hotmail.com/something/something';
> $content = 'figure=this&part=out&and=youre&home=free';
> # I'm using undef for the headers, by the way.
> $html =
>
LWP::UserAgent->new()->request(HTTP::Request->new($method,$action,undef,$content
))->as_string();
>
> print "It's just that simple.\n";
>
> hth,
>
> James
>
>

If nothing goes wrong on the first run, you must be using some sample
code...

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


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

Date: Tue, 16 Mar 1999 07:18:58 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Sending a Hotmail email
Message-Id: <ebohlmanF8oEzM.D72@netcom.com>

Witless <witless@my-dejanews.com> wrote:
: Thanks for your reply. Actually I know the POST request already. What I'm
: getting wrong is either the URL or the content cause I keep getting error: 302
: -REDIRECTED (which brings me back into the inbox page). Do you know the actual
: script that does the posting?

A 302 isn't an error; it's a normal way of redirecting a user agent to
another page.  I presume that it's Hotmail's normal way of sending the
browser back to the inbox page after you post a message (it couldn't very
well just send the HTML for the inbox page directly in response to a POST
request, could it?  That would leave the browser with a bunch of HTML that
had no URL to call its own, and links out of it wouldn't work). 



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

Date: Tue, 16 Mar 1999 00:39:26 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Syntax errors with PerlShop...
Message-Id: <1doqh0a.ojf60gc3genyN@bay3-145.quincy.ziplink.net>

"John Bigbooty" <mr_bigbooty@hotmail.com> wrote:

> Line 128 in the script is as follows:
> 
> if (lc $use_cookies ne 'yes')
> 
> and when run in the shell it produces this error:
> 
> syntax error in file Perlshop.cgi at line 128, next 2 tokens "lc 
> $use_cookies "
> Execution of Perlshop.cgi aborted due to compilation errors.

You're running a Perl5 script under Perl4.  You need to upgrade your
Perl installation.  (The latest version is perl5.005_02.)

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
          perl -le 'print "Just another \u$^X hacker"'


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

Date: Tue, 16 Mar 1999 07:13:54 +0000
From: Doc <Doc@goforit.demon.co.uk>
Subject: Re: Testing CGI scripts on a standalone
Message-Id: <PHCtGGAySg72Ew5P@goforit.demon.co.uk>

In article <RSt6zBALNl62EwCc@goforit.demon.co.uk>, Doc
<Doc@goforit.demon.co.uk> writes
>Hi
>I am new to CGI scripting and am writing a script to produce web pages
>from a database - no problem there.  But, I would like to be able to
>test the programme on my PC rather than have to use my provider's
>server!  I know that I can run my programme via the command prompt but
>obviously that does not include the browser.  How can I run it and see
>the results? (Yes I have run simple programmes from the browser but as
>soon as I include calculations and non-HTML stuff it gets printed on the
>screen and no calcs are done - i.e. it is not run as a porper programme)
>
>Thanks in anticipation
>
>doc
A response to my own atricle and a solution!  I have installed a
freeware version of OmniHTTPD(v1.01) 
(see www.micro.demon.co.uk/dbase.htm).  This sets up a server on my PC
for local use.  I can now run my CGI scripts on a browser without
connecting  to the net while developing.
  I then downloaded Microsoft's SQL server driver.  I set up a system
DSN with the SQL type and a user DSN with Access(mdb) type.  All works
easily, for once!  One word of warning - make sure that you have used
the DOS prompt (and dropped it to the bottom of the screen if you wish)
before running your programme - is this because of compiling???).

Thanks to those who offered help.
Doc
-- 
Doc


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

Date: Tue, 16 Mar 1999 02:40:44 -0500
From: "John Kloss" <jkloss@hurontel.on.ca>
Subject: Unable to find load file LS
Message-Id: <7cl0v1$j36$1@nr1.toronto.istar.net>

Hello,

I am very new to Perl and programming in general. I am hoping someone out
there will help me out with my dilema.

I have a script that searches directories on my web server( a very simple
script). When I run the script I get all the HTML output that I am supposed
to but no search results. I check the server logs and get the message:

Unable to find load file LS

The server is a Netscape Enterprise 3.0 running on a Novell O/S

Any help would be greatly appreciated

Thanks,
John Kloss




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

Date: Tue, 16 Mar 1999 00:39:27 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Using Select on STDIN ???
Message-Id: <1doqham.1e2630q13mx8sN@bay3-145.quincy.ziplink.net>

[posted and mailed]

Greg Forrest <forrestg@uregina.ca> wrote:

> my $ClientData = new IO::Select( *\STDIN );

No backslash:

my $ClientData = new IO::Select( *STDIN );

-- 
 _ / '  _      /         - 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: Tue, 16 Mar 1999 00:50:51 -0600
From: Greg Forrest <forrestg@uregina.ca>
Subject: Re: Using Select on STDIN ???
Message-Id: <36EDFF4B.46C4A128@uregina.ca>

That didn't work. Here is a more detailed listing of my code.

#!/usr/local/bin/perl -w
require 5.002;
use strict;
use IO::Socket;
use IO::Select;

my ($Socket, $ServerPort);
my $TimeOut = 5;
my $buffer;
my $StartupScreen = <<END;
****************************************************************
* This is a simple chat client *
****************************************************************
\n\n\n\n\n\n\n\n\n\n\n\n\n
END
print STDOUT "$StartupScreen";
print STDOUT "Please Enter Server's Name or IP: ";
my $ServerIP = <STDIN>;

do
{
    print STDOUT "Please Enter Port Number: ";
    $ServerPort = <STDIN>;
    chop($ServerPort);    # remove CRLF
} while( $ServerPort == 0 );

$| = 1;
my $remote = IO::Socket::INET->new(Proto => 'tcp',
                                   PeerAddr => $ServerIP,
                                   PeerPort => $ServerPort,
                                   Type => SOCK_STREAM) or die $!;
print STDOUT "SUCCESSFULLY CONNECTED TO $ServerIP ON PORT $ServerPort\n";

$remote->autoflush(1);

my $ClientData = new IO::Select( *\STDIN );
my $RemoteData = new IO::Select($remote);

    while( $RemoteData->can_read )
    {
        recv($remote,$buffer,80,0);
        print "$buffer";
        if( $ClientData->can_read($TimeOut) )
        {
            my $DataToServer = <STDIN>;
            chomp( $DataToServer );
            send($remote, $DataToServer,0);
        }
    }

__END__


Ronald J Kimball wrote:

> [posted and mailed]
>
> Greg Forrest <forrestg@uregina.ca> wrote:
>
> > my $ClientData = new IO::Select( *\STDIN );
>
> No backslash:
>
> my $ClientData = new IO::Select( *STDIN );
>
> --
>  _ / '  _      /         - 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: Tue, 16 Mar 1999 07:24:44 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Using the print << command
Message-Id: <ebohlmanF8oF99.DL7@netcom.com>

George Crissman <strads@tmisnet.com> wrote:
: Yeah, I remember having problems with the print << command.

This is going to sound nitpicky, but it's Not A Good Idea to think in
terms of the "print << command."  Perl doesn't have one.  Rather, it has
the print() function, operator, statement, whatever you want to call it, and
it has the "here-doc" convention for quoting lengthy strings with embedded
newlines.  The two can certainly be used together, and often are, but
they're not fundamentally connected; here-doc quoting can be used anywhere
you can use a literal string, not just as an argument to print().  People 
often overlook this, which is why I'm being so nitpicky here.




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

Date: Tue, 16 Mar 1999 00:39:27 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: viewing contents of *.html files
Message-Id: <1doqheo.4ltgb3rn62rN@bay3-145.quincy.ziplink.net>

Zenin <zenin@bawdycaste.org> wrote:

> : now this works fine and dandy, unless the file I want to view is a html
> : file.  I don't want to view the HTML itself, but rather the actual html
> : source.  Is this possible to do?  If so, how?
> 
>   print "Content-type: text/html\n\n";
>   print "<PRE>\n";
> 
>   open FILE, $input{'file'} or die $!;
>   while (<FILE>) {

        s/&/&amp;/g;

>       s/</&lt;/g;
>       s/>/&gt;/g;
>       print;
>   }
> 
>   print "</PRE>\n";
>   __END__


Is there anything else we're forgetting?


-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
perl -e'$_="\012534`!./4(%2`\cp%2,`(!#+%2j";s/./"\"\\c$&\""/gees;print'


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

Date: Tue, 16 Mar 1999 00:39:28 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Web Programming
Message-Id: <1doqhlu.105k8jad3xwkcN@bay3-145.quincy.ziplink.net>

Travis Leuthauser <korak@intersurf.com> wrote:

>     I am trying to write a perl script which will display a dislaimer, have
> the web user agree to the terms of the agreement, then call itself again and
> bring up a simple form for the user to fill out.  The reason I would like
> everything in the same script is to force every user to read the disclaimer
> first.  If there is a better way, I am certainly open to suggestions.  This
> is being written for an Apache web server.  Any help would be greatly
> appreciated.

That sounds to me like a very good way to do it.


A similar question was asked just a few days ago.  My response should be
helpful to you as well:


<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: Mon, 15 Mar 1999 17:32:15 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: What is wrong with this piece of counter code?
Message-Id: <fp1kc7.rb6.ln@magna.metronet.com>

tatabu@my-dejanews.com wrote:
: My counter log file gets corrupted all the time.

: What is wrong with this code? 


   You are releasing the lock before you close the file.


: open (LOG, "$logpath");


   You are not checking the return value there.


: flock (LOG, 2);


   You are not checking the return value there.


: flock (LOG, 8);
: close(LOG);


   Did you have a look at the three Frequently Asked Questions
   (in part 5) that have "lock" in them yet?

   You should.


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


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

Date: Tue, 16 Mar 1999 06:03:53 GMT
From: aluben@my-dejanews.com
Subject: Re: Where to start with Perl
Message-Id: <7cks84$d3k$1@nnrp1.dejanews.com>

Learning Perl is a tutorial.
Programming Perl is a reference.
Perl Cookbook is more advanced.
Advanced Perl Programming if you can't get enough.

All are good books and are published by O'Reilly, the animal series. Read the
table of contents.



In article <36ED1673.29D50D@ccrsDotnrcandOtgc.ca>,
  Tom Kralidis <tom.kralidis@ccrsDotnrcandOtgc.ca> wrote:
> Hi,
>
> At the risk of getting smart-alec replies, does anyone have any good
> starting points for someone wanting to learn Perl.  I have a good handle
> of UNIX (awk, grep, sed), some C/C++ and have heard nothing but good
> things about Perl.  I would like to enhance my data manipulation
> capabilities and productivity among other things.
>
> Thanks in advance,
>
> ..Tom
>
--------------------------------------------------------------------------------------------
> Tom Kralidis				      			Canada Centre for Remote Sensing
> Geo-Spatial Technologist		      			588 Booth Street , Room 241
> User Systems Development Section	      			Ottawa , Ontario K1A 0Y7
> Data Acquisition Division		      			Tel: (613) 947-1828
> mailto:tom.kralidis@ccrs.nrcan.gc.ca    			Fax: (613) 947-1408
>
>                               http://www.ccrs.nrcan.gc.ca
>
--------------------------------------------------------------------------------------------
>

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


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

Date: Tue, 16 Mar 1999 07:20:07 GMT
From: dana@oz.net.DELETE.CAPS (Dana Booth)
Subject: Re: Where to start with Perl
Message-Id: <HCnH2.124$2u4.434@news6.ispnews.com>

In article <36ED1673.29D50D@ccrsDotnrcandOtgc.ca>
Tom Kralidis <tom.kralidis@ccrsDotnrcandOtgc.ca> wrote:

> Hi, 
> 
> At the risk of getting smart-alec replies, does anyone have any good
> starting points for someone wanting to learn Perl.  I have a good handle
> of UNIX (awk, grep, sed), some C/C++ and have heard nothing but good
> things about Perl.  I would like to enhance my data manipulation
> capabilities and productivity among other things.

Programming Perl, an O'Reilly book, is very good. Like you, I also
had some programming experience before trying Perl, and unlike
some other languages, this made Perl a real snap, as far as getting
the basics down. Knowing other languages can be a hinderence
sometimes; I get impatient, and instead of learning, I just flip through
a book until I find what I need. But with Perl, and with the book
Programming Perl, you can get going _very_ quickly.

BTW, Perl is a blast... I'm the SA at a manufacturing plant, and I
find myself looking for reasons to write Perl. :)

---------------------------
Dana Booth <dana[at]oz.net>
Tacoma, Wa., USA
---------------------------



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

Date: Tue, 16 Mar 1999 07:47:41 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Where to start with Perl
Message-Id: <ebohlmanF8oGBI.EGr@netcom.com>

[obsolete newsgroup removed from headers]

aluben@my-dejanews.com wrote:
: Learning Perl is a tutorial.
: Programming Perl is a reference.
: Perl Cookbook is more advanced.
: Advanced Perl Programming if you can't get enough.

: All are good books and are published by O'Reilly, the animal series. Read the
: table of contents.

O'Reilly is planning to publish (their Web site indicates a May release) 
a CD-ROM with all those books (including both the Unix and Win32 versions 
of Learning Perl) along with _Perl in a Nutshell_ and Johan Vromans' 
quick reference guide) for around $70.



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

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

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