[11200] in Perl-Users-Digest
Perl-Users Digest, Issue: 4800 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 1 19:07:28 1999
Date: Mon, 1 Feb 99 16:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 1 Feb 1999 Volume: 8 Number: 4800
Today's topics:
(no subject) <marvs@portalinc.com>
Re: A little help, thanks. (Martien Verbruggen)
Re: A little help, thanks. <wfs-dominion@worldnet.att.net>
Re: alternative perl NG for newbies? (peter)
Re: alternative perl NG for newbies? <eric.gorely@mci.com>
Re: alternative perl NG for newbies? <uri@ibnets.com>
Re: code to recurse directories gwebb@reedtech.com
Re: code to recurse directories (Matthew Bafford)
Re: Comments in Perl code <design@raincloud-studios.com>
Re: Email script ..seems to be working.. anything overl <bcompson@yahoo.com>
Re: Email script ..seems to be working.. anything overl <uri@ibnets.com>
Filtering... <bdispa@bigfoot.com>
Re: HELP with string parsing and scoring <aqumsieh@matrox.com>
Re: Help! Problem searching for data in a large text fi (Martien Verbruggen)
Re: Help! Problem searching for data in a large text fi (Burt Lewis)
imagemap <ngo_t@bls.gov>
Re: local($_) - why not "my"? <aqumsieh@matrox.com>
Re: Match Parens-More Perlish? <uri@ibnets.com>
Re: Match Parens-More Perlish? (Martien Verbruggen)
Perl syntax ( URGENT ) kamez@my-dejanews.com
Re: regex lib or Perl linked in? <jimmy@globalSpam.org>
Re: regex lib or Perl linked in? <jimmy@globalSpam.org>
Re: regexp match fail: (Martien Verbruggen)
Running an .EXE in a perl script llowe@ltdcommodities.com
Re: Running an .EXE in a perl script (Martien Verbruggen)
Re: Running an .EXE in a perl script <paulrafiq@csi.com>
Source to web-based newsgroup gibsonc@aztec.asu.edu
Using Net <jcorbin@apci.net>
Re: Visual Perl? <svend@lubypublishing.com>
Re: Visual Perl? (I R A Aggie)
Re: Visual Perl? <dgris@moiraine.dimensional.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 02 Feb 1999 07:20:40 +0800
From: Marvin Lim <marvs@portalinc.com>
Subject: (no subject)
Message-Id: <36B636C5.AB40A6A7@portalinc.com>
How do i tell unix through perl programming to change my password ?
Is it possible to open the "passwd" command (the same as sending mail
using sendmail or
mail) then run it and change my password ?
thanx
James
------------------------------
Date: Mon, 01 Feb 1999 22:06:51 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: A little help, thanks.
Message-Id: <%zpt2.14$wk3.2833@nsw.nnrp.telstra.net>
In article <36B5155D.2C8E044E@snailgem.org>,
Eugene Sotirescu <eugene@snailgem.org> writes:
> Eugene Sotirescu wrote:
>
>>
>> $file = "/path/to/textfile";
>> open (ATHLETE, $file) or die "Can't open $file: $!);
>> #chop ($athlete); #you don't need this; should be 'chomp' anyway
>> $athlete = <ATHLETE>;
>> close ATHLETE;
>>
>
> Ahem...:
>
> open (ATHLETE, $file) or die "Can't open $file: $!");
> ^
Ahem...:
open (ATHLETE, $file) or die "Can't open $file: $!");
^
:)
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 1 Feb 1999 23:24:39 GMT
From: "Justin Saul" <wfs-dominion@worldnet.att.net>
Subject: Re: A little help, thanks.
Message-Id: <795d3n$k8j@bgtnsc02.worldnet.att.net>
Thanks everyone!
It really helped...it also helps me learn.
Thanks again,
Justin
Tad McClellan <tadmc@metronet.com> wrote in message
bno397.ql9.ln@magna.metronet.com...
>Justin Saul (wfs-dominion@worldnet.att.net) wrote:
>: I am kind of new at this stuff, but I learn quickly and have one quick
>: problem I need fixed. Please tell me how I can manage the following
problem:
>
>: I want to open a file that has data in it and make it into a variable.
For
>: example file X.dat has my data and I want to have the data from that file
>: become variable $x, so that later I can use $x as a printible object.
>
>
>open(XDAT, 'X.dat') || die "could not open 'X.dat' $!";
>{ local $/;
> $x = <XDAT>;
>}
>close(XDAT);
>
>
>--
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Mon, 01 Feb 1999 21:55:04 GMT
From: pdroogma@netscape.net (peter)
Subject: Re: alternative perl NG for newbies?
Message-Id: <36b621fc.29104770@192.168.0.1>
Hello,
I guess it would make life easier, I was playing with the idea to set up a web site with a list of the most common
questions asked in this newsgroup ( I know, another FAQ, but this one only contains hot topics ). And no I'm not going
to decide what's hot, depends probably on the traffic in this newsgroup.
So my question is : A new NG or on a website ?
Peter
On Mon, 01 Feb 1999 11:24:23 +0000, 23_skidoo <23_skidoo@geocities.com> wrote:
>i know that there are a lot of very busy people in this newsgroup who
>know more about perl than is probably healthy :) some of these people
>seem to get 'snappish' when a newbie asks a question and that's fair
>enough, you're not here to write code for other people. however, some
>people seem to enjoy helping others out and i was wondering if it was
>worthwhile setting up another newsgroup for just this reason. no one
>would _have_ to use it, perhaps no one would but it would give a more
>helpful direction for the busy people to point rather than 'rtfm' or
>references to 'perlfunc, perlfaq4, and perlre manuals'.
>
>there's a huge range of programming ability in this NG, perhaps
>somewhere for the less experienced to swap ideas and help eachother out
>would be a good idea.
>
>whatcha all think?
>
>-23
>
>p.s. just to clarify before i get flamed, i'm not asking for people to
>write my code for me, i'm not flaming people on this NG who give rtfm
>resonses, i just think the experienced would be happier without the
>newbie questions and the newbies might not get as discouraged by the
>frequent put downs or referrals to the huge faq which isn't beginner
>reading.
------------------------------
Date: Mon, 01 Feb 1999 22:09:09 GMT
From: "Eric Gorely" <eric.gorely@mci.com>
Subject: Re: alternative perl NG for newbies?
Message-Id: <9Cpt2.13$J_.806@news.cwix.com>
WebSite...just make it well known where it is. Maybe put something in the
FAQ referencing it.
>So my question is : A new NG or on a website ?
------------------------------
Date: 01 Feb 1999 17:05:54 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: alternative perl NG for newbies?
Message-Id: <39lnihg4ot.fsf@ibnets.com>
>>>>> "p" == peter <pdroogma@netscape.net> writes:
p> I guess it would make life easier, I was playing with the idea to
p> set up a web site with a list of the most common questions asked in
p> this newsgroup ( I know, another FAQ, but this one only contains
p> hot topics ). And no I'm not going to decide what's hot, depends
p> probably on the traffic in this newsgroup.
p> So my question is : A new NG or on a website ?
well, you ain't gonna get a newbie NG past the voters. it has been shot
down many times for very valid reasons, with the blind leading the blind
being the most popular.
and how is your web site going to help newbies who don't even read the
FAQ that comes with perl or is easily found on perl.com? if you can
attract every perl newbie to your site and away from here, you could
sell banner ads and make many us in the NG very happy!
think about it before you waste any effort. it is a chicken/egg
problem. if they are a newbie they won't know to find your site. if they
are not a newbie, they will ask functional questions in this NG.
this group is for discussing the perl language, not helping every newbie
with winblows wanting to emulate dejanews in 3 lines of code. (we just
got a post asking for a script that will do dejanews for them. i wonder
what he would do if he actually got the thousands (millions?) of lines
of code emailed to him!! :-)
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Mon, 01 Feb 1999 21:20:05 GMT
From: gwebb@reedtech.com
Subject: Re: code to recurse directories
Message-Id: <7955pv$idp$1@nnrp1.dejanews.com>
The following code does pretty much the same thing as 'ls -R', but not so
nicely formated.
--- CODE ---
#!/usr/local/bin/perl -w
use strict;
&rlistdir($ARGV[0]);
sub rlistdir {
my ($dirname) = @_;
print "$dirname\n";
opendir(DIR, $dirname) or die "Could not open dir '$dirname': $!\n";
foreach (readdir(DIR)) {
next if /^\.{1,2}$/;
-d "$dirname/$_" ? &rlistdir("$dirname/$_") : print "$dirname/$_\n";
}
closedir(DIR);
}
--- CODE ---
Garth Webb
In article <36b473bd.36328725@news.netvision.net.il>,
grynberg@hotmail.com (sysop) wrote:
> Hi. I am trying to write a program to print all the files on my hard
> drive, with their complete paths. I was wondering if anyone has
> anything like this.
>
> I do not want to use modules, I would like to see the perl code
> itself. It does not seem difficult, and indeed I have no trouble going
> into directories, but it does not come back up.
>
> Thanks for any help
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 01 Feb 1999 23:43:41 GMT
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: code to recurse directories
Message-Id: <slrn7bceqh.ddv.dragons@Server.Network>
On Mon, 01 Feb 1999 21:20:05 GMT, gwebb@reedtech.com <gwebb@reedtech.com> wrote:
-> The following code does pretty much the same thing as 'ls -R', but not so
-> nicely formated.
->
[snip code]
Using your code:
% cat ../badway
#!/usr/bin/perl -w
&rlistdir($ARGV[0]);
sub rlistdir {
my ($dirname) = @_;
print "$dirname\n";
opendir(DIR, $dirname) or die "Could not open dir '$dirname': $!\n";
foreach (readdir(DIR)) {
next if /^\.{1,2}$/;
-d "$dirname/$_" ? &rlistdir("$dirname/$_") : print "$dirname/$_\n";
}
closedir(DIR);
}
% ls -l
total 0
lrwxrwxrwx 1 matthew matthew 1 Feb 1 18:30 catcher -> .
% ../badway .
.
./catcher
./catcher/catcher
./catcher/catcher/catcher
./catcher/catcher/catcher/catcher
./catcher/catcher/catcher/catcher/catcher
./catcher/catcher/catcher/catcher/catcher/catcher
./catcher/catcher/catcher/catcher/catcher/catcher/catcher
./catcher/catcher/catcher/catcher/catcher/catcher/catcher/catcher
^C
%
File::Find doesn't have this problem.
Similar code is a lot shorter, too:
use File::Find;
find(\&wanted, '.');
sub wanted {
print "$File::Find::name\n";
}
HTH!
--Matthew
------------------------------
Date: 1 Feb 1999 23:57:31 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Comments in Perl code
Message-Id: <795f1b$2gf@bgtnsc01.worldnet.att.net>
>The size of a perl script has no effect on the bandwidth.
Right.. I knew that. I had sorta lumped everything together. I
was trying to explain things from a OS global point of view. In
other words.. users abcd getting HTML and Images, efgh and i
running scripts... all attributing to the speed or lack thereof
on the server.
>I don't believe the CPU times will be very different.
I've often considered putting some timers in the front and back
end of some scripts to see what I get. I'm sure you are probably
right... it's human nature to be curious about the little
things, ya know? :)
>I seriously doubt that you will be able to come up with one
real life
>example where code slows down the running of your perl program
>noticeably.
Oh yeah? Well.. again, you're probably right. :)
>If you are really so worried about all this, you should
seriously
>consider programming in C, having your reuseable code in shared
>libraries, so the executable sizes don't get too large.
Heh heh... umm... C .. why do you think I do Perl? :) <-- C
failure
Thanks for the post... lotsa stuff to think about.
CT
------------------------------
Date: 1 Feb 1999 23:03:34 GMT
From: "Quentin Compson" <bcompson@yahoo.com>
Subject: Re: Email script ..seems to be working.. anything overlooked
Message-Id: <01be4e36$b9e2c680$130b440c@brmptrue>
Thanks for you input
> The main thing you seem to have overlooked is the CGI.pm module. This
> module handles the reading of data, the parsing of arguments, and the
> conversion of hex escapes. It is strongly recommended that you 'use
> CGI' in all your CGI scripts.
>
The book I was using to teach myself Perl never even mentions CGI.pm which
means A) it is old or B) it isn't a very good book
copyright 1998
I looked around and seem to have come to the conclusion that CGI.pm is sort
of
a way of making Perl object oriented.
Anyway am I right in thinking that to use this you need to generate the
form with
perl as well as process it?
Can you process info sent from a normal HTML form?
------------------------------
Date: 01 Feb 1999 18:12:28 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Email script ..seems to be working.. anything overlooked
Message-Id: <39k8y1g1lv.fsf@ibnets.com>
>>>>> "QC" == Quentin Compson <bcompson@yahoo.com> writes:
QC> The book I was using to teach myself Perl never even mentions
QC> CGI.pm which means A) it is old or B) it isn't a very good book
QC> copyright 1998
B.
QC> I looked around and seem to have come to the conclusion that
QC> CGI.pm is sort of a way of making Perl object oriented. Anyway am
QC> I right in thinking that to use this you need to generate the form
QC> with perl as well as process it? Can you process info sent from a
QC> normal HTML form?
perl already is object oriented if you want to use that. CGI.pm is a
perl module that supports creating and parsing CGI forms. you can use it
in functional or object ways. it does not need to be used to create the
form in order to parse it. but that method has it big advantages if you
use it right.
check out the book "programming with cgi.pm" for a good tutorial and
reference to it. also it seems like you need to learn more perl so get
some good perl books. look for previous threads at dejanew to see what
this group considers good books.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Mon, 1 Feb 1999 22:08:23 +0100
From: "PsIoNnEkE" <bdispa@bigfoot.com>
Subject: Filtering...
Message-Id: <jJot2.31$5q4.885@afrodite.telenet-ops.be>
This is a multi-part message in MIME format.
------=_NextPart_000_0008_01BE4E2F.62657BC0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi !
I have a script that display's all filenames of a dir. Now I want that =
every file beginning with a '.' (dot) is filtered out... Every file =
comes in through a variable and is directly printed via the =
print-command. So no arrays are involved.
I though of an IF-THEN sequence, but I don't seem to get it work...
Somebody can help me ?
(if possible, pls reply via e-mail)
tnx...
--=20
Bram Dispa
bdispa@bigfoot.com
308692 [SP]
------=_NextPart_000_0008_01BE4E2F.62657BC0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.1012.1004" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi !</FONT></DIV>
<DIV></DIV>
<DIV><FONT face=3DArial size=3D2>I have a script that display's all =
filenames of a=20
dir. Now I want that every file beginning with a '.' (dot) is filtered =
out...=20
Every file comes in through a variable and is directly printed via the=20
print-command. So no arrays are involved.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I though of an IF-THEN sequence, but I =
don't seem=20
to get it work...</FONT></DIV>
<DIV></DIV>
<DIV><FONT face=3DArial size=3D2>Somebody can help me ?</FONT></DIV>
<DIV></DIV>
<DIV><FONT face=3DArial size=3D2>(if possible, pls reply via =
e-mail)</FONT></DIV>
<DIV></DIV>
<DIV><FONT face=3DArial size=3D2>tnx...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>-- <BR>Bram Dispa<BR><A=20
href=3D"mailto:bdispa@bigfoot.com">bdispa@bigfoot.com</A><BR>308692=20
[SP]</FONT></DIV></BODY></HTML>
------=_NextPart_000_0008_01BE4E2F.62657BC0--
------------------------------
Date: Mon, 1 Feb 1999 14:49:07 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: HELP with string parsing and scoring
Message-Id: <x3yk8y1nbv1.fsf@tigre.matrox.com>
Danny Paxton <paxtond@ix.netcom.com> writes:
>
> Hello...
>
> I am looking for some help. I am taking a 31 character string from an
> HTML FORM and attempting to treat each character as an individual answer
> to a question of a test. I am then trying to assign a certain number
> depending on the individual character (it changes depending on the
> answer and question number). I am then trying to keep a running total
> so that I can get an overall score. I have tried to use substr() to
I'm not sure substr() is the way to go here .. I would use split().
> isolate the idnividual characters of the string but am not enough of an
> accomplished perl programmer to see where my mistakes may lie. If
It's very hard to find mistakes in invisible code. Believe me, I
tried. Maybe if you perform that magical inchantment that causes the
code to appear. I believe that particular spell is called "Cut/Paste"
or something like that.
> someone could give me the first couple of lines of code I would greatly
> appreciate it.
No problem:
#!/usr/local/bin/perl -w
use strict;
> Thank you.
you're welcome.
Ala
PS. As a side note, I would do the following:
1) I would create an array of questions and answers, something like:
$qs[0] = { a => 1,
b => 2,
c => 3,
d => 4
};
This means, for question 0 (array index), answer 'a' receives 1
point. Answer b receives 2 .. etc ..
2) then:
my @answers = split //, $string;
my $score = 0;
for my $i (0..$#answers) {
$score += $qs[$i]{$answers[$i]};
}
print "Overall score is $score.\n";
------------------------------
Date: Mon, 01 Feb 1999 22:57:59 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Help! Problem searching for data in a large text file ..
Message-Id: <Xjqt2.37$wk3.2833@nsw.nnrp.telstra.net>
In article <917876756.23948.0.nnrp-06.c2ded70a@news.demon.co.uk>,
"Chris Bowring" <cbowring@softwareparadise.co.uk> writes:
> To whoever can help.....
> We are new to writing software in perl and have written an online catalog
> program which allows users/visitors to search for data in a fairly large
> sorted text file containing some 5000 line entries. It all works fine but we
> are getting constant complaints from the ISP hosting our site because of the
> time it takes for a wildcard/wordsanywhere sequential search to be performed
> on the file by multiple visitors to our site. (Understandable really)
> Can anyone suggest how we could reorganise the file and/or implement some
> better/more efficient searching techniques to appease our ISP before thery
> shut us down?
It's hard to tell exactly.
How is that text file sorted? on what? How is a search performed? Is
it dependent on the sorting order, or does it just blindly try to match
everything? Can you just match parts based on the sorting order?
You mention 'wildcard' searches, which sort of suggest that you cannot
use the sort order to limit the search scope.
Maybe you can break it up in smaller chunks based on your sort
criteria. This would only help though if that breaking up meant that
you wouldn't need to read all the files anyway.
You could consider having a small 'server' or 'daemon' process running
that does the actual search and stuff, while the clients just contact
that. (#perldoc perlipc for some suggestions)
It's really hard to be able to say what to do without knowing what the
criteria and data are.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Mon, 01 Feb 1999 22:44:22 GMT
From: burt@ici.net (Burt Lewis)
Subject: Re: Help! Problem searching for data in a large text file ..
Message-Id: <a7qt2.657$L5.12357@news.goodnet.com>
Hi,
This works for me.
Make sure your data file is sorted by a "key" field wich is a unique number.
Lets say you have 5000 products so your key numbers would be 1 to 5000, for example.
Break your 5000 line file into smaller files, maybe 500 lines each so you will have 10 files.
Something like:
file 1 = 1-500
file 2 = 501-549
etc...
In your script, have if statements something like:
if ($lookup >0 && <501)
{
OPEN FILE 1
}
if ($lookup >500 && <550)
{
OPEN FILE 2
}
==============================
This way you are never reading the entire 5000 line file and will greatly improve the speed.
Let me know how you make out.
Burt Lewis
burt@ici.net
www.eastonmass.com
In article <917876756.23948.0.nnrp-06.c2ded70a@news.demon.co.uk>, cbowring@softwareparadise.co.uk
says...
>
>To whoever can help.....
>We are new to writing software in perl and have written an online catalog
>program which allows users/visitors to search for data in a fairly large
>sorted text file containing some 5000 line entries. It all works fine but we
>are getting constant complaints from the ISP hosting our site because of the
>time it takes for a wildcard/wordsanywhere sequential search to be performed
>on the file by multiple visitors to our site. (Understandable really)
>Can anyone suggest how we could reorganise the file and/or implement some
>better/more efficient searching techniques to appease our ISP before thery
>shut us down?
>Are there any perl sites we could visit for tips or freeware code?
>Any help would be appreciated
>Thanks so much
>Chris Bowring & Phil Brewer.
>
>
------------------------------
Date: 1 Feb 1999 22:28:32 GMT
From: "Trang Ngo" <ngo_t@bls.gov>
Subject: imagemap
Message-Id: <01be4e32$33e79960$b9338e92@magee-b-psb.psb.bls.gov>
1. I am using perl5.004 with Apache 1.2.
2. My perl program in cgi-bin will invoke trgmap3.map such as
<A HREF="/cgi-bin/imagemap/maps/trgmap3.map?job=$jobs&month=$month"></a>
3. in /maps/trgmap3.map I could not get $job and $month resolve. For
instance,
<img src="../bucket/$job.gif" ISMAP>
poly /cgi-bin/analysis?thestate=ca&themonth=$month x,y, z
(x,y,z are the coordinate).
*** Seem to me when I tried to hard code for $job and $month, it was
working.
2nd try:
2) My perl program in cgi-bin will invoke trgmape.map such as:
<A HREF="/cgi-bin/trgmap3.map?job=$jobs&month=$month"></a>
3) My trgmap3.map will have
#!/opt/perl5.004/perl -w to get ENV_QUERY for variable jobs, month
after that everything here will be HTML format:
<img src="../bucket/$job.gif" ISMAP">
poly /cgi-bin/analysis?thestate=ca&themonth=$month x,y, z
(x,y,z are the coordinate).
STILL COULD NOT get $month resolves.
THIRD TRY:
1. ACTIVATE ADD HANDLER for Apache module imagemape.
2. then the rest is the same as first try. COULD NOT RESOLVE $job, $month.
SEEM TO ME you can't pass the parameters( only HARD CODE is working)
THANKS
trang ngo
ngo_t@bls.gov
------------------------------
Date: Mon, 1 Feb 1999 14:13:38 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: local($_) - why not "my"?
Message-Id: <x3ylniilyxr.fsf@tigre.matrox.com>
Martin GOLDSTERN <goldstern@tuwien.ac.at> writes:
> Why is "my $_" not allowed?
It is because lexical variables, declared by my(), do not reside in
the symbol table. They are stored separately in some array and are
only defined within the current scope.
$_, as well as other special Perl variables, always reside in the
symbol table, and are visible everywhere. You can local()ize them
though, but you can not declare them lexical via my(). That is their
nature, by definition (is this redundant?)
You can also have a look at perlfaq7 ..
What's the difference between dynamic and lexical (static)
scoping? Between local() and my()?
> "man perlsub" tells me:
> Only alphanumeric
> identifiers may be lexically scoped--magical builtins like
> $/ must currently be localized with "local" instead.
If you scroll down in perlsub, you can also find:
Variables declared with "my" are not part of any package and
are therefore never fully qualified with the package name.
In particular, you're not allowed to try to make a package
variable (or other global) lexical:
my $pack::var; # ERROR! Illegal syntax
my $_; # also illegal (currently)
> Does "currently" mean that in some later version of perl this will
> change? Where is the difficulty?
I am not sure what the "currently" means here. But I would guess that
that might have been legal code before. You see, lexical variables
were only introduced in Perl 5 (IIRC). But, as far as I know, there
are no plans to change that behaviour of my(). Anyone else care to
elaborate on this?
> Martin.Goldstern@tuwien.ac.at
Ala
------------------------------
Date: 01 Feb 1999 16:31:06 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Match Parens-More Perlish?
Message-Id: <39pv7tg6at.fsf@ibnets.com>
>>>>> "f" == frogsmock <frogsmock@my-dejanews.com> writes:
f> I've been messing with approaches to matching arbitrarily nested
f> constructs in Perl, and read with interest the various posts that
f> said it couldn't be done using regular expressions. Anyway, I'm
f> fairly new to Perl, and I've come up with this approach for
f> matching nested parentheses. But it *feels* ugly, so . . .
but your code doesn't do it with just regular expressions. no one said
it couldn't be done in perl. you have to do a full parse which you do in
a wierd sort of way. BTW the new regex stuff ilya is doing is supposed
to be able to directly parse nested parens.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Mon, 01 Feb 1999 22:41:14 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Match Parens-More Perlish?
Message-Id: <e4qt2.18$wk3.2833@nsw.nnrp.telstra.net>
In article <7954v5$hmf$1@nnrp1.dejanews.com>,
frogsmock@my-dejanews.com writes:
> I've been messing with approaches to matching arbitrarily nested
> constructs in Perl, and read with interest the various posts that
> said it couldn't be done using regular expressions. Anyway, I'm
> fairly new to Perl, and I've come up with this approach for matching
> nested parentheses. But it *feels* ugly, so . . .
Have you read what the perl FAQ has to say about this?
# perldoc perlfaq4
How do I find matching/nesting anything?
If you have, excuse me for pointing out the obvious. If you haven't,
you may be interested in the references to modules mentioned there.
> #!/usr/bin/perl
You should use -w, you know? and use strict.
> $txt =~ s/\(/*1*/gi; # replace "(" w/ *1*
> $txt =~ s/\)/*-1*/gi; # replace ")" w/ *-1*
Why do you do this? And why the i option? I mean, '(' is just as
identifiable as '*1*', otherwise you wouldn't be able to do this
subst anyway...
I'll change your code slightly, so it works without doing those
substitutions.
> while ($txt =~ /\*1\*/g) {
while ($txt =~ m|\(|g) {
> while ($remainder =~ /\*(-?1)\*/g) {
>
> $i += $1;
while ($remainder =~ /([()])/g)
{
# This could be more elegant
$i += ($1 eq ')') ? -1 : 1;
> $match =~ s/\*1\*/(/gi;
> $match =~ s/\*-1\*/)/gi;
delete the above 2 lines (and again, the i flag doesn't do anything
here)
Your program also ignores anything that is outside of any brackets.
You may need to do something about that :)
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Mon, 01 Feb 1999 21:20:41 GMT
From: kamez@my-dejanews.com
Subject: Perl syntax ( URGENT )
Message-Id: <7955r3$if9$1@nnrp1.dejanews.com>
hi everybody,
could anyone explain me in detail the meaning of the following lines
in Perl ( i'm not familiar with ) , so it'll help to better understand
to do other stuff :
1)
chop ------------> what's the meaning of "chop" ?
$line=$_;
$line =~ s/\s+/ /g; ------------------->?
@arr= split; ------------------->?
@val=split(/:/,arr[2]); $tt=val[0]; -------->?
2)
if ( ( index(line,"http-gw") !=-1)
&& ( index(line,"out=") !=-1) ) {
@array=grep(/^in=/,@arr);
@val=split(/=/,array[0]); in=val[1];
@array=grep(/^out=/,@arr);
@val=split(/=/,array[0]); out=val[1];
if (index(line,pcnserver) >= 0 ) {
t_pcn+=in+out;
Thanks for taking time to read this,
Thanks a lot for your help,
Khalid.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 01 Feb 1999 23:39:51 GMT
From: jimmy <jimmy@globalSpam.org>
Subject: Re: regex lib or Perl linked in?
Message-Id: <36B6397D.ED6C3A34@globalSpam.org>
>> Umm.. what's the problem? PCRE 1.0 had the regular expressions
>> of Perl 5.004, 2.0 has 5.005.
I guess I had a difficulty recognizing this very clear and highly
descriptive name--'pcre' as "Regular Expressions of Perl 5.004" <g>.
Silly me. How could one get lost in Unixish abbreviations! Well, now I
know, and so I'm off to get it. Thanks again.
------------------------------
Date: Mon, 01 Feb 1999 23:50:04 GMT
From: jimmy <jimmy@globalSpam.org>
Subject: Re: regex lib or Perl linked in?
Message-Id: <36B63BE3.A5BD60D9@globalSpam.org>
Got it. Super. Thanks.
------------------------------
Date: Mon, 01 Feb 1999 22:23:35 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: regexp match fail:
Message-Id: <HPpt2.17$wk3.2833@nsw.nnrp.telstra.net>
In article <794it8$g8p@bgtnsc01.worldnet.att.net>,
"sysadmin" <charlesjourdan@worldnet.att.net> writes:
> I have a file with about 2000 lines
> divided into blocks looking much like this:
[SNIP blocks]
> I want to identify each block then read the lines 3-7 (within the scope of
> the block)
> The block line number is the 3rd arg
Instead of reading the file line by line, you could consider putting
perl in 'paragraph mode' by setting $/ to the empty string. If you are
certain that each block is ended by two newlines, you could use $/ =
"\n\n". This is not the same.
# perldoc perlvar
{find $/ entry}
local $/ = "";
while (<DATA>)
{
# Got a whole block in here, limited by paragraph.
> 1. Filtering out lines 1-2 (because 2 does not represent
> quantities, but sizes)
I am assuming here that lines 1-2 are actually 4 lines in your post,
which got wrapped by your news reader. The reason I am asuming that is
that that part of athe block looks different from the rest, and your
code suggests the same
# Split $_ up in individual lines
#
# Note, this also gets rid of trailing newlines
#
my @lines = split "\n";
# get rid of the lines you don't need here, probably with splice
# Use unpack here on each of the lines, as you need it
}
> 2. Reading the 000000102010201020 string regardless of whether it is
> argument 5 or 4
Which string? I don't see that string, and I am also not sure what you
mean by argument 4 or 5.. Do you mean the lines numbered 4 or 5?
Could you be more specific?
As suggested above: For strings that have a fixed format, unpack is
probably better than a pattern match. It seems however that lines
marked with 3 and 4 are slightly different. This is still no problem,
since you have the lines in an array above for each of the blocks.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Mon, 01 Feb 1999 22:13:19 GMT
From: llowe@ltdcommodities.com
Subject: Running an .EXE in a perl script
Message-Id: <7958tq$kt2$1@nnrp1.dejanews.com>
I am new to programming and perl. I am a network admin that wants to
automate some tasks. I need to know if it is possible to run an .exe in the
perl script. I have a basic script that will cycle through a list of machine
names and I want to use the variable (machine name in a command line .exe
from the resource kit.
I have tried to find this info and I am stuck. If this cannot be done or is a
foolish question please have mercy.
Lonnie Lowe
llowe@ltdcommodities.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 01 Feb 1999 22:45:42 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Running an .EXE in a perl script
Message-Id: <q8qt2.19$wk3.2833@nsw.nnrp.telstra.net>
In article <7958tq$kt2$1@nnrp1.dejanews.com>,
llowe@ltdcommodities.com writes:
> I am new to programming and perl. I am a network admin that wants to
> automate some tasks. I need to know if it is possible to run an .exe in the
I suppose that with .exe you mean some sort of executable?
# perldoc -f exec
# perldoc -f system
# perldoc perlop
[look for `STRING`]
If you for some reason don't know about the perldoc program, or can't
or won't use the command line: The ActiveStatse perl comes with these
documents in html form. Find them, and look at the perlfunc and
perldoc pages.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Mon, 01 Feb 1999 23:21:06 +0000
From: paul <paulrafiq@csi.com>
Subject: Re: Running an .EXE in a perl script
Message-Id: <36B636E1.5DFC6437@csi.com>
Try the perl
return_code=system("prog_to_run.exe","arg1","arg2",..etc)
which will wait for the prog_to_run.exe to complete.
You can then check the return_code.
See the perlfunc man page.
llowe@ltdcommodities.com wrote:
> I am new to programming and perl. I am a network admin that wants to
> automate some tasks. I need to know if it is possible to run an .exe in the
> perl script. I have a basic script that will cycle through a list of machine
> names and I want to use the variable (machine name in a command line .exe
> from the resource kit.
>
> I have tried to find this info and I am stuck. If this cannot be done or is a
> foolish question please have mercy.
>
> Lonnie Lowe
> llowe@ltdcommodities.com
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 01 Feb 1999 21:39:42 GMT
From: gibsonc@aztec.asu.edu
Subject: Source to web-based newsgroup
Message-Id: <7956uu$jbc$1@nnrp1.dejanews.com>
Can someone tell me where to get the source for a web-based news group similar
to dejanews?
Thanks for your time.
gip_123@yahoo.com
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 1 Feb 1999 16:48:44 -0000
From: "John Corbin" <jcorbin@apci.net>
Subject: Using Net
Message-Id: <36b62efa.0@queeg.apci.net>
I have run across a line in a source file that reads;
use Net::Telnet;
When I try to use this source it says;
Can't locate Net/Telnet.pm in @INC (@INC contains: C:\PERL\lib\site
C:\PERL\lib
c:\perl\lib c:\perl\lib\site c:\perl\lib\site .) at finger.pl line 1.
BEGIN failed--compilation aborted at finger.pl line 1.
I looked thru the FAQ but cant seem to find anything that pertains to
this....whats the problem. I am using Win32, Perl 5.004_04. What's the
problem?? Any help is much appreciated....
--
John
jcorbin@apci.net
------------------------------
Date: Mon, 01 Feb 1999 17:03:41 -0600
From: Sven Davies <svend@lubypublishing.com>
Subject: Re: Visual Perl?
Message-Id: <36B632CD.2CEF@lubypublishing.com>
Charles R. Thompson wrote:
>
> >Meanwhile if anyone has heard of an application that new what I
> wanted
> >and could program it for me, please let me know. It sure would
> be
> >helpful.
>
> It's an archaic system called Employees 1.0 based off of the
> BIOLOGY::Human package. It's still in Beta because no matter how
> many times you run your code through the parser, it doesn't know
> what you want.
>
> :)
Yeah, this reminds me of a popular program called GirlFriend 1.0. It
doesn't always know what you want either. But then again, I don't think
it is a Perl Script.
yours,
--
========================================================
Sven T. Davies http://www.lubypublishing.com |
On-Line Coordinator http://www.billiardsdigest.com |
Luby Publishing http://www.bowlersjournal.com |
========================================================
------------------------------
Date: Mon, 01 Feb 1999 18:12:01 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Visual Perl?
Message-Id: <fl_aggie-0102991812020001@aggie.coaps.fsu.edu>
In article <7954c5$8js@bgtnsc01.worldnet.att.net>, "Charles R. Thompson"
<design@raincloud-studios.com> wrote:
+ It's an archaic system called Employees 1.0 based off of the
+ BIOLOGY::Human package. It's still in Beta because no matter how
+ many times you run your code through the parser, it doesn't know
+ what you want.
Its also in beta because it has to support a few million years of legacy
code... :)
James - dna, perl, whatever... :)
------------------------------
Date: 01 Feb 1999 17:02:07 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Visual Perl?
Message-Id: <m3679l4qrk.fsf@moiraine.dimensional.com>
fl_aggie@thepentagon.com (I R A Aggie) writes:
> dna, perl, whatever... :)
<topmind>
It's all incomprehensible and should be banned, DAMNIT!!!!!!!!
</topmind>
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 4800
**************************************