[10369] in Perl-Users-Digest
Perl-Users Digest, Issue: 3963 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 13 14:39:36 1998
Date: Tue, 13 Oct 98 10:01:32 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 13 Oct 1998 Volume: 8 Number: 3963
Today's topics:
Re: Max lines in an Array? (Abigail)
Re: need help with an interactive gannt chart <rootbeer@teleport.com>
Re: Need IP Address Sort Subroutine <williams@clark.net>
NET::FTP problem <mark@uninetwork.com>
Re: Newbie needs help transposing two words in a file (Sean McAfee)
Re: Perl freezes when using special characters in HTML (Ruud Limbeck)
Re: Q: How to Create Machines on the Domain? <john_scrimsher@ex.cv.hp.com>
Replacing a string only if not in HTML tags <antti.boman***NOSP@M***helsinki.fi>
Re: Replacing a string only if not in HTML tags <rootbeer@teleport.com>
Re: sorting hack <jimbo@soundimages.co.uk>
Re: sorting hack <jdporter@min.net>
Re: sorting hack <dgris@perrin.dimensional.com>
Re: sorting hack <jimbo@soundimages.co.uk>
Re: Sorting hash by value, not key <aqumsieh@tigre.matrox.com>
Re: Statistics for comp.lang.perl.misc <jdporter@min.net>
Re: unidirectional pipe into interactive program (passw <aperrin@mcmahon.qal.berkeley.edu>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Oct 1998 16:22:45 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Max lines in an Array?
Message-Id: <6vvuol$6b2$2@client3.news.psi.net>
Doyle Johnson (sales@madm.com) wrote on MDCCCLXVIII September MCMXCIII in
<URL:news:6vu4o4$egq$1@nnrp03.primenet.com>:
++ Hi again,
++
++ Im beginning to think the out of mem errors are more to do with a
++ possible maximum amount of lines allowed in an @Array instead of physical
++ mem.
You think wrongly.
++ Is there a limit to the number of lines you can stuff into an array?
Yes. It's bounded by the memory the kernel is giving the process.
++ or is
++ there a buffer size that can be adjusted?
Not in Perl. But perhaps in your OS.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: Tue, 13 Oct 1998 16:49:58 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: need help with an interactive gannt chart
Message-Id: <Pine.GSO.4.02A.9810130948590.1979-100000@user2.teleport.com>
On Tue, 13 Oct 1998, Webmaster wrote:
> Can anyone help me, please reply in this newgroup
Sure, I can help you. For people who ask questions like this, my standard
rate is $250 per hour. The good news is that this first minute is free.
Now, what help do you need?
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 13 Oct 1998 11:39:43 -0500
From: "Joe Williams" <williams@clark.net>
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <6vvvon$n1p$1@news.onramp.net>
I still don't think I'm interpreting correctly the binary structure produced
by pack with C4 used on IP octets, as in: pack("C4",199,77,210,67) .
I thought this would produce the binary equivalent of the IP address, but it
doesn't seem to. If it did, the bintodec function below should convert the
structure to the decimal equivalent of the binary address, which by my
calculations is 3,343,766,083, and that doesn't happen.
The reason is, I think, that the string with the IP octets, 199 77 210 67 is
being packed as ASCII characters, not as the binary equivalent of the
decimal numbers 199, etc.
All this must seem obvious to programs who are used to the pack function,
but I'm still looking for the light switch here!
What is the easiest way to take a look at the packed structure in binary?
It looks like pack with the C4 template is the standard way Perl uses to
convert IP octets into something manageable, and as I mentioned earlier, the
sort char sort works fine on it. I just don't understand why, certainly in
part because I don't understand the binary structure that
(pack("C4",199,77,210,67) is producing.
# Ain't working:
print bintodec(pack("C4",199,77,210,67),"\n");
sub bintodec { unpack("N", pack("B32", substr("0" x 32 . shift, -32) ) ); }
Joe Williams wrote in message <6vtng2$2kr$1@news.onramp.net>...
>Michael - This is very helpful. Many TXs.
>
>I see better what the code is doing now. It is taking the four quads of an
>IP address and converting
>them to binary (I assume this is in 8-bit chunks since it is using the
ASCII
>format.) Then this is
>stuffed into a string. Elementary, my dear Watson--but not until you gave
me
>a few hints!
>
>This approach actually recreates the 32-bit IP address in binary form, then
>when it is sorted
>as characters, that works fine, because it is sorting on the four octets
>giving the leftmost octets
>the most importance. Actually, you could sort on the binary number as well,
>but I assume Perl's
>built in sort routine sorts on decimal numbers written in ASCII, and that
>won't work well on this
>kind of structure. Right?
>
>Here is why I was confused:
>
>Your example prints out fine:
>print pack("C4",48,49,50,51),"\n";
>print "\n";
>
>However, the following is what I used as an example, and this doesn't print
>out so fine--
> for reasons now obvious.
>print pack("C4",199,77,210,67),"\n";
>
>This is OK of course:
>print unpack ("C4", get_ipa ("199.77.210.67") );
>
>sub get_ipa{
> $_[0] =~ /([\d.]+)/;print "\n";
> return pack("C4",split(/\./,$1));
>}
------------------------------
Date: Tue, 13 Oct 1998 11:34:49 -0400
From: Mark Cain <mark@uninetwork.com>
Subject: NET::FTP problem
Message-Id: <36237318.465BD6B1@uninetwork.com>
I am trying to utilize the NET::FTP module in a perl solution. I can't
identify the cause of the failure of the following script. No error
messages pertaining to this failure are logged on the server. Can you
help me identify why this returns "get failed at line ..." ?
I have confirmed that:
- I do get logged in.
- the file does exist on the server in the pwd.
- I have permissions to the directory and the file
- It also fails with the "put" command
#!/perl5 for win32
use strict;
use NET::FTP;
my $site = "www.abc.cba";
my $UserName = "abc";
my $Password = "cba";
my $file = "myfile.html";
my $ftp = Net::FTP->new("$site");
# Login to FTP site
print("\nLogin: $site ...");
$ftp->login($UserName, $Password) or die "\nlogin failed: $!";
$ftp->cwd("/logs/") or die "\ncwd failed: $!";
$ftp->binary() or die "\nbinary failed: $!";
$ftp->get($file) or die "\nget failed: $!";
$ftp->quit;
Thanks,
mark
------------------------------
Date: Tue, 13 Oct 1998 15:39:47 GMT
From: mcafee@battlezone.rs.itd.umich.edu (Sean McAfee)
Subject: Re: Newbie needs help transposing two words in a file
Message-Id: <7vKU1.1586$fS.4619215@news.itd.umich.edu>
In article <6vvl2f$4er$1@fir.prod.itd.earthlink.net>,
Bitstream <bitstream@excite.com> wrote:
>I'm a Perl newbie and am having difficulty trying to transpose two words in a
>file...for example the file contains several hundred lines that look like
>this:
>SMTP:last.first@company.com
>I need them to all be changed to:
>SMTP:first.last@company.com
If you have Perl 5.005 installed, do this:
while (<FILE>) {
s/(?<=SMTP:)(\w+)\.(\w+)(?=\@company\.com)/$2.$1/;
}
With Perl 5.004, it's only slightly less elegant:
while (<FILE>) {
s/SMTP:(\w+)\.(\w+)(?=\@company\.com)/SMTP:$2.$1/;
}
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: Tue, 13 Oct 1998 14:47:15 GMT
From: ruud.limbeck@tip.nl (Ruud Limbeck)
Subject: Re: Perl freezes when using special characters in HTML
Message-Id: <36236660.6328599@news.NL.net>
On 13 Oct 1998 15:40:55 +0200, Jonathan Feinberg <jdf@pobox.com>
wrote:
>Perl does not have a submit button; your browser does.
Ok. I know perl doesn't have a submit-button of course.
> I think you're
>having a problem with your web browser, and not with your Perl
>script.
I'm working with the latest versions of MSIE and NS ....
The only thing I want is to start a very tiny perl-program to make an
environment-variable out of the input-fields of the html-form, and
start my own application.
>Have you seen this document?:
>
> http://language.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html
>
No. Thanks a lot. Just printed it. The 'flush STDOUT' will be usefull
in this case I hope.
Jonathan, thank you very much for helping in this !!!
Ruud Limbeck
------------------------------
Date: Tue, 13 Oct 1998 08:13:33 -0700
From: "John P. Scrimsher" <john_scrimsher@ex.cv.hp.com>
Subject: Re: Q: How to Create Machines on the Domain?
Message-Id: <6vvqms$i0g@hpcvsnz.cv.hp.com>
George Kuetemeyer wrote in message <3622B693.C7EF64AD@mail.tju.edu>...
>
>
>User and machine accounts are really pretty much the same thing. Just
append a
>'$' to account names that you want to be machine accounts & use a different
>account flag value. (I don't think you need the '$', but it appears that
>Microsoft's utilities filter user and machine accounts based on that
symbol).
Thanks much!!! It works like a charm.
John Scrimsher
john_scrimsher@hp.com
------------------------------
Date: Tue, 13 Oct 1998 18:32:25 +0200
From: "Antti Boman" <antti.boman***NOSP@M***helsinki.fi>
Subject: Replacing a string only if not in HTML tags
Message-Id: <6vvrot$jmh$1@hiisi.inet.fi>
Sorry if this is a FAQ, I couldn't find the answer.
I have an array of words, and I should highlight them in an HTML-file (by
putting them in <font color="..."></font>). How can I replace the word only
if it's not within <>'s. I tried and found my head empty.
-a
------------------------------
Date: Tue, 13 Oct 1998 16:55:10 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Replacing a string only if not in HTML tags
Message-Id: <Pine.GSO.4.02A.9810130953480.1979-100000@user2.teleport.com>
On Tue, 13 Oct 1998, Antti Boman wrote:
> I have an array of words, and I should highlight them in an HTML-file
> (by putting them in <font color="..."></font>). How can I replace the
> word only if it's not within <>'s. I tried and found my head empty.
You'll need to parse the HTML. Try the HTML::Parser module from CPAN. Hope
this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 13 Oct 1998 17:26:36 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: sorting hack
Message-Id: <u3e8s1l8j.fsf@jimbosntserver.soundimages.co.uk>
abigail@fnx.com (Abigail) writes:
> sort {my $i = 0; {return 0 if $#{$a} < $i && $#{$b} < $i;
> return -1 if $#{$a} < $i;
> return +1 if $#{$b} < $i;
> $a -> [$i] <=> $b -> [$i] or do {$i ++; redo}}} @list;
How would you write it without the deprecated $#?
--
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.
------------------------------
Date: Tue, 13 Oct 1998 12:30:42 -0400
From: John Porter <jdporter@min.net>
Subject: Re: sorting hack
Message-Id: <36238032.4C56F8EB@min.net>
Xah wrote:
>
> I just noted that this solution fails when the numbers are greater
> than 'long'. For example,
> my $ref = [[5000000000000000000000],[1000000000000000000000,2]];
> print Dumper(IndexSetSort2($ref,1,1,1));
> will print "$VAR1 = [['5e+21'],['1e+21',2]];"
Of course. Perl treats numbers as floating-point whenever integers
aren't capable of holding the value, e.g. when a division has a
remainder.
I really wonder whether you have indices that large.
If you call CompleteIndexSet with those numbers, you won't have
enough memory to contain the result. So get real. ;-)
--
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer
------------------------------
Date: Tue, 13 Oct 1998 16:38:28 GMT
From: Daniel Grisinger <dgris@perrin.dimensional.com>
Subject: Re: sorting hack
Message-Id: <m3iuhojufy.fsf@perrin.dimensional.com>
Jim Brewer <jimbo@soundimages.co.uk> writes:
> abigail@fnx.com (Abigail) writes:
>
> > sort {my $i = 0; {return 0 if $#{$a} < $i && $#{$b} < $i;
> > return -1 if $#{$a} < $i;
> > return +1 if $#{$b} < $i;
> > $a -> [$i] <=> $b -> [$i] or do {$i ++; redo}}} @list;
>
> How would you write it without the deprecated $#?
$# as numeric output format is deprecated. That is not what is being
used here. $#{$b} is the index of the last element of the array
referenced by $b.
dgris
--
Daniel Grisinger dgris@perrin.dimensional.com
`By about halfway through I was beginning to guess the
ending, but it still kind of surprised me.'
David Hatunen, talking about the movie Titanic
------------------------------
Date: 13 Oct 1998 17:59:05 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: sorting hack
Message-Id: <u1zoc1jqe.fsf@jimbosntserver.soundimages.co.uk>
Daniel Grisinger <dgris@perrin.dimensional.com> writes:
> $# as numeric output format is deprecated. That is not what is being
> used here. $#{$b} is the index of the last element of the array
> referenced by $b.
Thanks. I looked up $# in The Camel and only found a reference to the
deprecated special variable. I then found it referred to in chapter 2,
The Gory Details as a result of your post.
--
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.
------------------------------
Date: 13 Oct 1998 11:05:06 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: Sorting hash by value, not key
Message-Id: <x3yww64lcyl.fsf@tigre.matrox.com>
"Carrie Coy" <carriec@doc.state.vt.us> writes:
>
> I have:
>
> while ( .......) {
> $count{$street} += 1;
> }
>
> Now I want to output hash in order of street frequency. Is there a simple
> trick?
Yes and it happens to be well documented too.
check out
perldoc -f sort
Hope this helps,
--
Ala Qumsieh | No .. not Just Another
ASIC Design Engineer | Perl Hacker!!!!!
Matrox Graphics Inc. |
Montreal, Quebec | (Not yet!)
------------------------------
Date: Tue, 13 Oct 1998 12:55:03 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <362385E7.A8D4B55F@min.net>
Bart Lateur wrote:
>
> I recently found that some long time posters are more guilty of
> this kind of behaviour.
> The difference is: long time posters don't get sneared at for doing it.
Cool!
A statement which, at the instant of being uttered, changes its own
truth value from true to false!
--
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer
------------------------------
Date: Tue, 13 Oct 1998 07:58:56 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
To: "Mikkel K." <mtk@egmont-kol.dk>
Subject: Re: unidirectional pipe into interactive program (passwd)
Message-Id: <36236AB0.45D3FD22@mcmahon.qal.berkeley.edu>
[reply posted & sent via email]
I think the answer is looking like "no." Or at least not without re-writing
expect.pm, which seems sort of pointless.
There is some stuff I wrote for our samba site, which probably won't be
directly useful for your situation but might give you some ideas. Feel free
to check it out: http://demog.berkeley.edu/~aperrin/tips/mchp.html
Cheers,
Andy
Mikkel K. wrote:
> ..snip..
> But still: Can I somehow pipe to passwd and smbpasswd (stdin or tty)
> without expect.pm?
>
> Thanks, Mikkel
--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting - (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King)
http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3963
**************************************