[16708] in Perl-Users-Digest
Perl-Users Digest, Issue: 4120 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 24 14:10:30 2000
Date: Thu, 24 Aug 2000 11:10:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967140617-v9-i4120@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 24 Aug 2000 Volume: 9 Number: 4120
Today's topics:
Re: redirect script just providing an HREF, not redirec (Abigail)
Re: redirect script just providing an HREF, not redirec (Abigail)
RegEx zejames@my-deja.com
Re: RegEx <care227@attglobal.net>
Re: Self-Answering Questions (Was Re: Flipflop matching <lr@hpl.hp.com>
Re: To push or not to push <smerr612@mailandnews.com>
Re: unpack format question <lr@hpl.hp.com>
Where is the Perl Newbie or Begginers group? <gdonovanNOgdSPAM@jeffco.k12.co.us.invalid>
Re: Where is the Perl Newbie or Begginers group? <elephant@squirrelgroup.com>
Re: Where is the Perl Newbie or Begginers group? <care227@attglobal.net>
Win32 Registry and IP addresses. <psb154@yahoo.com>
Re: Win32 Registry and IP addresses. <elephant@squirrelgroup.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 24 Aug 2000 15:25:31 GMT
From: abigail@foad.org (Abigail)
Subject: Re: redirect script just providing an HREF, not redirecting as I'd like
Message-Id: <slrn8qafhu.tj3.abigail@alexandra.foad.org>
dack@visi.com* (dack@visi.com*) wrote on MMDXLIII September MCMXCIII in
<URL:news:399b71ce.192389942@news.visi.com>:
`` I have successfully determined if the user is visiting the site with a
`` phone or a PC, but the redirect script doesn't take them there
`` directly; it only provides them with an HREF they need to click on.
`` What am I doing wrong? Here is the script:
The HTTP RFC can tell you what you did wrong. It has nothing to do with Perl.
Abigail
--
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_;
sub _ {push @_ => /::(.*)/s and goto &{ shift}}
sub shift {print shift; @_ and goto &{+shift}}
Hack ("Just", "Perl ", " ano", "er\n", "ther "); # 20000724
------------------------------
Date: 24 Aug 2000 15:28:18 GMT
From: abigail@foad.org (Abigail)
Subject: Re: redirect script just providing an HREF, not redirecting as I'd like
Message-Id: <slrn8qafn2.tj3.abigail@alexandra.foad.org>
J. M. (Jens) (jellegie@ford.com) wrote on MMDXLIII September MCMXCIII in
<URL:news:399B830C.6204AA6A@ford.com>:
--
-- This is simple: You mustn't print the Content-type when you want to
-- redirect the browser.
That is incorrect. See the HTTP RFC. What he did wrong was something else,
but that answer can be found in the HTTP RFC. Or he goes asking in a more
appropriate group.
-- In short: The Content-type and the Location are so-called headers not
-- visible to a user. So you tell the browser that everything that follows
-- is text especially html text. By using a double newline character at the
-- end, you tell the browser that this is the last header and that the rest
-- is content. And voila, your location is displayed in the browser.
Right. And that's something else than you describe above.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: Thu, 24 Aug 2000 15:28:00 GMT
From: zejames@my-deja.com
Subject: RegEx
Message-Id: <8o3et2$p0d$1@nnrp1.deja.com>
Hello everybody,
I have a question about regex for you. I don't understand why this:
$name = "/usr/local/bin/perl";
($test) = ( $name =~ m#/(.*)# );
print "$test\n";
Why do I see usr/local/bin/perl on my screen, whereas I would
expect usr/local/bin/perl , cause of the fact that Perl
tries to match the motif as many times as it can, and chooses the last
one.
Can anyone tell me?
Thank you
James
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 24 Aug 2000 12:01:29 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: RegEx
Message-Id: <39A546D9.A50F4CB7@attglobal.net>
zejames@my-deja.com wrote:
>
> Hello everybody,
>
> I have a question about regex for you. I don't understand why this:
>
> $name = "/usr/local/bin/perl";
>
> ($test) = ( $name =~ m#/(.*)# );
>
> print "$test\n";
>
> Why do I see usr/local/bin/perl on my screen, whereas I would
> expect usr/local/bin/perl , cause of the fact that Perl
> tries to match the motif as many times as it can, and chooses the last
> one.
>
Wha?
mo·tif (m-tf)
n.
1.
a.A recurrent thematic element in an artistic or literary work.
b.A dominant theme or central idea.
2.Music. A short significant phrase in a composition.
3.A repeated figure or design in architecture or decoration.
We must try to use appropriate words, ok?
Now then, the only difference in what you got and what you expected
is that you expected spaces? But why? The above example is:
$name =~ m#/(.*)#
where the regex is:
/(.*)
which says "match a leading slash followed by anything or nothing."
There is no substitution, and the whole string obviously matches, so
that is what is assigned to $test. What about this don't you
understand?
------------------------------
Date: Thu, 24 Aug 2000 10:10:08 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Self-Answering Questions (Was Re: Flipflop matching)
Message-Id: <MPG.140ef6cfa9635a3498acd4@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <x7wvh7sbq7.fsf@home.sysarch.com> on Thu, 24 Aug 2000
01:13:04 GMT, Uri Guttman <uri@sysarch.com> says...
> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
...
> that list just shows you larry (the wall's) linguistic background. and it
> highlights the interesting split of perl into line noise and well chosen
> english words.
A lot of the background is in Unix, because many of those English words
are the names of traditional Unix system calls. But at least he spared
us from 'creat'.
Many of the other words (including syntactic elements I didn't quote,
such as 'do', 'for' and 'while') are adopted from C. I don't know why
'last' replaced 'break', or 'next' replaced 'continue', though. And
there's still no 'switch' or 'case'. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 24 Aug 2000 16:49:38 GMT
From: Steven Merritt <smerr612@mailandnews.com>
Subject: Re: To push or not to push
Message-Id: <8o3jmq$v79$1@nnrp1.deja.com>
In article <x766ortvbd.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> wrote:
> >>>>> "SM" == Steven Merritt <smerr612@mailandnews.com> writes:
>
> SM> sub Parse_LogLines{
>
> SM> foreach $_ (@LogLines){
>
> $_ is the default variable in foreach loop so that is redundant.
True, fixed.
> SM> if (! $Record-> {Status} ) {
> SM> $Record-> {Status} = "None";
> SM> }
>
> $Record->{Status} ||= "None";
>
> is cleaner. also lose the space after ->. it is ugly.
That certainly is cleaner. I kind of like the space, it keeps me
straight in remembering that $Record is just a reference and {Status} is
really the key, but I'll change it if that's widespread convention, I
want this code to be maintainable and I don't want to throw someone off
with -> {blah} when they were expecting ->{blah}
> SM> ($Record-> {Oper}, $Record-> {Status}) = split /Status:
/,
> SM> substr($_, 22);
>
> SM> if (/Transaction: Phone/){
> SM> $Record-> {Oper} =~ s/Transaction: Phone\s+//;
> SM> }
> SM> chomp $Record-> {Oper};
>
> since the oper field comes before the end of the line according to
your
> split, it can't have a newline so the chomp is useless.
Here is the first of many things that has me beating my head against the
wall over this logfile. There isn't always a status field. There isn't
always a "Transaction: Phone" either. Sometimes it's just the operators
name and a bunch of padded spaces. So to get nice output formatting, I
have to strip off the "Transaction: Phone" (if it exists) capture the
status(if it exists) and handle the case where neither exists(what the
chomp does). But wait, it gets better, read on. Mgt. has allowed
people to manually edit this file with vi or whatever text editor they
feel like using. So not only can I not count on always having these
fields, they're not fixes length and not even always in the same order.
I've told my boss that I'll do my best to parse all the records, but I
can't guarantee 100% accuracy when I get records with just a name and
description. One of the things I've made them promise me is that when
this is all done, they won't let people edit this logfile by hand
anymore, they'll use the log entry tool.
> SM> }
>
> SM> elsif (/^\s+Release:*/) {
> SM> $Record-> {SR} = $_;
> SM> # print $Record-> {SR};
> SM> }
> SM> elsif (/^\s+Application:*/) {
>
> these elsif's are not nested, so don't indent them progressively which
> is misleading. they are really at the same level.
True, I've fixed the indenting.
> SM> elsif (/^\s+Pegasys\/EER Ticket:*/) {
>
> use alternative delimiters so you don't need to backwhack the /
>
Does this cause problems, or is it just a style thing to prefer not to
have to escape things in regexes? It's working fine, should I be
looking for potential problems?
> SM> foreach $_ (@LogLines){
>
> that line is odd. you can't loop over the same set of lines here as
you
> do in the main loop. you are starting over here and overlapping
> with lines you have parsed already.
>
> this style is better done with:
>
> while( @LogLines ) {
>
> $line = shift @LogLines ;
>
> then you can slurp in more lines in an inner loop using the same code
> and you will always get the next line no matter where you are. or
don't
> have all the lines read in to the array and use <FILE> to get them.
I've switched to this construct, but there's a problem, the $line =
shift @LogLines doesn't advance the array element subscript the outer
foreach loop is using, it would if I were using <>. So what's happening
is this:
20000523 17:48:34 Jeff None
SR field did not exist at time of this record's creation
Application: wf
Environment: prod
Referencing Phone: 4721
Referencing Party: Ericka Alles
Pegasys/EER Ticket:
/staged/00b5a/wf*6/. per Ericka. She said she would deal with
it in the
20000523 17:48:34 Jeff None
SR field did not exist at time of this record's creation
Application: wf
Environment: prod
Referencing Phone: 4721
Referencing Party: Ericka Alles
Pegasys/EER Ticket:
/staged/00b5a/wf*6/. per Ericka. She said she would deal with
it in the
I get duplicate records(because the outer counter doesn't advance) and
the really wierd part is it only captures the first line of the
description, even the first time through. The construct now looks like
this:
# If we've got some non-whitespace field which doesn't have any of the
# identifing marks of the other fields, it must be part of the desc.
elsif (/\S/) {
# grab the current line
$Desc = $_;
# Let's grab a few more lines until we come to the end of record pattern
while( @LogLines ) {
my $line = shift @LogLines;
last if (/^\s\n/, $line);
$Desc .= $line;
}
# Now $Desc should have the first line that wasn't obviously a part of
# another field and all the lines that follow it until we get to the
# space-newline record delimiter
$Record->{Desc} = $Desc;
# And just to make our workday even more fun, sometimes the SR field
# doesn't exist, we better fill this variable.
$Record->{SR} |= " SR field did not exist at time of
this record's creation\n";
push @Recs, $Record;
And yet somehow $Desc doesn't contain more than the first line of the
description each time. The first time it satisfies the elsif for the
Desc it should work properly, concatenate all the lines of the desc, but
it doesn't.
Actually, as I was reading this over before I send it, I think I figured
out the problem. The while loop is doing the same thing the foreach was,
starting from the top of the array. The first line in the array, and
the first line in all the logfiles is the end of record delimiter, so
the while loop dies immediately and never concatenates. But that still
doesn't explain why on future loops through it keeps grabbing the same
line. I guess I may have to code this whole thing with for loops and
have an array index I can explicitly change to sync up the inner and
outer loops to keep them from working on the same elements over and
over. I'll work on that after lunch, I'm hoping someone else has a
suggestion and I won't have to resort to that, it feels so c-ish.
Anyway, thanks for the response Uri and any further insight would be
appreciated as well.
Steven
--
King of Casual Play
The One and Only Defender of Cards That Blow
My newsreader limits sigs to four lines, but I cleverly bypassed this by
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 24 Aug 2000 10:39:11 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: unpack format question
Message-Id: <MPG.140efd97227e6dde98acd6@nntp.hpl.hp.com>
In article <39a5319f.71040400@nntpa.cb.lucent.com> on Thu, 24 Aug 2000
14:34:31 GMT, Fred R. Buck <frbuck@bell-labs.com> says...
> open(hBinFile, "<$ARGV[0]") or die "could not open $ARGV[0] as
> hBinFile";
> binmode(hBinFile);
> read (hBinFile, $header, 4+4+2+4+128+4+4);
> ($id, $idx, $count, $length, @binblock, $progn, $pcount) =
> unpack('IISIC128II', $header);
>
> given the script fragment above my problem is the number of bytes
> extracted into @binblock. When I run the script $#binblock yields 129
> and empty values for $progn and $pcount. $id, $idx, $count and $length
> all contain appropriate values after the unpack.
>
> If I increase the read size so more data is available and add
> additional "I"'s to the format $#binblock increases by 1 for each
> additional "I" I add to the format.
>
> Why? I thought that counts i.e. C128 were absolute limits.
It doesn't have anything to do with the unpack format.
An array in a list assignment sucks up all the remaining values in the
list being assigned. This is well documented, but at first shot I found
this in perlsub:
Do not, however, be tempted to do this:
(@a, @b) = upcase(@list1, @list2);
Like the flattened incoming parameter list, the return list is also
flattened on return. So all you have managed to do here is stored
everything in @a and made @b an empty list. See Pass by Reference for
alternatives.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 24 Aug 2000 07:45:21 -0700
From: sysnovice <gdonovanNOgdSPAM@jeffco.k12.co.us.invalid>
Subject: Where is the Perl Newbie or Begginers group?
Message-Id: <1f1200dc.18c6c27a@usw-ex0109-069.remarq.com>
Hello,
I am a Unix SysAd with no programming experience looking for
a discussion group for Perl beginners like myself that don't
have a clue. I'm so new I don't even know where to find
FAQ's. It's evident that from many postings here that the
experienced Perl programmers are more than a bit annoyed
with folks like myself posting "dumb" questions. Does
someone out there know of a group for the retarded perl
wanabes? If I could find such a place I would address all my
questions there until the year 2025 when I may have a
question intelligent enough for this discussion group.
Thanks for your help.
G.Donovan
* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful
------------------------------
Date: Thu, 24 Aug 2000 15:28:23 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Where is the Perl Newbie or Begginers group?
Message-Id: <MPG.140fdc8c621fb9de9896ea@localhost>
sysnovice <gdonovanNOgdSPAM@jeffco.k12.co.us.invalid> wrote ..
>I am a Unix SysAd with no programming experience looking for
>a discussion group for Perl beginners like myself that don't
>have a clue. I'm so new I don't even know where to find
>FAQ's. It's evident that from many postings here that the
>experienced Perl programmers are more than a bit annoyed
>with folks like myself posting "dumb" questions. Does
>someone out there know of a group for the retarded perl
>wanabes? If I could find such a place I would address all my
>questions there until the year 2025 when I may have a
>question intelligent enough for this discussion group.
can't help you with a specific beginner group .. and even if I knew of
one I can't imagine recommending it to anyone - novices helping
beginners in Perl is a scary thought indeed (though it would explain Mr
Wright)
BUT
start by reading some of the documentation that's included with Perl ..
assuming you've already installed Perl then in most systems from a
command prompt type
perldoc perldoc
and start reading .. the included FAQ is extensive and searchable (which
the perldoc manual will explain how to do)
it's really not that difficult to get through this c.l.p.misc baptism of
fire relatively unscathed .. read the FAQ first before asking a question
.. read the relevant pieces of the documentation .. then post a clear
subject line (which you seem to already have the hang of) and a clear
question about a specific Perl issue
if it's an issue relating to code then include a small working example
of the problem .. include the version of Perl that you're using (which
should be at least 5.005) .. and your expected outcome .. and if it's at
all possible that it's relevant - your operating system
oh .. and - like this post - cut off the signature of what you're
responding to - and any irrelevant parts of the post .. and reply
underneath (or interleaved) what you're quoting
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 24 Aug 2000 12:10:03 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Where is the Perl Newbie or Begginers group?
Message-Id: <39A548DB.9E342889@attglobal.net>
sysnovice wrote:
>
> Hello,
>
> I am a Unix SysAd with no programming experience looking for
> a discussion group for Perl beginners like myself that don't
> have a clue. I'm so new I don't even know where to find
> FAQ's.
The FAQ is included with the standard perl distribution,
as is all the documentation. Its also all posted on the
web at http://www.perl.com
> It's evident that from many postings here that the
> experienced Perl programmers are more than a bit annoyed
> with folks like myself posting "dumb" questions.
Wrong. People are annoyed by others posting questions that
have been answered over and over again. When the answer to a
question is available in a FAQ, the documentation or the
archive of this very group, asking it again serves no
purpose. Asking for clarification or additional information
or posing a new question is never bothersome to anyone,
not that I've seen at least.
> Does
> someone out there know of a group for the retarded perl
> wanabes?
You are in it. Wannabees and Wizards all welcome. Just
check your ego at the door, or it might get bruised.
Another good resource is the new PerlMonks site, at
www.perlmonks.org
> If I could find such a place I would address all my
> questions there until the year 2025 when I may have a
> question intelligent enough for this discussion group.
> Thanks for your help.
HAND
------------------------------
Date: 24 Aug 2000 16:10:40 +0100
From: Paul Butterfield <psb154@yahoo.com>
Subject: Win32 Registry and IP addresses.
Message-Id: <ud7iyvgnj.fsf@yahoo.com>
Given the following information:
IP address.
SubNet mask
Default Gateway
DNS server
How would I get PERL on win32, to put them in the correct places in the
NT4 registry?
Have not thought this through too much so any suggestions would be great.
The purpose is:
Setting up a bunch of NT computers in a QA lab. The hard disks are
constantly formated. I want to keep all computer network details in a
text file database. Then from a command line type something like:
addip.pl computerName
Then hopefully the above information will be put into the computer's
registry.
Thank you.
--Paul.
------------------------------
Date: Thu, 24 Aug 2000 15:32:03 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Win32 Registry and IP addresses.
Message-Id: <MPG.140fdd68a5ea43459896eb@localhost>
Paul Butterfield <psb154@yahoo.com> wrote ..
>Given the following information:
>IP address.
>SubNet mask
>Default Gateway
>DNS server
>
>How would I get PERL on win32, to put them in the correct places in the
>NT4 registry?
there are two modules (now) included as standard with the Win32 Perl
distribution .. one called Win32Api::Registry and one called
Win32::TieRegistry
use whichever one seems more natural to you (they both have very
different interfaces) to place the values in the appropriate place in
the NT registry
the rest of the program should write itself .. read the file .. find the
details for that computer .. then enter them in the registry
--
jason -- elephant@squirrelgroup.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 V9 Issue 4120
**************************************