[24408] in Perl-Users-Digest
Perl-Users Digest, Issue: 6596 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 22 00:05:49 2004
Date: Fri, 21 May 2004 21:05:06 -0700 (PDT)
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, 21 May 2004 Volume: 10 Number: 6596
Today's topics:
Re: 2-1/2 regexp questions <nomail_please@nomail.org>
Re: 2-1/2 regexp questions <tadmc@augustmail.com>
Re: advice on backing up a DB from server? (dan baker)
Re: advice on backing up a DB from server? <glex_nospam@qwest.invalid>
Re: advice on backing up a DB from server? <usenet@morrow.me.uk>
Re: advice on backing up a DB from server? <gnari@simnet.is>
Re: advice on backing up a DB from server? <nospam@bigpond.com>
Re: advice on backing up a DB from server? <nospam@bigpond.com>
Re: How to pass input from perl to shell programming? <nospam@bigpond.com>
Re: Password scheme/Persistent session... (krakle)
Re: Password scheme/Persistent session... (krakle)
Re: Password scheme/Persistent session... <jurgenex@hotmail.com>
Re: perl tcp server script works, but no data. (Eli Sidwell)
Re: perl tcp server script works, but no data. <usenet@morrow.me.uk>
Re: Perl vs PHP <dha@panix2.panix.com>
Re: Perl vs PHP <jurgenex@hotmail.com>
Re: Perl vs PHP (Randal L. Schwartz)
Re: Perl vs PHP <tadmc@augustmail.com>
Re: Perl vs PHP <tadmc@augustmail.com>
Re: Problem installing modules <tpsX@vr-web.de>
Re: Problem installing modules <glex_nospam@qwest.invalid>
Re: rmdir Question <tadmc@augustmail.com>
Re: Sockets: receiving data <usenet@morrow.me.uk>
Re: String search/match question <tore@aursand.no>
Re: String search/match question <matthew.garrish@sympatico.ca>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 22 May 2004 01:07:37 +0000 (UTC)
From: Irving Kimura <nomail_please@nomail.org>
Subject: Re: 2-1/2 regexp questions
Message-Id: <c8m94p$p16$1@reader2.panix.com>
In <slrncaskp3.ct.abigail@alexandra.abigail.nl> Abigail <abigail@abigail.nl> writes:
> my $re = qr /($r)(?{print "(", $- [-1], ", ", $+ [-1] - $- [-1], ")",
> " --> '$^N'\n"})(?!)/;
I assume that "$- [-1]" and "$+ [-1]" refer to elements of some
special arrays @- and @+ , but I have not been able to find anything
on these arrays by grepping through the online documentation.
Where in the Perl documentation are @- and @+ explained?
Thanks!
Irv
------------------------------
Date: Fri, 21 May 2004 21:16:57 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: 2-1/2 regexp questions
Message-Id: <slrncate0p.33r.tadmc@magna.augustmail.com>
Irving Kimura <nomail_please@nomail.org> wrote:
> Where in the Perl documentation are @- and @+ explained?
Perl's var_iables are documented in:
perldoc perlvar
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 21 May 2004 15:19:56 -0700
From: botfood@yahoo.com (dan baker)
Subject: Re: advice on backing up a DB from server?
Message-Id: <13685ef8.0405211419.21f75e84@posting.google.com>
...just to clarify, I would like comments on whether it will be easier
to build a script on my local computer to "pull" specific files from a
remote host, or if it is possible to run a cron job on the remote host
to "push" the files to my computer (assuming I am connected to the
internet.)
currently it looks like it may be easiest to code a little routine to
GET the files, probably using Net::FTP . Or, do I need to use
Win32::Internet module since I would be running the script from a PC
running Windows98 ?
The second part of this is how do I do a "cron-like" wrapper that
would fire up the transfer in the middle of the night automatically?
What module would I use to do something like this on a PC running
Windows98 ?
thanks,
d
------------------------------
Date: Fri, 21 May 2004 17:40:17 -0500
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: advice on backing up a DB from server?
Message-Id: <lzvrc.404$G47.58602@news.uswest.net>
dan baker wrote:
> My question IS: what might be the simplest, easiest perl
> module [that allows me] to copy a file from a remote server to my local computer.
Had you simply asked that question you may have received more helpful
advice. Also, before asking, download a module and try it. If you have
questions or problems, post the code. All you trying to do is copy a
file, it's trivial no matter what module you use. It could also be an
even simpler shell script.
To answer your question. It doesn't have anything to do with perl, it
really depends on what Protocol your servers support or have running.
Use what you know, like, or have available. Since we don't know that,
it's not possible to answer.
If you're familiar with FTP, and your servers are running FTP, then by
all means use Net::FTP, if you want something secure, use scp and
Net::SCP. If you like using some other Protocol, then use it.
It's better to pull the information, that way you can have one script to
contol how and when and can also handle errors more easily.
------------------------------
Date: Fri, 21 May 2004 23:48:57 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: advice on backing up a DB from server?
Message-Id: <c8m4h9$r5p$2@wisteria.csv.warwick.ac.uk>
Quoth botfood@yahoo.com (dan baker):
> ...just to clarify, I would like comments on whether it will be easier
> to build a script on my local computer to "pull" specific files from a
> remote host, or if it is possible to run a cron job on the remote host
> to "push" the files to my computer (assuming I am connected to the
> internet.)
That is likely to be tricky with no static IP, unless you register with
dyndns.org or whatever.
> currently it looks like it may be easiest to code a little routine to
> GET the files, probably using Net::FTP . Or, do I need to use
> Win32::Internet module since I would be running the script from a PC
> running Windows98 ?
Net::FTP and LWP both work perfectly well under Win32. I would imagine
you'll find LWP easier to use.
> The second part of this is how do I do a "cron-like" wrapper that
> would fire up the transfer in the middle of the night automatically?
> What module would I use to do something like this on a PC running
> Windows98 ?
You would use Windows' Scheduled Tasks.
Ben
--
Outside of a dog, a book is a man's best friend.
Inside of a dog, it's too dark to read.
ben@morrow.me.uk Groucho Marx
------------------------------
Date: Fri, 21 May 2004 23:04:46 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: advice on backing up a DB from server?
Message-Id: <c8m1rh$722$1@news.simnet.is>
"dan baker" <botfood@yahoo.com> wrote in message
news:13685ef8.0405211419.21f75e84@posting.google.com...
> ...just to clarify, I would like comments on whether it will be easier
> to build a script on my local computer to "pull" specific files from a
> remote host, or if it is possible to run a cron job on the remote host
> to "push" the files to my computer (assuming I am connected to the
> internet.)
have a cron job on remote server backup your files with tar
if push is an option, just have your cron job do that too. my
preference is to use scp
if push is not an option, just pull the prepared backup at
your leisure.
gnari
------------------------------
Date: Sat, 22 May 2004 10:47:41 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: advice on backing up a DB from server?
Message-Id: <4034831.AcykxfoekY@GMT-hosting-and-pickle-farming>
dan baker wrote:
> I have a small database on a remote webserver that I would like to
> back up daily. The host does NOT make backups, except by special
> request and extra fees. I was thinking I could mirror either to my
> localhost, or mail it to myself via email, or something... I would
> appreciate some feedback as to what a good approach might be.
>
> The host I use does allow the configuration of cron jobs, so I could
> write a little perl script to fire up nightly on the remote host. I
> just don't know what the easiet/best approach might be, or what
> modules might make this a slam dunk.
>
> I do have a localhost running at home that I use for testing, but I
> dont know if it is possible to mirror file(s) from a domain on the web
> to my localhost? I don't have a fixed IP, it is dynamically assigned
> from my ISP.
Irrelevant.
>
> I was thinking about the email approach, but wasn't sure what the
> easiest way would be to attach the DB as a binary attachment and send
> it to myself. Is this a decent way to go? The database is fairly small
> (about 1MB), and doesnt get any activity at night.
>
> d
I have numerous database enabled sites.
My advice (after many years doing this) is:
1. Get a VPN linux server, running user mode linux. I use www.linode.com
This gives you full root access.
2. Run your favourite database backup utility provided by your DBMS,
preferably that writes data as as ASCII file.
4. run rsync to copy the backed up database to another machine
gtoomey
------------------------------
Date: Sat, 22 May 2004 10:49:02 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: advice on backing up a DB from server?
Message-Id: <2395417.sM6O2XGDlO@GMT-hosting-and-pickle-farming>
dan baker wrote:
> ...just to clarify, I would like comments on whether it will be easier
> to build a script on my local computer to "pull" specific files from a
> remote host, or if it is possible to run a cron job on the remote host
> to "push" the files to my computer (assuming I am connected to the
> internet.)
Use rsync - its a one liner.
gtoomey
------------------------------
Date: Sat, 22 May 2004 10:42:16 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: How to pass input from perl to shell programming?
Message-Id: <8697113.VjxxpfgKjI@GMT-hosting-and-pickle-farming>
Swamy wrote:
> I have a perl program which executes a shell program using system
> call. This shell program needs user input for several questions it
> asks. How can I automate the user input so that user don't have to key
> in the input?
>
> thanks
> Swamy
The easiest way MAY be:
open(FH, "| command.sh") || die "can't run command.sh: $!";
print FH "stuff\n";
close(FH)
Otherwise use expect.
gtoomey
------------------------------
Date: 21 May 2004 17:42:43 -0700
From: krakle@visto.com (krakle)
Subject: Re: Password scheme/Persistent session...
Message-Id: <237aaff8.0405211642.5161c745@posting.google.com>
"John W. Kennedy" <jwkenne@attglobal.net> wrote in message news:<G0rrc.9423$cz5.1816627@news4.srv.hcvlny.cv.net>...
> We understand perfectly. You are asking a question about how the web
> works in a Perl group.
OR I asked how can you mantain state in Perl to make a session with
out the use of cookies. That's not a question asking how the web
works. It's a Perl question. To say such a thing just proves your
ignorance after I repeatedly asked the question. Wow...unbelievable.
------------------------------
Date: 21 May 2004 17:47:32 -0700
From: krakle@visto.com (krakle)
Subject: Re: Password scheme/Persistent session...
Message-Id: <237aaff8.0405211647.4065ff40@posting.google.com>
botfood@yahoo.com (dan baker) wrote in message news:<13685ef8.0405211003.3ce3136b@posting.google.com>...
> You COULD try to do something with IP addresses, but not many people
> have static IPs.
I considered that but then proxies hold many people on one IP aswell
as some networks... Plus dynamic IPs change every connection...
>
> I ended up using a scheme in a similar situation that sets a cookie
> which is a combination of the username, the time, and the user's
> encrypted password. comparing it to what I have stored server-side. if
> everything doesn't match, or if the time is "too old" then I kick'em
> out to re-login where I can check against the password, etc. The nice
> thing about managing it this way is you can do nice things like email
> passwords (only to the user's previously defined address) when they
> forget, etc.
What I ended up doing is setting a cookie that md5 encrypted time +
random number + process ID as the session id (sid). Then it looks up
the data of that user in a mySQL table using the SID in the cookie.
Thank you.
------------------------------
Date: Sat, 22 May 2004 01:16:07 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Password scheme/Persistent session...
Message-Id: <rRxrc.3090$ZQ.411@nwrddc03.gnilink.net>
krakle wrote:
> "John W. Kennedy" <jwkenne@attglobal.net> wrote in message
> news:<G0rrc.9423$cz5.1816627@news4.srv.hcvlny.cv.net>...
>> We understand perfectly. You are asking a question about how the web
>> works in a Perl group.
>
> OR I asked how can you mantain state in Perl to make a session with
> out the use of cookies. That's not a question asking how the web
> works. It's a Perl question. To say such a thing just proves your
> ignorance after I repeatedly asked the question. Wow...unbelievable.
Ok, here is a Perl answer. It is even portable to most(all?) other
programming languages:
- As long as the Perl program is not terminated any global variables will
keep its state. Therefore you can use global variables to preserve the state
of the program.
- If you want to preserve a state from one program execution to the next
program execution then typically this is called "data persistence". Two
typical solutions for data persistence are files or databases. Before
terminating the first program execution it writes whatever data you want to
persist into a status file or into a database. The following program
execution reads this information from the file or database and restores the
state.
Now, I doubt that this Perl answer solves your problem, because your problem
is not about data persistence to begin with.
Your problem is about the stateless nature of the HTTP protocol where you
cannot relate one HTTP request to another HTTP request without using some
crutch like e.g. cookies. Your question is about what other crutches are
available to work around this "shortcoming" of the HTTP protocol.
In which way a question about workarounds for the HTTP protocol has anything
to do with Perl or any other programming language is beyond me.
Again: Perl has states, Perl maintains the program state during program
execution, there are many ways to preserve the state of a Perl program
between different program executions. None of this has anything to do with
your problem, YOU DO NOT HAVE A PERL PROBLEM.
jue
------------------------------
Date: 21 May 2004 19:52:41 -0700
From: sidwelle@alexian.net (Eli Sidwell)
Subject: Re: perl tcp server script works, but no data.
Message-Id: <ef9a95b0.0405211852.5158a99d@posting.google.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<c8kgsg$smk$3@mamenchi.zrz.TU-Berlin.DE>...
> Kevin Collins <spamtotrash@toomuchfiction.com> wrote in comp.lang.perl.misc:
> > In article <ef9a95b0.0405200724.2b8f1e58@posting.google.com>, Eli Sidwell
> > wrote:
> >
> > Please, no top posting...
> >
> > > Still nothing, the $nread even comes up 0.
> > >
> > > As far as the client, I tried to telnet a small file to that port and
> > > then I wrote an app using the VB winsock to move text to that port.
> > > Both times it opens the port and accepts the data (I think), I can get
> > > the port and IP from perl but, I don't see any data.
> > >
> > > Are there any good reference books on the perl socket with examples.
> > > I have the orilly cookbook, but its a lot of theory.
> > >
> > -snip-
> >
> > perldoc 'perlipc' has a basic TCP client/server that I have used as the basis
> > for a couple of different things. Its not too complex.
>
> There's also Net::EasyTCP which covers simple TCP-based client/server
> pairs.
>
> Anno
I think that I have narrowed the problem, it seems that I don't
receive any data unless I send more than a 2k of stuff. I have seen
some postings that refer to flushing issues, how do I cause this code
to flush no matter what size data is received?
Thanks
------------------------------
Date: Sat, 22 May 2004 03:36:41 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: perl tcp server script works, but no data.
Message-Id: <c8mhs9$6ci$1@wisteria.csv.warwick.ac.uk>
Quoth sidwelle@alexian.net (Eli Sidwell):
> I think that I have narrowed the problem, it seems that I don't
> receive any data unless I send more than a 2k of stuff. I have seen
> some postings that refer to flushing issues, how do I cause this code
> to flush no matter what size data is received?
This sounds like a problem on the sending end... you need to flush after
each write. In perl, set $|=1.
Ben
--
Outside of a dog, a book is a man's best friend.
Inside of a dog, it's too dark to read.
ben@morrow.me.uk Groucho Marx
------------------------------
Date: Fri, 21 May 2004 22:45:09 +0000 (UTC)
From: "David H. Adler" <dha@panix2.panix.com>
Subject: Re: Perl vs PHP
Message-Id: <slrncat1jl.a9q.dha@panix2.panix.com>
On 2004-05-21, Matija Papec <perl@my-header.org> wrote:
> X-Ftn-To: David H. Adler
>
> "David H. Adler" <dha@panix2.panix.com> wrote:
>>> FOR the web I'd use PHP because 1. It's easier 2. More convienent and
>>> 3. faster than CGI.
>>
>>For the sake of accuracy, I just want to point out that #3 seems
>>somewhat off, as PHP is a programming language and CGI is an interface.
>>Apples and oranges, you know. :-)
>
> It seems that CGI stands for many things, apples and oranges are probably
> ok, but how one could describe a very common "CGI == perl_script"?
~ 18:44:04$ perl -e 'print "Yikes\n" if "CGI" == "perl_script";'
Yikes
:-)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"We're dumber than squirrels. We hear voices and do what they
command. I have broccoli in my socks." - Dilbert's boss
------------------------------
Date: Sat, 22 May 2004 01:24:17 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl vs PHP
Message-Id: <5Zxrc.3093$ZQ.350@nwrddc03.gnilink.net>
Matija Papec wrote:
>> It seems that CGI stands for many things, apples and oranges are
> probably ok, but how one could describe a very common "CGI ==
> perl_script"?
How do you call the opposite of a tautology (i.e always false)?
jue
------------------------------
Date: Sat, 22 May 2004 01:40:07 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl vs PHP
Message-Id: <0f5c43ed5cdfcc95526a79a30fb52fa9@news.teranews.com>
>>>>> "Jürgen" == Jürgen Exner <jurgenex@hotmail.com> writes:
Jürgen> How do you call the opposite of a tautology (i.e always false)?
A Used Car Salesman.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 21 May 2004 20:17:12 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl vs PHP
Message-Id: <slrncatago.2ue.tadmc@magna.augustmail.com>
Matija Papec <perl@my-header.org> wrote:
> X-Ftn-To: David H. Adler
>
> "David H. Adler" <dha@panix2.panix.com> wrote:
>>> FOR the web I'd use PHP because 1. It's easier 2. More convienent and
>>> 3. faster than CGI.
>>
>>For the sake of accuracy, I just want to point out that #3 seems
>>somewhat off, as PHP is a programming language and CGI is an interface.
>>Apples and oranges, you know. :-)
>
> It seems that CGI stands for many things, apples and oranges are probably
> ok, but how one could describe a very common "CGI == perl_script"?
I think many people use "CGI" as short for "CGI program", which
many other people object to because then you are talking about
the Interface rather than a program that conforms to the Interface.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 21 May 2004 21:14:19 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl vs PHP
Message-Id: <slrncatdrr.33r.tadmc@magna.augustmail.com>
Jürgen Exner <jurgenex@hotmail.com> wrote:
> Matija Papec wrote:
>>> It seems that CGI stands for many things, apples and oranges are
>> probably ok, but how one could describe a very common "CGI ==
>> perl_script"?
>
> How do you call the opposite of a tautology (i.e always false)?
A contradiction.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 22 May 2004 00:55:05 +0200
From: Thomas Schweikle <tpsX@vr-web.de>
Subject: Re: Problem installing modules
Message-Id: <2h7fo2Fa1bbcU1@uni-berlin.de>
Matt Garrish wrote:
> "Thomas Schweikle" <tpsX@vr-web.de> wrote in message
> news:2h70hhF9qcf5U1@uni-berlin.de...
>> Hi!
>>
>> Trying to install "AppConfig":
>>
>> C:\HOME\xch4008>perl -MCPAN -e"install AppConfig"
>>
>
> Since you're a bit thin on details about what you're doing, I'll guess that
> you were trying to run the cpan shell and it died, so you're now trying to
> install the module it died on? I'll also guess that you aren't using cygwin,
> and give you a hint that there is no make on Windows.
>
> If you're using ActivePerl, use ppm to install modules.
Yes, it is ActivePerl. I've tried with ppm. But this leads to:
ppm> install AppConfig
Error: PPD for 'AppConfig.ppd' could not be found.
Hm?!
--
Thomas
------------------------------
Date: Fri, 21 May 2004 18:26:52 -0500
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: Problem installing modules
Message-Id: <0fwrc.406$G47.61674@news.uswest.net>
Thomas Schweikle wrote:
> Yes, it is ActivePerl. I've tried with ppm. But this leads to:
> ppm> install AppConfig
> Error: PPD for 'AppConfig.ppd' could not be found.
>
> Hm?!
>
Can be found at http://theoryx5.uwinnipeg.ca/ppms/AppConfig.ppd
------------------------------
Date: Fri, 21 May 2004 20:44:01 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: rmdir Question
Message-Id: <slrncatc31.2ue.tadmc@magna.augustmail.com>
George Kinley <georgekinley@hotmail.com> wrote:
> Tad,
> I must ask you at this point , Do you hate me , or my question. or my
> Posting to this NG
Certainly not.
But I don't let rudeness pass unquestioned either.
> Reasons:
> You Wrote to me :
Note that I have also answered several of your questions, even
though you were spitting in my face while asking.
I am mean-spirited alright.
> 1 > [ Please do not top-post.
People here do not like top-posting. If you do it, they won't like you.
I would like them to like you, so I suggest that you do as they like.
I was/am truly trying to help you, whether you can see that it helps or not.
I have been here an awfully long time.
I know these folks, you just got here...
> > Have you seen the Posting Guidelines that are posted here
> frequently?
Have you yet?
Or are you unconcerned with how people perceive you?
The guidelines have a bunch of other stuff that folks hereabouts
don't like either.
Since you did several of them in recent posts, I though you might
like to know what the others are. (before you become widely
auto-ignored.)
Top-posting is the newsgroup-equivalent of toilet paper stuck to your shoe.
I pointed it out to you rather than snicker and let you walk around
like that.
You can pull it off or leave it there, as you please (and live
with the results).
> 2 > >> He's made off-topic posts before too:
> > >> I've arranged to ignore all of his posts since that one.
>
> As an Experience person in this field
"this field" being programming, I guess?
That's fine but irrelevant in this sub-thread, as you have moved
the topic from programming to netiquette.
You are clearly not experienced at all with Usenet in general, or
with this newsgroup in particular, since top-posting is near
universally reviled.
> you should not humiliate others,
I did not put the toilet paper on your shoe. You did.
I offered you a chance to avoid the humiliation.
You take issue with my attempts to help you avoid it.
The killfile is the Right Place.
[ snip 60 lines of yet more full-quote.
Top-posting is rude.
Are you _trying_ to be rude?
To me? To the thousands of other readers of your upside-down posts?
]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 21 May 2004 23:45:33 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Sockets: receiving data
Message-Id: <c8m4at$r5p$1@wisteria.csv.warwick.ac.uk>
Quoth Jim Gibson <jgibson@mail.arc.nasa.gov>:
> Stick to the object-oriented versions of the socket functions. E.g.,
> use $lsv->recv(...) instead of recv(...) (although as you have
> discovered you should be using read instead of recv). You are calling
> the basic Perl recv function with a reference to an IO::Socket::INET
> object instead of a file handle as the first argument. That may or may
> not work.
An IO::Socket::INET ISA IO::Handle which is a filehandle. (To be more
specific, an IO::Handle is a blessed globref.) It works just fine.
Ben
--
If I were a butterfly I'd live for a day, / I would be free, just blowing away.
This cruel country has driven me down / Teased me and lied, teased me and lied.
I've only sad stories to tell to this town: / My dreams have withered and died.
ben@morrow.me.uk (Kate Rusby)
------------------------------
Date: Sat, 22 May 2004 00:31:15 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: String search/match question
Message-Id: <pan.2004.05.21.22.30.48.772803@aursand.no>
On Fri, 21 May 2004 13:12:09 -0700, Kevin Potter wrote:
> The problem is, I need to find the first occurance of this character
> that is not enclosed in brackets "[]" in this string.
1. Remove all the characters within brackets.
2. Use 'index'.
--
Tore Aursand <tore@aursand.no>
"I am become Death, shatterer of worlds." (J. Robert Oppenheimer, upon
witnessing the explosion of the first atomic bomb.)
------------------------------
Date: Fri, 21 May 2004 18:16:17 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: String search/match question
Message-Id: <Ocvrc.92772$325.1983538@news20.bellglobal.com>
"Matija Papec" <perl@my-header.org> wrote in message
news:oqpsa0t6pcbrah8iqu2o7m6oh26rs6ido8@4ax.com...
> X-Ftn-To: Kevin Potter
>
> krpotter@co.douglas.or.us (Kevin Potter) wrote:
> >How can I find the POSITION number of the first occurance of the
> >letter "x" that is not enclosed in the bracketed text (the one I want
> >is the one directly before the capital YZ).
> >
> >I've tried numerous versions indexing this and that, comparing this to
> >the positions of the first and successive brackets, but cannot come up
> >with a realiable method.
> >
> >Any thoughts, or pointers would be really appreciated. Maybe a fancy
> >regex would be able to do this?
>
> It's not fancy but it should be reliable. :)
>
> my $s =
> "abcdefg[extra]hijklmn[texas]opqrstuvwxYZabc[tex]defghijklmnopqrstuvwxyz";
>
> s/(\[.+?\])/' ' x length $1/ge, $_ = index $_,'x' for my $pos = $s;
> print "$pos\n";
>
It won't work, though, if there are nested brackets. I would prefer
something like the following just to be safe:
my $s =
"abcdefg[extra]hijklm[n[texas]opqrstuvwxYZ]abc[tex]defghijklmnopqrstuvwxyz";
my $pos = 0;
my $bracket = 0;
foreach my $char ( $s =~ /(.)/g ) {
if ( ($char eq 'x') && !$bracket ) {
print $pos;
}
elsif ( $char eq '[' ) {
$bracket += 1;
}
elsif ( $char eq ']' ) {
$bracket -= 1;
}
else {
}
$pos += 1;
}
Matt
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V10 Issue 6596
***************************************