[16856] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4268 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 8 21:10:34 2000

Date: Fri, 8 Sep 2000 18:10:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968461819-v9-i4268@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 8 Sep 2000     Volume: 9 Number: 4268

Today's topics:
    Re: Last day of month <anmcguire@ce.mediaone.net>
    Re: Need Help! OK Who wants to laugh at my first perl a <care227@attglobal.net>
    Re: New Perl Tutorial - www.perltutor.com (Gwyn Judd)
    Re: New Perl Tutorial - www.perltutor.com <uri@sysarch.com>
    Re: New Perl Tutorial - www.perltutor.com lurker65535@my-deja.com
    Re: ODBC, OLE, ADO, WTF?? <bcaligari@my-deja.com>
    Re: ODBC, OLE, ADO, WTF?? <jeff@vpservices.com>
    Re: Packet problem <jon@king-fu.freeserve.co.uk>
    Re: Perl & https & proxy andkovacs@my-deja.com
    Re: Perl script hogging memory on IRIX 6 <bcaligari@my-deja.com>
    Re: Perl script hogging memory on IRIX 6 (Chris Fedde)
    Re: Regular Expressions <care227@attglobal.net>
    Re: Regular Expressions <lr@hpl.hp.com>
    Re: Regular Expressions (Abigail)
    Re: Regular Expressions <bcaligari@my-deja.com>
    Re: Regular Expressions <mauldin@netstorm.net>
    Re: Regular Expressions <care227@attglobal.net>
    Re: Regular Expressions <dietmar.staab@t-online.de>
    Re: Regular Expressions <dietmar.staab@t-online.de>
    Re: Regular Expressions (Abigail)
    Re: Scoping of symbolic references (variables) <sariq@texas.net>
    Re: Simple Question <jjohn@cs.umb.edu>
    Re: The Heartbreak of Inscrutable Perl Code <sariq@texas.net>
    Re: The Heartbreak of Inscrutable Perl Code <christopher_j@uswest.net>
    Re: use strict: why? <christopher_j@uswest.net>
    Re: use strict: why? <bart.lateur@skynet.be>
    Re: use strict: why? <bart.lateur@skynet.be>
    Re: use strict: why? <godzilla@stomp.stomp.tokyo>
    Re: use strict: why? <bart.lateur@skynet.be>
    Re: use strict: why? (Gwyn Judd)
    Re: using unix commands within perl script darlenewong@my-deja.com
        why on earth can't locate bing-du@tamu.edu
        Win32::AuthenticateUser is working ? saravanansrivai@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 8 Sep 2000 17:59:45 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: Last day of month
Message-Id: <Pine.LNX.4.21.0009081754460.5851-100000@hawk.ce.mediaone.net>

On 8 Sep 2000, Abigail quoth:

~~ Date: 08 Sep 2000 06:59:41 GMT
~~ From: Abigail <abigail@foad.org>
~~ Newsgroups: comp.lang.perl.misc
~~ Subject: Re: Last day of month
~~ 

[ snip my silly reply ]

~~ 
~~ Even in England and its colonies, the last day of September 1752 was
~~ the 30th. The most recent day the above code fails on is February 1700,
~~ although it will be correct for that day in many parts of Western Europe.
~~ 
[ removing foot from mouth ]

Er, whoops.  For some reason I was thinking that the number of the 
last day of a month has a direct correlation to the number of days in
that month.  I guess I should have looked at that 'cal' output
a little longer. :-)

anm 
-- 
Andrew N. McGuire
anmcguire@ce.mediaone.net
perl -le'print map?"(.*)"?&&($_=$1)&&s](\w+)]\u$1]g&&$_=>`perldoc -qj`'



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

Date: 08 Sep 2000 22:27:42 GMT
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Need Help! OK Who wants to laugh at my first perl attempt?
Message-Id: <39B96574.5D5F9A58@attglobal.net>

Greg Donovan wrote:
> 
> Ok here it goes! Let me have it! What am I doing wrong? Boy is that a
> loaded question. Please be kind and just give me a few pointers. Keep in
> mind this is my first attempt at any kind of code at all. I sincerly
> would appreciate your guru critiques.

Can I pretend to be a guru?  It would make me happy!


> Well it almost works. It sends the file name of the mail message to the
> forwarding address not the contents.

As expected.  I'll show you...

> #!/usr/bin/perl -w
> use strict;

Excellent habits!  Keep them up.  The probelm is in the section 
I have retained below:

>     opendir(BIN, "/var/spool/mailbox/$MAILBOX/inbox") || die "Can not
> find mailbox for " .
> "$MAILBOX.: $! \n";
> my $MessagesSent;
>     while(defined ($letters = readdir BIN)) {
>     next if $letters =~ /^\.\.?$/;
>     next if $letters =~ /[__]/;
>     open(SENDMAIL, "|/usr/lib/sendmail -odg $DESTADD") || die "Can't
> fork for sendmail: $!\n";

>     print SENDMAIL ($letters);   # <----- here's the problem!

At this point what does $letters contain?  Lets see how
it was populated.  You opendir()'d the directory on fh BIN, and 
then you readdir() the fh and assigned the output of readdir() to
$letters.  Well, the output of readdir() is the filename in the
directory, right? (right)  So when you print to the sendmail fh,
you are just printing the filename, not its contents.  

You'll probably want to investigate the use of a nice module
like MIME::Lite, which can take that filename and turn its
contents into an attachment rather easily.


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

Date: Fri, 08 Sep 2000 22:28:52 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: New Perl Tutorial - www.perltutor.com
Message-Id: <slrn8riq12.8ll.tjla@thislove.dyndns.org>

I was shocked! How could Tom Christiansen <tchrist@perl.com>
say such a terrible thing:
>In article <slrn8rhudn.8ll.tjla@thislove.dyndns.org>,
>Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
>>I really think you need to use the '-w' flag for all of your scripts as
>>well as the 'use strict' pragma.  
>
>NB: The "use warnings" pragma is safer and more functional than a
>mere -w.  Why?  Because it's lexically scoped.  That way you don't
>autoenable warnings in separate lexical scopes--read, module
>files--that you don't have control over.

Excellent point.

>Advocate "use warnings" over -w in most cases.  See also the perllexwarn

I don't have that one. Is the name right? It's referenced in the perlrun
manpage but I cannot find it anywhere. I'm running 5.6.0

>manpage and the -W and -X entries in the perlrun manpage.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Yes, but which self do you want to be?


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

Date: Fri, 08 Sep 2000 22:58:23 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: New Perl Tutorial - www.perltutor.com
Message-Id: <x7ya12ij8x.fsf@home.sysarch.com>

>>>>> "GJ" == Gwyn Judd <tjla@guvfybir.qlaqaf.bet> writes:

  >> Advocate "use warnings" over -w in most cases.  See also the perllexwarn

  GJ> I don't have that one. Is the name right? It's referenced in the perlrun
  GJ> manpage but I cannot find it anywhere. I'm running 5.6.0

it's there. check the spelling as it has 2 l's.

but pushing a 5.6 feature now is not a good idea IMO. i would wait until
the next stable release which is aimed at fixing many of 5.6's ills.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 09 Sep 2000 00:42:20 GMT
From: lurker65535@my-deja.com
Subject: Re: New Perl Tutorial - www.perltutor.com
Message-Id: <8pc119$496$1@nnrp1.deja.com>

In article <slrn8rhudn.8ll.tjla@thislove.dyndns.org>,
  tjla@guvfybir.qlaqaf.bet (Gwyn Judd) wrote:
> You have an error in the section on strings. You say the literal
> 'C:\\AUTOEXEC.BAT' is interpolated into C:\AUTOEXEC.BAT which is
clearly
> wrong.
You would think that, but \\ and \' in single-quoted strings are in fact
interpreted.  Other escape sequences are passed through untouched:

print 'C:\\autoexec.bat \' \a';   # C:\autoexec.bat ' \a
print 'C:\autoexec.bat \' \a';    # C:\autoexec.bat ' \a
print '\\\\';                     # \\



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 08 Sep 2000 23:06:12 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: ODBC, OLE, ADO, WTF??
Message-Id: <8pbrcp$tr4$1@nnrp1.deja.com>

In article <39B90E3A.69A2256F@vpservices.com>,
  Jeff Zucker <jeff@vpservices.com> wrote:
> Brendon Caligari wrote:
> >
> > In article <8pa3pl$rce$1@nnrp1.deja.com>,
> >   Brendon Caligari <bcaligari@my-deja.com> wrote:
> > >
> > >
> > > Suppose I have some nice scripts filtering tons of data that has
to be
> > > eventually imported into an table in a MS-Access db.  The problem
as
> > > usual lies as to where to get started!!!
> > >
> > > Any pointing in a right direction is appreciated!!
>
> I suggest you forget ODBC, OLE, and ADO and go straight to the WTF.pm
> module.  It is always better to curse the darkness than light a
candle.
> =)
>
> Actually the answer lies in a different acronym that you didn't
mention:
> DBI, the Perl Database Interface.  It has drivers for ODBC and ADO and
> many other databases.  See
>
>     http://www.symbolstone.org/technology/perl/DBI/
>
> for further details.  If you need many specific M$ things, then you
> should investigate the OLE stuff but if you are doing fairly
> straightforward database type things, then DBI and its friends should
> give you everything you need in a portable format.
>
> --
> Jeff
>

shoukran 'mon

Actually got Win32::ODBC working (something possessed me to try to
configure odbc as file dsn rather than user dsn).  Will stick to that
for the immediate future as all i have to do is update a lame access db
table.  However, "Programming the perl dbi" should be on it's way from
amazon and will be sticking to that, given that (correct me if i'm
wrong) it'll give me a common interface whether i script for unix or
win.

Geez.....I'm ending up with a whole library of perl books.  At least
the o'reilly one are all the same shape and colour :)

Brendon


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 08 Sep 2000 16:36:39 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: ODBC, OLE, ADO, WTF??
Message-Id: <39B97807.463C3BAA@vpservices.com>

Brendon Caligari wrote:

> However, "Programming the perl dbi" should be on it's way from
> amazon and will be sticking to that, given that (correct me if i'm
> wrong) it'll give me a common interface whether i script for unix or
> win.

Yep, that's the idea.

> Geez.....I'm ending up with a whole library of perl books.  At least
> the o'reilly one are all the same shape and colour :)

Not to mention they all have animals on 'em :-)  The Cheetah is a good
one, you'll enjoy it.

-- 
Jeff


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

Date: Sat, 9 Sep 2000 01:29:48 +0100
From: "King Fu" <jon@king-fu.freeserve.co.uk>
Subject: Re: Packet problem
Message-Id: <8pc0p4$7if$1@news6.svr.pol.co.uk>


"Jeff Pinyan" <jeffp@crusoe.net> wrote in message
news:Pine.GSO.4.21.0009081233040.23350-100000@crusoe.crusoe.net...
> On Sep 8, King Fu said:
>
> >But the problem is i dont seem to be able to print 4B properly to the
socket
> >as it gets converted into ascii.
>
> If your problem is you don't know how to print an ASCII character by hex
> value (like printing the character 'a', whose hex value is 61), then do:
>
>   print chr(0x61);  # prints 'a'
>
<snip>

No the problem is i dont know how to print 4B without it being converted
into ascii..if that makes any sense? lol
heres an example of some data from a packet of what i want todo which might
help:

0030:  21 80 6D 87 00 00 48 54 54 50 2F 31 2E 30 20 33    !.m...HTTP/1.0 3

                               ^^^^^
how would i print the two 00 00 hex values? or any for that matter?


>
> --
> Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
> PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
> The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
> CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/
>




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

Date: Fri, 08 Sep 2000 22:33:01 GMT
From: andkovacs@my-deja.com
Subject: Re: Perl & https & proxy
Message-Id: <8pbpes$ron$1@nnrp1.deja.com>

 .
In article <8pb9dp$7pm$1@nnrp1.deja.com>,
  andras_kovacs2@non.agilent.com wrote:
> Hi,
>
> I have to use a proxy server to access the outside world.
> My proxy has an address like : http://proxy.koko.com:6000
>
> The web site that I want to access is an https:
> https://www.koko.com
>
> When I try to connect from perl to this "https" site perl uses
> the "http" scheme instead of the "https" because of the proxy server.
>
> This setting is defined in LWP::UserAgent->simple_request()
>
>     # Locate protocol to use
>     my $scheme = '';
>     my $proxy = $self->_need_proxy($url);
>     if (defined $proxy) {
> 	$scheme = $proxy->scheme;
>     } else {
> 	$scheme = $url->scheme;
>     }
>
> Is there a workaround to open a socket on my http proxy then
> keep this socket open and send through https request encoded ?
>
> Thanks
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 08 Sep 2000 22:51:48 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: Perl script hogging memory on IRIX 6
Message-Id: <8pbqht$sri$1@nnrp1.deja.com>

In article <8pbihu$kbn$1@sws1.ctd.ornl.gov>,
  "Barry Westaway" <bw2@nospam.y12.doe.gov> wrote:
>
> I have written a Perl script that normally operates in 12 - 30 MB of
> memory on an SGI Irix 6.X system.  It run like this for weeks at a
time.
> On rare occasions it will go berzerk and start gobbling up memory.
> Eventually, IRIX provides all memory and swap  to the script and then
the
> system crashes.  I get a nasty phone call.
>
> I could probably add a few undefs to give back some relatively large
> chunks of memory (100 - 600K), but othet that that I don't know what
to do
> to restrict memory usage.
>
> Any suggestions or hypothesis would be apreciated.
>
> Thanks.
>
>

Since trying to learn perl a couple of months ago I have put together
some scripts that, as in your case, are running round the clock (e-mail
gateways).  To avoid having such problems I started killing the
programme and restarting it every few hours (automatically of course :)

Brendon


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 08 Sep 2000 23:01:08 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: Perl script hogging memory on IRIX 6
Message-Id: <Uceu5.31$W3.170617344@news.frii.net>

In article <8pbihu$kbn$1@sws1.ctd.ornl.gov>,
Barry Westaway <bw2@nospam.y12.doe.gov> wrote:
>
>I have written a Perl script that normally operates in 12 - 30 MB of
>memory on an SGI Irix 6.X system.  It run like this for weeks at a time. 
>On rare occasions it will go berzerk and start gobbling up memory. 
>Eventually, IRIX provides all memory and swap  to the script and then the
>system crashes.  I get a nasty phone call.
>
>I could probably add a few undefs to give back some relatively large
>chunks of memory (100 - 600K), but othet that that I don't know what to do
>to restrict memory usage.
>
>Any suggestions or hypothesis would be apreciated.
>
>Thanks.
>

If you can't find where the memory is being sucked up, and you need a
pragmatic solution. Then try "re-exec-ing" the program periodically.

chris
-- 
    chris fedde
    303 773 9134


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

Date: 08 Sep 2000 22:21:29 GMT
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Regular Expressions
Message-Id: <39B963FF.F39DB1BD@attglobal.net>

armstrongc@my-deja.com wrote:
> 
> I hope someone can give me some help with a reqular expression problem.
> 
> Here is my Text:
> 
> Testing stuff <BDI.delimited.catalog.ETOWN@redknife.net>
> or
> Testing stuff "BDI.delimited.catalog.ETOWN@redknife.net"
> or
> Testing stuff 'BDI.delimited.catalog.ETOWN@redknife.net'
> 
> I want to just be able to pull out
> BDI.delimited.catalog.ETOWN@redknife.net

Perlfaq 6 has an entry that will get you started on the right path.

http://www.perl.com/pub/doc/manual/html/pod/perlfaq6.html
(see the bit on removing C style comments from a file, its 
similar in spirit to what you want to do)

Your task, should you choose to accept it, is to find a delimiting
charachter, then capture anything that is not a delimiter, and then
finally match the ending delimiter.  Easy if the delimiter can not 
exist within the text you want to grab, harder if it can.  (unless 
you are constraining the input, both a <> and a "" pair can appear 
in an email address, making this potentially more difficult.


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

Date: Fri, 8 Sep 2000 15:27:43 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regular Expressions
Message-Id: <MPG.142307bef60e9aa298ad4b@nntp.hpl.hp.com>

In article <8pbn20$oqv$1@nnrp1.deja.com> on Fri, 08 Sep 2000 21:52:09 
GMT, armstrongc@my-deja.com <armstrongc@my-deja.com> says...
> I hope someone can give me some help with a reqular expression problem.
> 
> Here is my Text:
> 
> Testing stuff <BDI.delimited.catalog.ETOWN@redknife.net>
> or
> Testing stuff "BDI.delimited.catalog.ETOWN@redknife.net"
> or
> Testing stuff 'BDI.delimited.catalog.ETOWN@redknife.net'
> 
> I want to just be able to pull out
> BDI.delimited.catalog.ETOWN@redknife.net
> 
> The address can change so I cannot depend on counting chars at the
> begining.

    /([<"'])(.*?)\1/ and print $2;

Explanation of regex:

    /
     ([<"'])  # Capture one of the delimiting characters in $1.
     (.*?)    # Capture in $2 the sortest sequence of characters that
     \1       #    end before the same delimiting character.
    /x        # Add /s modifier if it can span more than one line.

> Thanks for the Help.

You're welcome.   Now read perlre a few times.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 08 Sep 2000 22:36:20 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Regular Expressions
Message-Id: <slrn8riqd9.b1k.abigail@alexandra.foad.org>

Drew Simonis (care227@attglobal.net) wrote on MMDLXV September MCMXCIII
in <URL:news:39B963FF.F39DB1BD@attglobal.net>:
__ armstrongc@my-deja.com wrote:
__ > 
__ > I hope someone can give me some help with a reqular expression problem.
__ > 
__ > Here is my Text:
__ > 
__ > Testing stuff <BDI.delimited.catalog.ETOWN@redknife.net>
__ > or
__ > Testing stuff "BDI.delimited.catalog.ETOWN@redknife.net"
__ > or
__ > Testing stuff 'BDI.delimited.catalog.ETOWN@redknife.net'
__ > 
__ > I want to just be able to pull out
__ > BDI.delimited.catalog.ETOWN@redknife.net
__ 
__ Perlfaq 6 has an entry that will get you started on the right path.
__ 
__ http://www.perl.com/pub/doc/manual/html/pod/perlfaq6.html
__ (see the bit on removing C style comments from a file, its 
__ similar in spirit to what you want to do)
__ 
__ Your task, should you choose to accept it, is to find a delimiting
__ charachter, then capture anything that is not a delimiter, and then
__ finally match the ending delimiter.  Easy if the delimiter can not 
__ exist within the text you want to grab, harder if it can.  (unless 
__ you are constraining the input, both a <> and a "" pair can appear 
__ in an email address, making this potentially more difficult.


*ANY* character can appear in an email address.

    \<@example.com

is a valid address.



Abigail
-- 
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
 |perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
 |perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
 |perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;


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

Date: Fri, 08 Sep 2000 22:43:45 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: Regular Expressions
Message-Id: <8pbq2t$se3$1@nnrp1.deja.com>

In article <8pbn20$oqv$1@nnrp1.deja.com>,
  armstrongc@my-deja.com wrote:
> I hope someone can give me some help with a reqular expression
problem.
>
> Here is my Text:
>
> Testing stuff <BDI.delimited.catalog.ETOWN@redknife.net>
> or
> Testing stuff "BDI.delimited.catalog.ETOWN@redknife.net"
> or
> Testing stuff 'BDI.delimited.catalog.ETOWN@redknife.net'
>
> I want to just be able to pull out
> BDI.delimited.catalog.ETOWN@redknife.net
>
> The address can change so I cannot depend on counting chars at the
> begining.
>
> Thanks for the Help.

quick and dirty:
   m/\b([\w\.]+\@[\w\.]+)\b/ && print("Found: $1\n");

Brendon



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 08 Sep 2000 23:28:22 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Regular Expressions
Message-Id: <39B97569.BAE15B02@netstorm.net>

Larry Rosler wrote:
> 
> In article <8pbn20$oqv$1@nnrp1.deja.com> on Fri, 08 Sep 2000 21:52:09
> GMT, armstrongc@my-deja.com <armstrongc@my-deja.com> says...
> > I hope someone can give me some help with a reqular expression problem.
> >
> > Here is my Text:
> >
> > Testing stuff <BDI.delimited.catalog.ETOWN@redknife.net>
> > or
> > Testing stuff "BDI.delimited.catalog.ETOWN@redknife.net"
> > or
> > Testing stuff 'BDI.delimited.catalog.ETOWN@redknife.net'
> >
> > I want to just be able to pull out
> > BDI.delimited.catalog.ETOWN@redknife.net
> >
> > The address can change so I cannot depend on counting chars at the
> > begining.
> 
>     /([<"'])(.*?)\1/ and print $2;
> 
But that won't catch <blah>.  Probably better as:

/[<"'](.*)[>"']/ and print $1;

-- Jim


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

Date: 08 Sep 2000 23:41:13 GMT
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Regular Expressions
Message-Id: <39B976B0.C53C87B0@attglobal.net>

Abigail wrote:
> 
> Drew Simonis (care227@attglobal.net) wrote on MMDLXV September MCMXCIII
> __ Your task, should you choose to accept it, is to find a delimiting
> __ charachter, then capture anything that is not a delimiter, and then
> __ finally match the ending delimiter.  Easy if the delimiter can not
> __ exist within the text you want to grab, harder if it can.  (unless
> __ you are constraining the input, both a <> and a "" pair can appear
> __ in an email address, making this potentially more difficult.
> 
> *ANY* character can appear in an email address.
> 
>     \<@example.com
> 
> is a valid address.

I see your point.  I was making an example using two of the delimiters 
the OP specified, but perhaps I should have been more cautious with 
my choice of words.


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

Date: Sat, 09 Sep 2000 02:09:31 +0100
From: "Dietmar Staab" <dietmar.staab@t-online.de>
Subject: Re: Regular Expressions
Message-Id: <8pbv2v$4c7$17$1@news.t-online.com>

In article <MPG.142307bef60e9aa298ad4b@nntp.hpl.hp.com>, Larry Rosler
<lr@hpl.hp.com> wrote:

>     /([<"'])(.*?)\1/ and print $2;

Doesn't work, because left and right delimiter are not equal for <>

/(["'<])(.*?)[\1>]/ and print $2;

should fix it.

D.


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

Date: Sat, 09 Sep 2000 02:16:29 +0100
From: "Dietmar Staab" <dietmar.staab@t-online.de>
Subject: Re: Regular Expressions
Message-Id: <8pbvg1$4dd$17$1@news.t-online.com>

In article <8pbv2v$4c7$17$1@news.t-online.com>, "Dietmar Staab"
<dietmar.staab@t-online.de> wrote:
> In article <MPG.142307bef60e9aa298ad4b@nntp.hpl.hp.com>, Larry Rosler
> <lr@hpl.hp.com> wrote:
> 
>>     /([<"'])(.*?)\1/ and print $2;
> 
> Doesn't work, because left and right delimiter are not equal for <>
> 
> /(["'<])(.*?)[\1>]/ and print $2;
> 
> should fix it.

Not yet. If the string contains a "<"; better match the delimiter twice
without using \1

D.



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

Date: 09 Sep 2000 00:52:26 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Regular Expressions
Message-Id: <slrn8rj2cf.b1k.abigail@alexandra.foad.org>

Dietmar Staab (dietmar.staab@t-online.de) wrote on MMDLXVI September
MCMXCIII in <URL:news:8pbv2v$4c7$17$1@news.t-online.com>:
() In article <MPG.142307bef60e9aa298ad4b@nntp.hpl.hp.com>, Larry Rosler
() <lr@hpl.hp.com> wrote:
() 
() >     /([<"'])(.*?)\1/ and print $2;
() 
() Doesn't work, because left and right delimiter are not equal for <>
() 
() /(["'<])(.*?)[\1>]/ and print $2;
() 
() should fix it.


Not really.

    #!/opt/perl/bin/perl -wl
    $_ = "'foo>bar'";
    /(["'<])(.*?)[\1>]/ and print $2;
    __END__
    foo


Abigail
-- 
perl -wle 'eval {die ["Just another Perl Hacker"]}; print ${${@}}[$#{@{${@}}}]'
#    A kitty near the
#    Emperor's palace. A mosquito
#    flies. A bee.


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

Date: Fri, 08 Sep 2000 17:30:31 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Scoping of symbolic references (variables)
Message-Id: <39B96887.D1193FFC@texas.net>

Mark-Jason Dominus wrote:
> 
> In article <39B91250.CAA6E522@texas.net>, Tom Briles  <sariq@texas.net> wrote:
> >> Again, any insight woould be greatly appreciated.
> >
> >Read:
> >
> >http://www.plover.com/~mjd/perl/varvarname.html
> 
> I think it might be more instructive to read
> 
>   http://www.plover.com/~mjd/perl/FAQs/namespaces.html
> 
> in this case.

That's:

http://www.plover.com/~mjd/perl/FAQs/Namespaces.html

And it's a terrific explanation of Perl's namespace issues.

And thanks again for your contributions!

- Tom


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

Date: Fri, 08 Sep 2000 22:49:59 GMT
From: Joe Johnston <jjohn@cs.umb.edu>
Subject: Re: Simple Question
Message-Id: <39B96D0E.A923ED8F@cs.umb.edu>

Akira Kiyomiya wrote:
> 
> Could someone explain why this results in  3: 0 8 22 in dummy's language?
> I am a little bit confused ...

Let's untangle this beastie.

> $string = 'foo bar foo blah quux foo';
> my @pos   = find_strings($string, 'foo');
> my $count = find_strings($string, 'foo');
> print "$count: @pos\n";     # prints: 3: 0 8 22

Let's start with the print statement. 

We've got a double quoted string, which means
Perl will try to interpolate any variables found
inside. We've got a scalar and an array. 
The scalar has the value '3' (we'll get to 
why it does in a second). Perl simply prints this
value out. Next we have an array with three elements 
(0, 8, 22). Perl will print out the values of the 
array separated by whatever you've got in $" 
($LIST_SEPARATOR). The default value for this special 
global variable is a space. (man pervar for more)

Now, you might be wondering where those values came 
from. We called the same function twice with the 
same arguments but got back two different answers.
What's going on here?

The answer is context. 

Perl functions are aware of the context in which 
they are called. Context is determined by what 
the function returns to. The first call to find_strings()
is called in list context because we are assigning to 
an array. The second is in scalar context because we 
are assigning to a scalar. Look at these examples:

$i   = localtime; # produces an pretty ASCII string of 
		  # your local date

($i) = localtime; # gets the first value of the 9 element
		  # list, seconds 

If the second example throws you, think of it as 
a simple list assignment like this:

($a, $b) = ('apples', 'oranges', 'bananas'); # 'Bananas' goes
                                             # bye-bye

Inside a user defined function, Perl's 'wantarray' 
operator will return true if function will be 
returning to a list context - like an array 
assignment. 

On to the actual function.

>     sub find_strings {
>         my($string, $substr, $offset) = @_;
>         $offset ||= 0;  # what is ||??
>         my @positions;
>         my $ind;
>         while(($ind = index($string, $substr, $offset)) >= 0){
>             push @positions, $ind;
>             $offset = $ind + 1;
>         }
>         if ( wantarray() ) {
>             return @positions;
>         } elsif ( defined(wantarray()) ) {
>             return scalar @positions;
>         } else {
>             return;
>         }
>     }

After the sub routine declaration, we want to 
assign the arguments found in @_ into lexical 
variables. The next line is setting a default 
value for $offset, in case the user did not. 
This "or-equals" operator sometimes goes by the 
cute name "orcish" which is a play on 
"or cached". Let's write this assignment another 
way:

$offset = $offset || 0; 

If $offset as a true value already ("cached", get it?), 
use it. Otherwise make sure it is set to a known
value.

The next two lines set up two lexicals.

The while's condition uses the often forgotten
'index' operator, which scans $string for 
the leftmost instance of $substr, starting 
$offset characters into $string. If such 
a substring is found, 'index' returns the 
offset at which the substring occurs. If no
occurrence is found, -1 is returned (assuming
$[ is 0 which is as the Almighty intended).

Since we can only execute the body of the loop
if the substring is found, we stuff the 
offset of where the substring was found into 
our @positions array and increment the $offset
variable so that we don't find the same substring
again on our next trip through the loop.

Once we have fallen out of the loop, we need
to figure out how to return this information.
Perldoc and Camel say only that 'wantarray'
returns true if the calling context is list.
The actual return *of* wantarray isn't known 
to me. Clearly, the intent of this code is to 
show how wantarray works. I suggest this would be 
a more standard way to write this example:

if( wantarray ){
   return @positions;
}else{
   return scalar @positions;
}

But here's the kicker. You don't need wantarray
at all! Remember, Perl already treats arrays 
differently for list and scalar contexts. 
In scalar context, arrays return the number of 
elements in them. In list context, the array's
contents are return. 

Armed with this truth, let's rewrite the return
this way:

return @positions;

Perl. Simplifying your life to make more beer time.

But I'm feeling empty. You want to be able to 
use 'wantarray' responsibly, just like localtime().
Let's make this function return sometime special 
in scalar context.

I suggest something like the following:

if( wantarray ){
   return @positions;
else{
   return "Found " . @positions;
}  

The concatenate operator works on scalars. 
The array is in scalar context. Any guesses 
as to what the output is going to be?

Hope this helps. 

-- 
----------------
Joe Johnston
http://aliensaliensaliens.com


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

Date: Fri, 08 Sep 2000 17:22:33 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: The Heartbreak of Inscrutable Perl Code
Message-Id: <39B966A9.950104A1@texas.net>

"Christopher M. Jones" wrote:
> 
> "avast" <avast@hortonsbay.com> wrote:
> 
> > my @fields = split /,\s+/ => $fields;
> 
> Quite simple actually.  First, you need to realize that => is
> nothing special.  It's just a dressed up , (comma) and nothing
> more.

Not true.

perldoc perlop

- Tom


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

Date: Fri, 8 Sep 2000 15:55:09 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: The Heartbreak of Inscrutable Perl Code
Message-Id: <a7eu5.1201$QB6.252472@news.uswest.net>


"Tom Briles" <sariq@texas.net> wrote:
> "Christopher M. Jones" wrote:

> > Quite simple actually.  First, you need to realize that => is
> > nothing special.  It's just a dressed up , (comma) and nothing
> > more.
>
> Not true.
>
> perldoc perlop

It's _mostly_ true.

It has a few other nifty convenience functions but nothing
overly special.




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

Date: Fri, 8 Sep 2000 15:08:45 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: use strict: why?
Message-Id: <Brdu5.1179$QB6.235193@news.uswest.net>


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> "...exactly the same ... only difference is...."
>
> Yeah, ok, sure, whatever toots your Tootsie Roll.

If it looks like a duck, quakcs like a duck, waddles
like a duck, flies like a duck, but has a slightly
different colored beak, it's still a duck.  It's
just a slightly different _kind_ of duck.

> So, declare a local variable within a sub routine and
> try to use it later as a global. They are not 'exactly'
> the same, actually quite different, yes?
>
> * toots her Oscar Myer Weenie Whistle *

$blah = "something";

    {
    local $blah = "something else";
    function();
    }

sub function
    {
    print $blah;
    }

It prints "something else", not something.  This is
because local functions like a global.

> So cute! Have you ever thought about this symbology
> of Oscar Myer riding, straddled upon top his
> huge Weenie Mobile, during a public parade?

How long has it been since your medication ran out?


P.S. Don't substitute crack for your regular medication,
they are _not_ the same thing.




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

Date: Fri, 08 Sep 2000 22:13:44 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: use strict: why?
Message-Id: <auoirsgca3drnqa5368r6oi87ca1mkbccf@4ax.com>

Godzilla! wrote:

>"In summary: it's the same variable. Therefore, it is a global variable."

Yes.

You seem to misunderstand what local() does. It's something like this:

	{	
		local $x = "temp";
		print $x;
	}

is functionally equivalent to:

	{
		my $saved = $x;
		{
			$x = "temp";
			print $x;
		}
		$x = $saved;
	}

If $x is a global variable outside the block, then it is a global
variable *inside* the block as well, because it is the SAME VARIABLE!

"local" is a poor choice of words. "temporary" would have been better.

-- 
	Bart.


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

Date: Fri, 08 Sep 2000 22:17:12 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: use strict: why?
Message-Id: <r8pirsoe8lm9u6kujq701c126n3g6c7d1q@4ax.com>

Godzilla! wrote:

>Why do you even bother to try this type of mule manure
>with me, of all people?

So evberything you feel to understand is "mule manure". You surely see a
lot more mule manure here than anybody else does. Could it be just you?

"I have my eyes closed, so now it is dark."

-- 
	Bart.


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

Date: Fri, 08 Sep 2000 15:40:04 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: use strict: why?
Message-Id: <39B96AC4.B37EEB6@stomp.stomp.tokyo>

Bart Lateur wrote:
 
> Godzilla! wrote:
 
> You seem to misunderstand what local() does. 

Actually, I seem to understand this distinct
difference between global and local better
than anyone in this group, except Randal
and perhaps Mr. Berry.

>It's something like this:

No, same variable name, different
variable value. What was a drake,
becomes a transvestite ugly duckling,
then, steps back into his closet only
to become a drake again.

You boys are trying to equate values
with being the same thing. They are
not. Same variable name, different goose,
in punny way.


> If $x is a global variable outside the block, 
> then it is a global variable *inside* the block 
> as well, because it is the SAME VARIABLE!

If Mr. X is not a jailbird outside the gray bar hotel,
Mr. X is a jailbird inside the gray bar hotel,
and Mr. X is no longer a jailbird back outside again.

Same name, different Birdman.

Global and Local, are not the same. Each
has a specific value, presumably, not equal
to each other. 

Again, you boys are confusing a function with
a variable name. Unimportant what name a variable
carries. Important what a function does to this
variable, regardless of name. Switching from
global to local is a function allowing the same
variable name to be used for different values,
hopefully to resume its original value later.

 
> "local" is a poor choice of words. 
> "temporary" would have been better.

Local is a logical choice for this function name.
I want to do something locally then go back to
where I was before.

You think you boys have whipped this dead horse enough?


Godzilla!
-- 
Bark Bent - Ace News Reporter
  http://la.znet.com/~callgirl/android/news.cgi


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

Date: Fri, 08 Sep 2000 23:26:39 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: use strict: why?
Message-Id: <i8tirssuielmoo33a1uhs404jvee8fncjq@4ax.com>

Godzilla! wrote:

>No, same variable name, different
>variable value.

It's not just the same variable NAME, it is the same variable.

Try this, and try explain how this can be a different hash which just
happens to have the same name.

    use Data::Dumper;
    %hash = ( a => 'alfa', b => 'beta', c => 'nada' );
    print Dumper \%hash;
    {
	local $hash{c} = 'temporarily replaced';
	$hash{d} = 'delta';
	print Dumper \%hash;
    }
    print Dumper \%hash;

-->

$VAR1 = {
          'a' => 'alfa',
          'b' => 'beta',
          'c' => 'nada'
        };
$VAR1 = {
          'a' => 'alfa',
          'b' => 'beta',
          'c' => 'temporarily replaced',
          'd' => 'delta'
        };
$VAR1 = {
          'a' => 'alfa',
          'b' => 'beta',
          'c' => 'nada',
          'd' => 'delta'
        };

-- 
	Bart.


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

Date: Sat, 09 Sep 2000 00:00:59 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: use strict: why?
Message-Id: <slrn8rivdo.8ll.tjla@thislove.dyndns.org>

I was shocked! How could Tom Christiansen <tchrist@perl.com>
say such a terrible thing:
>In article <Mv8u5.16028$AW2.204613@news1.rdc2.pa.home.com>,
>Ben Kennedy <bkennedy99@home.com> wrote:
>
>>local() only alters the value of
>>a global variable, the variable continues to be in the sybmol table and
>>globally accessable.
>
>Usually, that's true enough as it goes, but nevertheless represents--shall
>we say--a "simplified" version of reality.
>
>To see what I mean, please consider:
>
>    use strict;
>    use warnings;
>
>    our          @word = qw/who knows what evil lurks in the heart of perl/;
>    { 
>        my       @word = qw/do you see what I see/;
>        local    @word[2,-1] = ("know") x 2;

interesting...if we make it:

         local   @word = ("blah");

we get:

         Can't localize lexical variable @word at - line 4.

but it works with the array slice...hmmm...does that mean the my
variable is lexical in scope but the array elements get listed in the
symbol table?

>        print "\u@word?\n";
>    }
>    print     "\u@word?\n";
>
>Just to give you a thing or three to think about. :-)
>
>--tom


-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
A man in love is incomplete until he is married. Then he is finished.
-Zsa Zsa Gabor, "Newsweek"


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

Date: Fri, 08 Sep 2000 23:20:36 GMT
From: darlenewong@my-deja.com
Subject: Re: using unix commands within perl script
Message-Id: <8pbs7j$uqn$1@nnrp1.deja.com>

Hi Emma,

I'm having the same problem you had last week...did you ever find a
solution?
I am running scripts from within a Perl/CGI script.  Like you, I have
tried all types of quotes.  Like your command, mine works fine from the
command line and fails to execute from within the CGI script.  I don't
get syntax errors, just no return string.  Using system("COMMAND") I get
a return value of "65280".

Thanks,
Darlene

In article <8opbk0$2od$1@news.swissonline.ch>,
  "Johan Brattemark" <johan.brattemark@net2000.ch> wrote:
>
> "Emma Stoten" <E.L.Stoten@ncl.ac.uk> wrote in message
> news:39AFC0CD.4243F90@ncl.ac.uk...
> > I'm trying to use a unix command within a perl script:
> >
> > system(`COMMAND`);
> >
> > I've tried using all three types of quotes, and still it doesn't
work
> > when executed. The command works at the command line and -c and -w
> > options don't shed any light.
> >
> > I've exhausted all other lines of enquiry and hope someone can offer
> > some advice.
> >
> > Cheers,
> > Emma Stoten
>
> I think you should user either
> $now = `COMMAND`;
> or
> system("COMMAND")
>
> Johan
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 08 Sep 2000 22:25:38 GMT
From: bing-du@tamu.edu
Subject: why on earth can't locate
Message-Id: <8pbp0d$r62$1@nnrp1.deja.com>

Greetings all--

Our system administrator installed DBD::Oracle and DBI in
/usr/freeware/lib/perl5/site_perl/5.005/irix-64.

The first 5 lines in my Perl script test.pl look like this:

=======================
#!/usr/local/bin/perl

use lib '/usr/freeware/lib/perl5/site_perl/5.005/irix-64';

use DBD::Oracle;
use DBI;
=======================

Why did I get the following 'Can't locate' message when I run the
script?

me@machine:~/tmp % ./test.pl
Can't locate loadable object for module DBD::Oracle in @INC (@INC
contains: /usr/freeware/lib/perl5/site_perl/5.005/irix-64
/usr/share/lib/perl5/irix-n32/5.00404 /usr/share/lib/perl5
/usr/share/lib/perl5/site_perl/irix-n32 /usr/share/lib/perl5/site_perl
/usr/share/lib/perl5/sgi_perl .) at ./test.pl line 5
BEGIN failed--compilation aborted at ./test.pl line 5

Any help would be greatly appreciated.

Bing


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 08 Sep 2000 23:42:01 GMT
From: saravanansrivai@my-deja.com
Subject: Win32::AuthenticateUser is working ?
Message-Id: <8pbtg5$6l$1@nnrp1.deja.com>

Try this code and worked fine for me.

use Win32::AuthenticateUser;
$domain="mad1";
$user="smalaiax";
$password="";

if (AuthenticateUser("$domain,"$user", "$password")) {
	print "Valid user\n";
} else {
	print "InValid user\n";
}

Note that 6th line and u don't use win32::AuthenticateUser

Thanx.
Saravanan Malaiappan
Intel Media Services
503-696-0149
saravananx.malaiappan@intel.com




Sent via Deja.com http://www.deja.com/
Before you buy.


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

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


Administrivia:

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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 4268
**************************************


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