[17909] in Perl-Users-Digest
Perl-Users Digest, Issue: 69 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 16 09:05:31 2001
Date: Tue, 16 Jan 2001 06:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979653911-v10-i69@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 16 Jan 2001 Volume: 10 Number: 69
Today's topics:
Re: Can't associate .PL files in Win98 <gracenews@optusnet.com.au>
Re: exit (Martien Verbruggen)
Re: Limits on array and hash storage <gracenews@optusnet.com.au>
Re: Maybe more of a unix question. Translating file nam (G.A.D.Miles)
Re: More questions about pattern matching (Bernard El-Hagin)
Re: More questions about pattern matching (Helgi Briem)
Re: name of var $_ is pointing to? <bernie@fantasyfarm.com>
newbie - hash value size limit? (Jason Goodrow)
Re: newbie - hash value size limit? <wyzelli@yahoo.com>
Re: Newbie question: hash tables and dbm files; what am <cingram-at-pjocs-dot-demon-dot-co-dot-uk>
Re: NEWBIE: need help with search spider/crawler <gracenews@optusnet.com.au>
Perl 5.6 Win32::Process::Create <gert.grossmann@sap.com>
Re: Perl and AOL. How is this possible? (G.A.D.Miles)
Re: Perl and AOL. How is this possible? <gracenews@optusnet.com.au>
Re: Perl and AOL. How is this possible? (Abigail)
Perl module to yahoo messenger (Miguel Manso)
Re: RegEx , matching ? <W.Hielscher@mssys.com>
tr or replace <Per-fredrik.Pollnow@epk.ericsson.se>
Re: tr or replace (Bernard El-Hagin)
Re: tr or replace mastertivoli@my-deja.com
Re: tr or replace (Bernard El-Hagin)
Re: why does system() work on command line but not in b <amc@deez.com.ua>
Re: why does system() work on command line but not in b <Peter.Dintelmann@dresdner-bank.com>
Win32::NetAdmin used to work. geek@microgeek.com
Re: ZIp Code Perl Program <phallicity_2000@yahoo.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 16 Jan 2001 22:02:44 +1000
From: "Jeffrey Grace" <gracenews@optusnet.com.au>
Subject: Re: Can't associate .PL files in Win98
Message-Id: <3a64387f$0$15493$7f31c96c@news01.syd.optusnet.com.au>
you could run the perl file using start
eg:
start myperlfile.pl
if you use the /w option it will force the window to stay open until the
program returns.
--
Jeffrey Grace
~~~~~~~~~~~~~~~~~~~~
Queensland, Australia
"Damian James" <damian@puma.qimr.edu.au> wrote in message
news:slrn967c9p.dks.damian@puma.qimr.edu.au...
> David Efflandt wrote:
> >On Sun, 14 Jan 2001, Gary Burton wrote:
> >
> >> The association still would not work in Windows 98. An opinion on one
> >> of the discussion groups was that it can't be done for shell
> >> (DOS) programs in Win95 or Win98, although it works fine in Windows
> >> NT. Unfortunately, that seems to be correct because I carefully
> >> reviewed the instructions in ActiveState's perlwin32faq4 FAQ called
"How
> >> do I associate Perl scripts with Perl?" and followed them precisely.
> >
> >While the file association does not work from the DOS shell, it does work
> >from Windows Explorer (see below). From the DOS shell you either run the
> >script as a commandline parameter to Perl, or use pl2bat to convert it to
> >a .bat file. This requires that Perl and pl2bat are in your PATH
(usually
> >C:\PERL\BIN). The pl2bat worked for me.
> >
>
> Under Win98 and NT, I have found that you can change file associations for
> anything at any time by shift-right-clicking on the file, then selecting
> "Open With..." from the context menu.
>
> If the relevent executable is not in the list, click "Other" and locate it
> yourself.
>
> You can use this to associate .txt files with vim, for example. Likewise
you
> can associate ANY extension you like with the perl executable. Really, the
> extension you use is quite arbitrary and is up to you.
>
> As for getting the window to stay around -- myself, I'd just be opening a
> DOS/command prompt window and typing "perl filename".
>
> HTH
>
> Cheers,
> Damian
------------------------------
Date: Wed, 17 Jan 2001 00:09:44 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: exit
Message-Id: <slrn968i0o.fu5.mgjv@martien.heliotrope.home>
On Mon, 15 Jan 2001 18:46:01 GMT,
sandywadkins123@my-deja.com <sandywadkins123@my-deja.com> wrote:
> Perl 5, HTML, little java script.
>
> Ok I wrote scripts making each user have a temp. file (xxx.dat). When
> they sumit it updates a file, then gets deleted.
>
> Question: if they don't submit and close it the file is hanging out
> there. So how can I capture when they exit?
If you had created those files from a CGI program written in C, would
your question be different? If there had been no Perl involved,
whatsoever, would your question have been otherwise? Would the answer
be?
No. The above are the basic rules that you can use to figure out whether
you have a question about Perl. You don't. You have a question about how
to deal with remnants of an inherently stateless protocol. You should be
asking in groups where they talk about this protocol, over in
comp.infosystems.www.*
\begin{offtopic}
You can't capture when people 'exit' from your web site, because they
don't ever do that. That also don't 'enter' it. They request single
documents from your web server (sometimes a few more in a single
connection). The whole idea of a 'visit' or 'session' is a construct
that market-droids have come up with, and that programmers now have to
somehow support.
But it isn't there.
If you create a temporary file for a CGI program, then make sure that
once every so often you run a separate program (from crontab normally)
that cleans them up.
Something like:
find /wherever/your/temp/dir/is -atime +1 -exec rm {} \;
or, slightly more efficiently, but it only works (portably) if your file
names don't have spaces:
find /foo -atime +1 | xargs rm
Platform specific solutions exists that work with infidel file names as
well.
\end{offtopic}
Martien
--
Martien Verbruggen |
Interactive Media Division | The gene pool could use a little
Commercial Dynamics Pty. Ltd. | chlorine.
NSW, Australia |
------------------------------
Date: Tue, 16 Jan 2001 22:04:47 +1000
From: "Jeffrey Grace" <gracenews@optusnet.com.au>
Subject: Re: Limits on array and hash storage
Message-Id: <3a6438fa$0$15487$7f31c96c@news01.syd.optusnet.com.au>
eg: DOS
;-)
--
Jeffrey Grace
~~~~~~~~~~~~~~~~~~~~
Queensland, Australia
"Rich Lafferty" <rich@bofh.concordia.ca> wrote in message
news:slrn967jrv.rc6.rich@bofh.concordia.ca...
> In comp.lang.perl.misc,
> Abigail <abigail@foad.org> wrote:
> > Rich Lafferty (rich@bofh.concordia.ca) wrote
> > > William Cardwell <EUSWMCL@am1.ericsson.se> wrote:
> > > >
> > > > I notice that large arrays and hashes are commonly used in Perl. I
do
> > > > the same and have not yet hit limits. Am I really using only ram?
> > >
> > > Possibly swap, also. Depends on your operating system.
> >
> > Really? There are operating systems that have swap that's located in
> > memory that cannot be randomly accessed? Swap on punch cards does exist?
>
> Tsk tsk! Occam's razor, Abigail -- there are operating systems without
> swap.
>
> -Rich
>
> --
> Rich Lafferty ----------------------------------------
> Nocturnal Aviation Division, IITS Computing Services
> Concordia University, Montreal, QC
> rich@bofh.concordia.ca -------------------------------
------------------------------
Date: Tue, 16 Jan 2001 10:17:46 GMT
From: usad1@gadnet.com (G.A.D.Miles)
Subject: Re: Maybe more of a unix question. Translating file names
Message-Id: <3a641f90.5200200@news.newsguy.com>
Thanks for the tip, but I've come up with a whole new approach so that
the problem doesn't really exist any more.
Drummond
>
>One way is to use the URI::Escape module. You can pass the
>uri_escape() function a range of characters that are "unsafe," and the
>documentation even has an example that escapes absolutely everything.
>As long as your OS can handle filenames with the characters you deem
>safe, and numbers and the "%" character, and it can handle long
>filenames, you should be fine.
>
>--
>Teodor Zlatanov <tzz@iglou.com>
>"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais
>
>
>-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
>http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
>-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Tue, 16 Jan 2001 11:30:09 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: More questions about pattern matching
Message-Id: <slrn968c60.2q0.bernard.el-hagin@gdndev25.lido-tech>
On Tue, 16 Jan 2001 17:09:50 +1000, Mike McPherson
<hafateltec@hotmail.com> wrote:
>
>One note added that I noticed after I posted this:
>perlre manpage states:
>The following standard quantifiers are recognized:
>
>
> * Match 0 or more times
> + Match 1 or more times
> ? Match 1 or 0 times
> {n} Match exactly n times #EXACTLY N TIMES ??????
> {n,} Match at least n times
> {n,m} Match at least n but not more than m times
>
>then if {n} Matches EXACTLY N TIMES why is it that /\d{3}-\d{4}/ will work
>on xxx-xxxx but not xxx-xxxxx ?????
I don't know what you mean by "will work on", but it certainly matches
both cases:
$_ = "123-45678";
print "Yipee" if /\d{3}-\d{4}/;
Maybe you meant that this:
/^\d{3}-\d{4}$/
doesn't match, which is true enough.
Cheers,
Bernard
--
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Tue, 16 Jan 2001 11:35:31 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: More questions about pattern matching
Message-Id: <3a643105.597763588@news.itn.is>
On Tue, 16 Jan 2001 17:09:50 +1000, "Mike McPherson"
<hafateltec@hotmail.com> wrote:
>then if {n} Matches EXACTLY N TIMES why is it that /\d{3}-\d{4}/ will work
>on xxx-xxxx but not xxx-xxxxx ?????
>
I'm not sure I understand your question, but if
you are asking: why will 123-1234 and 123-12345
both match /\d{3}-\d{4}/, then the answer is
that the pattern 123-1234 is contained fully
and completely within the pattern 123-12345.
So if you want to match only the former and not
the latter, modify your regexp to:
/^\d{3}-\d{4}$/ to match a complete string or perhaps
to /\b\d{3}-\d{4}\b/ to match at wird boundaries.
Regards,
Helgi Briem
------------------------------
Date: Tue, 16 Jan 2001 08:45:17 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: name of var $_ is pointing to?
Message-Id: <1rj86topd4u8lrpsm4orda1v2bu21odv5v@news.supernews.net>
abigail@foad.org (Abigail) wrote:
} Bernie Cosell (bernie@fantasyfarm.com) wrote on MMDCXCIV September
} MCMXCIII in <URL:news:t5366tkl34jr6baq2ulp9gk4dcfco6ed9v@news.supernews.net>:
} `` rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote:
} ``
} ``
} ``...I
} `` can envision opening up the main:: symbol table and iterating through it
} `` (and all nested symtabs, of course0 looking for a reference match.
} `` ... Seems like it'd be a pretty complex bit of code, but is
} `` probably doable. You write "whoami(ref)" and it comes back with a string,
} `` being the best name it could figure out that matches that ref.
}
}
} Good luck in finding the variables in the code fragment above in the
} symbol table....
I know --- 'my' symbols don't show up in the symbol table -- I was less
addressing his *specific* problem than just thinking about a strange little
(?), perhaps interesting/amusing programming exercise. There used to be a
similar program on Unix, for example, [don't know if it is still there
these days] that if you gave it an inode number it'd try to figure out a
'name' associated with it by traversing the directory tree looking for a
match... [I think it was called 'ncheck' but I don't really remember].
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: 16 Jan 2001 06:13:49 -0500
From: goodrow@panix.com (Jason Goodrow)
Subject: newbie - hash value size limit?
Message-Id: <941add$eld$1@panix2.panix.com>
Newbie here -
I've got a hash with lots of keys - Values have one or more element
(saving as a ':'delimited string)
How large is too large for the string? I mean, a hash with
a six charicter key and 50k value?
Any info?
thanks
goodrow@opencity.com
------------------------------
Date: Tue, 16 Jan 2001 21:09:33 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: newbie - hash value size limit?
Message-Id: <EpW86.17$Le4.1877@vic.nntp.telstra.net>
"Jason Goodrow" <goodrow@panix.com> wrote in message
news:941add$eld$1@panix2.panix.com...
> Newbie here -
>
> I've got a hash with lots of keys - Values have one or more element
> (saving as a ':'delimited string)
>
> How large is too large for the string? I mean, a hash with
> a six charicter key and 50k value?
>
> Any info?
>
How much RAM do you have?
How many other users are sharing the resources of the system?
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: Tue, 16 Jan 2001 13:50:29 -0000
From: "Clyde Ingram" <cingram-at-pjocs-dot-demon-dot-co-dot-uk>
Subject: Re: Newbie question: hash tables and dbm files; what am I doing wrong?
Message-Id: <979653057.11548.0.nnrp-12.9e98e5bc@news.demon.co.uk>
James,
James Kauzlarich <nospam-abuse@[127.0.0.1]> wrote in message
news:yXS86.2625$d25.15703@newsfeed.slurp.net...
> Ok, I'm trying to manipulate some dbm files, the first two programs I
> cobbled together work fine, the 2nd two do NOT. I'm getting very
> frustrated. Do the dbm files NOT work with Hashes of hashes??
I recall a problem with DBM files failing to support s hashes of hashes in,
er.., possibly ActiveState 5.22.
Reason was that DBM files supported scalar values only. If the value was
not a scalar but a reference to another hash (or array), the DBM file did
not work as expected.
Remedy was to get a module from CPAN (or was it the O'Reilly Perl Resource
Kit?) to support references in hash elements.
Sadly I don't recall which module - but I'll see if I can dig it up.
Yours vaguely,
Clyde
------------------------------
Date: Tue, 16 Jan 2001 22:17:27 +1000
From: "Jeffrey Grace" <gracenews@optusnet.com.au>
Subject: Re: NEWBIE: need help with search spider/crawler
Message-Id: <3a643bf3$0$15467$7f31c96c@news01.syd.optusnet.com.au>
already posted part of this in alt.perl, but want to ensure you know not
everyone has the same opinions and/or attitudes.
http://www.stonehenge.com/merlyn/WebTechniques/col35.html
Implements a fair amount of what you want to do, and he gives a good
description of what each group of lines do, its a big script for him, and
his explanation isn't quite as detailed as it normally is, if you get a bit
lost, look at some of the earlier articles.
--
Jeffrey Grace
~~~~~~~~~~~~~~~~~~~~
Queensland, Australia
"Abigail" <abigail@foad.org> wrote in message
news:slrn96835i.kig.abigail@tsathoggua.rlyeh.net...
> someone of export (lashawn@rice.edu) wrote on MMDCXCV September MCMXCIII
> in <URL:news:3a63ccb3.184683563@news.rice.edu>:
> <> On 15 Jan 2001 22:58:52 GMT, abigail@foad.org (Abigail) wrote:
> <> (snippage of my inquiry)
> <> >Hire someone.
> <> >
> <> >
> <> >
> <> >Abigail
> <> I'd like to figure out how to do it. Not much of a solution for a
> <> newcomer to purchase every program or script they need. Any help with
> <> the problem would be great, but there's no need for snarking.
>
>
> You don't learn carpenting by asking how to build a church either.
>
> Hiring someone *IS* a good advice. What you want to do is complex, and
> requires quite some code - not at all suitable for a self proclaimed
> newbie.
>
>
> Abigail
> --
> print 74.117.115.116.32;
> print 97.110.111.116.104.101.114.32;
> print 80.101.114.108.32;
> print 72.97.99.107.101.114.10;
------------------------------
Date: Tue, 16 Jan 2001 13:33:05 +0100
From: "SAP Users" <gert.grossmann@sap.com>
Subject: Perl 5.6 Win32::Process::Create
Message-Id: <941f1t$6hl$1@news1.wdf.sap-ag.de>
Hi,
how can I create a process with inheritance of the environment pointer?
In Perl 5.005 this code snippet works, in 5.6 it goes wrong:
------------------------------
use Win32::Process;
$ENV{'TEST'} = "OK";
Win32::Process::Create(
$ProcObj,
"C:\\WINNT\\system32\\cmd.exe",
"cmd.exe /c echo %TEST%",
1,
NORMAL_PRIORITY_CLASS | CREATE_SUSPENDED,
"." ) || die Win32::FormatMessage( Win32::GetLastError()) ;
$ProcObj->Resume();
$ProcObj->Wait(INFINITE);
print "halt";
-----------------------------------
output perl 5.005 :
"OK"
halt
output perl 5.6 :
%TEST%
halt
thanks
Gert
------------------------------
Date: Tue, 16 Jan 2001 10:15:53 GMT
From: usad1@gadnet.com (G.A.D.Miles)
Subject: Re: Perl and AOL. How is this possible?
Message-Id: <3a641ddf.4767407@news.newsguy.com>
On 14 Jan 2001 00:40:14 GMT, abigail@foad.org (Abigail) wrote:
>G.A.D.Miles (usad1@gadnet.com) wrote on MMDCXCII September MCMXCIII in
><URL:news:3a605397.7747790@news.newsguy.com>:
>.. I have written some perl scripts for running your own banner exchange.
>.. When you click on a banner it takes you to the appropriate site. This
>.. works fine in all browsers. However, if you right click on a banner
>.. and opt to open the page in a new browser window, it works fine in IE
>.. and Netscape, but in AOL the script cannot find the site and returns
>.. the default URL location.
>
>"the script cannot find the site".
>
>*What site* and how are you searching for the site? Why does the program
>need to `find' a site anyway, as nothing in the status purpose of program
>needs to `find' a site?
As I mentioned above, the program is a banner exchange program. I
expect you have come across them on the web. When you click on a
banner the script then has to work out which site to take you to. The
problem seems easy enough to understand, if not to solve, but I don't
know how I can explain it any better.
>
>.. How can this be possible since it is the server, not the browser that
>.. is running the code?
>
>According to your status problem, the program can't find a site.
>
>Or are you utterly clueless and should you be asking in a browser group?
I am asking here because, in a nutshell, a Perl script is operating in
different ways under different browsers.
Are you always so rude?
Drummond
>
>
>Abigail
>--
>$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_=sub{print/::(.*)/};
>$\=$/;q<Just another Perl Hacker>->();
------------------------------
Date: Tue, 16 Jan 2001 21:58:13 +1000
From: "Jeffrey Grace" <gracenews@optusnet.com.au>
Subject: Re: Perl and AOL. How is this possible?
Message-Id: <3a643770$0$15483$7f31c96c@news01.syd.optusnet.com.au>
AOL browser bugged somehow, and not copying the full line properly (after
the ?). Strange I thought the AOL browser is based on IE. Does the script
check for browser versions at all? Otherwise the only thing I could suggest
would be to post to AOL support or appropriate newsgroup.
--
Jeffrey Grace
~~~~~~~~~~~~~~~~~~~~
Queensland, Australia
"G.A.D.Miles" <usad1@gadnet.com> wrote in message
news:3a605397.7747790@news.newsguy.com...
> I have written some perl scripts for running your own banner exchange.
> When you click on a banner it takes you to the appropriate site. This
> works fine in all browsers. However, if you right click on a banner
> and opt to open the page in a new browser window, it works fine in IE
> and Netscape, but in AOL the script cannot find the site and returns
> the default URL location.
>
> How can this be possible since it is the server, not the browser that
> is running the code?
>
> Regards,
>
> Drummond Miles
> BannerPlus
> http://www.gadnet.com/bplus
>
------------------------------
Date: 16 Jan 2001 12:21:44 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Perl and AOL. How is this possible?
Message-Id: <slrn968f6o.lsu.abigail@tsathoggua.rlyeh.net>
G.A.D.Miles (usad1@gadnet.com) wrote on MMDCXCV September MCMXCIII in
<URL:news:3a641ddf.4767407@news.newsguy.com>:
<> On 14 Jan 2001 00:40:14 GMT, abigail@foad.org (Abigail) wrote:
<>
<> >G.A.D.Miles (usad1@gadnet.com) wrote on MMDCXCII September MCMXCIII in
<> ><URL:news:3a605397.7747790@news.newsguy.com>:
<> >.. I have written some perl scripts for running your own banner exchange.
<> >.. When you click on a banner it takes you to the appropriate site. This
<> >.. works fine in all browsers. However, if you right click on a banner
<> >.. and opt to open the page in a new browser window, it works fine in IE
<> >.. and Netscape, but in AOL the script cannot find the site and returns
<> >.. the default URL location.
<> >
<> >"the script cannot find the site".
<> >
<> >*What site* and how are you searching for the site? Why does the program
<> >need to `find' a site anyway, as nothing in the status purpose of program
<> >needs to `find' a site?
<>
<> As I mentioned above, the program is a banner exchange program. I
<> expect you have come across them on the web. When you click on a
<> banner the script then has to work out which site to take you to. The
<> problem seems easy enough to understand, if not to solve, but I don't
<> know how I can explain it any better.
Since when does a script "take you to a site"? That's not how the web
works. You tell the browser where to go - and it's the browser that
goes and fetch the data. And unless you want to have pointless extra
load on your server (and most banners work that way), the address
where to go is already put in the same page that displays the banner.
Hence, my question, what site and how are you searching for the site?
And why does your program need to find a site in the first place?
<> >.. How can this be possible since it is the server, not the browser that
<> >.. is running the code?
<> >
<> >According to your status problem, the program can't find a site.
<> >
<> >Or are you utterly clueless and should you be asking in a browser group?
<>
<> I am asking here because, in a nutshell, a Perl script is operating in
<> different ways under different browsers.
You are indeed utterly clueless.
The Perl program is run ON THE SERVER, and is not executed by a browser.
And beside that, in two postings about the problem, you haven't shared
a single detail of what you are doing, let alone given a single byte of
code.
Abigail
--
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");
------------------------------
Date: Tue, 16 Jan 2001 12:27:43 GMT
From: mmanso@localhost.localdomain (Miguel Manso)
Subject: Perl module to yahoo messenger
Message-Id: <slrn968fpo.4si.mmanso@localhost.localdomain>
Hi ppl..
I've seen some libraries to write programs like "Yahoo Messenger".
Is there any module for such thing?
Thanks.
------------------------------
Date: Tue, 16 Jan 2001 14:50:49 +0100
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: Re: RegEx , matching ?
Message-Id: <3A6451B9.4417426C@mssys.com>
Rafael Garcia-Suarez wrote:
> Ricky wrote in comp.lang.perl.misc:
> > Suppose I have :
> > $string = 'abc ab abcde abcDef abc 123 ab';
> >
> > the regex : /([A-Za-z]+)/ returns me ($1) 'abc' which is 3 char long.
> > Imagine now I want that regexp to return me 'abcDef' which is 6 char long.
>
> Ok -- I imagine that you want the longest substring that matches.
> You need to extract all substrings that match and find the longest. This
> can't be done with a single regexp.
>
> Here is the a short bit of code that does what you want :
>
> my $string = 'abc ab abcde abcDef abc 123 ab';
> my $longest = (sort { length $b <=> length $a }
> ($string =~ /([A-Za-z]+)/g))[0];
^ ^
> print $longest;
Two minor points:
First, we don't need the brackets marked above. (But you, Rafael,
probably know that... :).
Second, _if_ the OP wants to find the longest substring, _delimited by
spaces or string-boundaries_, then one should write the
matching-operation as follows:
$string =~ /\b[A-Za-z]+\b/g
By using \b you avoid getting 'notthis' as longest match, if $string is
defined by
my $string = 'abc ab _notthis_ abcde abcDef abc 123 ab';
But that's just wild guessing. Rafael's solution is alright for
extracting the longest substring.
Cheers
Wolfgang
------------------------------
Date: Tue, 16 Jan 2001 13:06:35 +0100
From: "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se>
Subject: tr or replace
Message-Id: <941dt8$k8u$1@newstoo.ericsson.se>
(O/s:UNIX)
Hi,
I was wondering if someone can help me.
This is a row in my /etc/shadow
gunde:*LK:::::::
I need to read the "/etc/shadow" and find "gunde" and then replace the *LK
with "hello", can I use tr or something ?
---------------------------------------------------
( I did this in nawk like this: )
#cat shadow | nawk -F: -v c=crypted '{if ($1 ~ /gunde/)
#{split($0,a);a[2]=c;for(i=1;i<8;i++){printf a[i] ":"}print ":"} else
#print}'
------------------------------
Date: Tue, 16 Jan 2001 12:42:58 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: tr or replace
Message-Id: <slrn968geh.2q0.bernard.el-hagin@gdndev25.lido-tech>
On Tue, 16 Jan 2001 13:06:35 +0100, Per- Fredrik Pollnow
<Per-fredrik.Pollnow@epk.ericsson.se> wrote:
>(O/s:UNIX)
>Hi,
>
>I was wondering if someone can help me.
>
>This is a row in my /etc/shadow
>gunde:*LK:::::::
>
>I need to read the "/etc/shadow" and find "gunde" and then replace the *LK
>with "hello", can I use tr or something ?
perl -i.bak -pe 's/^(gunde:)\*LK/$1hello/' /etc/shadow
Cheers,
Bernard
--
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Tue, 16 Jan 2001 12:49:24 GMT
From: mastertivoli@my-deja.com
Subject: Re: tr or replace
Message-Id: <941g0i$geo$1@nnrp1.deja.com>
try either tr/\*LK/hello/ or you can try $newstring = s/\*Lk/hello/,
$string.
In article <941dt8$k8u$1@newstoo.ericsson.se>,
"Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se> wrote:
> (O/s:UNIX)
> Hi,
>
> I was wondering if someone can help me.
>
> This is a row in my /etc/shadow
> gunde:*LK:::::::
>
> I need to read the "/etc/shadow" and find "gunde" and then replace the *LK
> with "hello", can I use tr or something ?
>
> ---------------------------------------------------
>
> ( I did this in nawk like this: )
> #cat shadow | nawk -F: -v c=crypted '{if ($1 ~ /gunde/)
> #{split($0,a);a[2]=c;for(i=1;i<8;i++){printf a[i] ":"}print ":"} else
> #print}'
>
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 16 Jan 2001 13:15:39 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: tr or replace
Message-Id: <slrn968ibp.2q0.bernard.el-hagin@gdndev25.lido-tech>
[
Jeopardy quoting, which was a clue as to the quality of the reply,
fixed.
]
On Tue, 16 Jan 2001 12:49:24 GMT, mastertivoli@my-deja.com
<mastertivoli@my-deja.com> wrote:
>In article <941dt8$k8u$1@newstoo.ericsson.se>,
> "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se> wrote:
>> (O/s:UNIX)
>> Hi,
>>
>> I was wondering if someone can help me.
>>
>> This is a row in my /etc/shadow
>> gunde:*LK:::::::
>>
>> I need to read the "/etc/shadow" and find "gunde" and then replace the *LK
>> with "hello", can I use tr or something ?
>
>try either tr/\*LK/hello/ or you can try $newstring = s/\*Lk/hello/,
>$string.
Both of those answers are complete rubbish. The tr would yield:
gunde:hel::::::
which is probably *not* what the OP wanted. Your other answer just
boggles the mind in oh-so-many ways. First, there should be a binding
operator between $newstring and s/// *not* an equal sign. And you
shouldn't even have $newstring to the left of it since that's not the
string which you're doing the search and replace on. Second, the OP
wanted to replace the characters "*LK" *not* "*Lk". And third, the
construct:
$output =~ s/PATTERN/REPLACEMENT/, $input
is just too ridiculous to comment on. So I won't.
Cheers,
Bernard
--
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Tue, 16 Jan 2001 13:09:53 +0200
From: "Alexander" <amc@deez.com.ua>
Subject: Re: why does system() work on command line but not in browser?
Message-Id: <941a4t$ptg$1@sirius.sns.net.ua>
> I'm trying to get the system "run_my_prog", "args"; to run in both an AIX
> 4.3.3 environment with Apache and have also try W2000 running IIS 5.0. I
> can do anything else from perl (read and write files, display html code),
> but when I try to run the system command from within the html page, it
> doesn't execute. If I run the perl script from the command line it works
> fine - in both environments.
>
> On the W2000 machine, I get an "Access denied" on the web page that tries
to
> run the system command. On the AIX machine, I get nothing. In both
> instances, all I did was do a directory listing and pipe it to a file.
>
> Here's the code (W2000 version):
>
> use CGI qw(:standard);
>
> #deleted html formatting code...
> system "dir c:\ > results1.txt";
> #other stuff
>
> Now on the AIX version (which I can't get to right now because I shutdown
> the machine before I left work) I established the proper $ENV("path")
values
> so that the internal server error would not show up on the page. Now,
this
> script will work fine from the command line, but not from an html page.
>
> Please help!!!!
>
> Thanks,
> Billy brennanb_731@yahoo.com
>
That's bacause http server process is running under special account
(nobody -Appace, IWADM_USR-IIS or some). This user cannot execute this
command, it has no right to do this command. You can grant rights to this
user to perfom this command, but it's wrong way in secutity context.
amc@deez.com.ua
------------------------------
Date: Tue, 16 Jan 2001 12:47:43 +0100
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: why does system() work on command line but not in browser?
Message-Id: <941cd5$rbu7@intranews.bank.dresdner.net>
Hi,
"BB" <brennanb_731@yahoo.com> wrote in message
news:riQ86.1848$hD5.46346@nnrp1.sbc.net...
[snip]
> In both
> instances, all I did was do a directory listing and pipe it to a file.
you do not need system() to do that. Get your directory
content with opendir/readdir/closedir and safe the info
to a file with open/print/close.
Try to avoid system() in CGI environments.
Regards,
Peter Dintelmann
------------------------------
Date: Tue, 16 Jan 2001 12:26:12 GMT
From: geek@microgeek.com
Subject: Win32::NetAdmin used to work.
Message-Id: <941ekv$fh1$1@nnrp1.deja.com>
Help... This sub used to work from netadmin but now it does not.
@rem = '--*-Perl-*--
@echo off
perl -x -S -w %0 %*
goto endofperl
@rem ';
#!perl
#line 8
use Win32::NetAdmin;
Win32::NetAdmin::GetUsers("", FILTER_NORMAL_ACCOUNT , \@hash)
or die "GetUsers() failed: $^E";
$count=@hash;
print "\nThe current user count is = $count\n\n";
__END__
:endofperl
The error message I am getting is --> C:\>usercount
GetUsers() failed: at c:\perlscripts/usercount.bat line 10.
What is realy strange is I am using the UserCreate part every day to add
users. At one point GetUsers did work then I went to run it and it did
not. To my knowledge nothing has changed on the nt box.
NT - 4.0 sp 6
Perl - 5.00402
Thanks,
Louis
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 16 Jan 2001 12:46:47 GMT
From: Phallicity <phallicity_2000@yahoo.com>
Subject: Re: ZIp Code Perl Program
Message-Id: <941frl$gdf$1@nnrp1.deja.com>
Thanks all!!
In article <eli$0101151856@qz.little-neck.ny.us>,
Eli the Bearded <elijah@workspot.net> wrote:
> In comp.lang.perl.misc, Phallicity <phallicity_2000@yahoo.com> wrote:
> > I am looking for a perl (cgi) script that will automatically enter a
> > users city & state given a zip code, maybe one that I could simply
> > implement using the require (".."); function call. If anyone can
tell
> > me where to find one and how to implement it I would appreciate it.
> > Please be as specific as possible for I am fairly new to Perl
> > programming and am still learning.
>
> If such a beast exists, it would probably be at CPAN. Did you
> check CPAN? (www.cpan.org)
>
> If you want to write such a thing, you'll need a listing of zips
> and places. The only free one I know about is an old (1990) one
> offered by the Census Bureau as a public service.
>
> http://ftp.census.gov/geo/www/gazetteer/places.html
>
> Rural areas may pose problems judging by the FAQ for the data.
>
> Elijah
> ------
> has it bookmarked since it takes so long to navigate to that page
>
--
Phallicity
"He must have a huge Schwanstucker!"
-Young Frankenstein
Sent via Deja.com
http://www.deja.com/
------------------------------
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 V10 Issue 69
*************************************