[13576] in Perl-Users-Digest
Perl-Users Digest, Issue: 986 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 5 01:05:36 1999
Date: Mon, 4 Oct 1999 22:05:14 -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: <939099913-v9-i986@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 4 Oct 1999 Volume: 9 Number: 986
Today's topics:
/foo/bar differs from /foo/bar? <sobotka@axess.com>
Re: A different turn ( WAS Re: Bye Tom? ) (Abigail)
Re: A different turn ( WAS Re: Bye Tom? ) (Abigail)
ActivePerl Implementation Problem (subs mysteriously re <dove@synopsys.com>
Re: installing mod_perl on Apache - What is lgdbm? <Tim.Potter@anu.edu.au>
Re: installing mod_perl on Apache - What is lgdbm? (Martien Verbruggen)
Need help with using "format" for String pejman@pejman.com
Re: Need help with using "format" for String <rick.delaney@home.com>
Newbie question: Ordering files by Modification time <Kdd7@stratos.net>
Re: Newbie question: Ordering files by Modification tim (Martien Verbruggen)
Re: Newbie question: Ordering files by Modification tim <sjs@yorku.ca>
Re: Newbie question: Ordering files by Modification tim <mj.stevenson@auckland.ac.nz>
Re: Newbie question: Ordering files by Modification tim <crdevilb@mtu.edu>
Re: Newbie question: Ordering files by Modification tim (Martien Verbruggen)
Re: Newbie question: Ordering files by Modification tim <uri@sysarch.com>
Re: Newbie question: Ordering files by Modification tim (Martien Verbruggen)
Re: pattern matching question (Larry Rosler)
Re: Perl macros for vi (Chris Fedde)
Re: Pulling positional data from a string <ultrak@my-deja.com>
Re: Pulling positional data from a string (Larry Rosler)
Re: setpwent (Abigail)
Re: setpwent (Martien Verbruggen)
Re: setpwent <uri@sysarch.com>
Re: sort routine - can it ignore numeric values? (Abigail)
Re: Test this please (Abigail)
Re: Test this please (Abigail)
Re: Using the Expect.pm module w/Perl5.00502 <wendigo@deathstar.jabberwock.org>
Re: What's the quickest way to read a file (Philip 'Yes, that's my address' Newton)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 05 Oct 1999 04:35:01 GMT
From: Henry Sobotka <sobotka@axess.com>
Subject: /foo/bar differs from /foo/bar?
Message-Id: <37F97F71.95857FD2@axess.com>
I'm trying to get the Mozilla version of LXR (mozilla/webtools/lxr)
running on an OS/2 box. An opendir(DIR, $Path->{'real'})call is failing.
Displaying the value of $Path->{'real'} shows "s:/lxr/javaprojects". If
I replace the variable with the pathstring in the opendir call, it
works; ditto if I assign it to my $testdir. Applying the eq operator to
$testdir and $Path->{'real'} produces
s:/lxr/javaprojects/ differs from s:/lxr/javaprojects/
which is what by now I expected to see, but don't understand. It doesn't
appear to be an Apache access problem, as with $testdir the directory
gets listed, and the LXR ident script works fine, i.e. I can browse
through the individual src files via the links.
Any insight into this strangeness would be much appreciated.
Henry
------------------------------
Date: 4 Oct 1999 23:12:54 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: A different turn ( WAS Re: Bye Tom? )
Message-Id: <slrn7viv60.dtc.abigail@alexandra.delanet.com>
Craig Berry (cberry@cinenet.net) wrote on MMCCXXV September MCMXCIII in
<URL:news:rvi1gbi8rad81@corp.supernews.com>:
@@
@@ The next time you get a perfumed love letter from a complete stranger in
@@ *any* medium, you call me. Love letters are exchanged between lovers.
@@ I've recieved them via both electrons and dead trees, and they've both
@@ been love letters with or without olfactory enhancement. :)
I've gotten a love letter from a complete stranger on my pager. Unsigned.
It probably wasn't directed at me, unless my (Perl) monitor program went
bonkers, it was unsigned, but it was still a love letter.
It wasn't perfumed though, so I don't have to call you.
Abigail
--
package Z;use overload'""'=>sub{$b++?Hacker:Another};
sub TIESCALAR{bless\my$y=>Z}sub FETCH{$a++?Perl:Just}
$,=$";my$x=tie+my$y=>Z;print$y,$x,$y,$x,"\n";#Abigail
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 4 Oct 1999 23:18:51 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: A different turn ( WAS Re: Bye Tom? )
Message-Id: <slrn7vivh5.dtc.abigail@alexandra.delanet.com>
Dan Sugalski (dan@tuatha.sidhe.org) wrote on MMCCXXV September MCMXCIII
in <URL:news:3G7K3.5680$S32.11576@news.rdc1.ct.home.com>:
..
.. When exactly does it *not* seem absurd? That's the bit that's got me puzzled.
Oh, the internet looks pretty ok to me if there are no packages going
over my ppp-link.
Abigail
--
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
${qq$\x5F$} = q 97265646f9 and s g..g;
qq e\x63\x68\x72\x20\x30\x78$&eggee;
{eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Mon, 04 Oct 1999 20:36:12 -0700
From: David Amann <dove@synopsys.com>
Subject: ActivePerl Implementation Problem (subs mysteriously redefined)
Message-Id: <37F9722C.76A2DD05@synopsys.com>
Hi all,
In order to demo a web based application, I've been forced to move it to
a Windows NT environment. I've installed ActivePerl and all of the
various modules, but when I try to test my script from the command line
I get a lot of the following errors:
Screen.pm: Subroutine title redefined at ../cm-lib Screen.pm line 37.
The same module on UNIX gives me no such problem. Is there something
specific to the ActivePerl implementation I should be looking for? Does
it handle namespaces differently?
I'm running under use strict on both UNIX and Windows NT.
Any assistance is appreciated.
Thanks,
-=dav
------------------------------
Date: 05 Oct 1999 13:53:38 +1000
From: Tim Potter <Tim.Potter@anu.edu.au>
To: osinglet@my-deja.com
Subject: Re: installing mod_perl on Apache - What is lgdbm?
Message-Id: <6yn1tyea4d.fsf@acronym.anu.edu.au>
osinglet@my-deja.com writes:
> I'm trying to install mod_perl and PHP3 1.30.12 on Apache 1.3.9. I'm
> getting the following output when I'm configuring it. It seems to have
> something to a missing thing called lgdbm, but I don't know what that
> is.
>
> Here is the output from the configure script:
>
> /usr/lib/perl5/5.00503/i386-linux/auto/DynaLoader/DynaLoader.a
> -L/usr/lib/perl5/5.00503/i386-linux/CORE -lperl -lnsl -lndbm -lgdbm -ldb
> -ldl -lm -lc -lposix -lcrypt
> /usr/bin/ld: cannot open -lgdbm: No such file or directory
You need to obtain and install the gdbm library (GNU dbm). Download
gdbm-1.8.0.tar.gz from your favourite GNU mirror.
Tim.
--
Tim Potter, System Admin/Programmer "Disco Stu doesn't advertise"
Advanced Computational Systems CRC, RSISE Bldg Australian National University,
Canberra 0200, AUSTRALIA Ph: +61 2 62798813 Fax: +61 2 62798602
------------------------------
Date: Tue, 05 Oct 1999 04:14:36 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: installing mod_perl on Apache - What is lgdbm?
Message-Id: <MWeK3.170$xs2.6119@nsw.nnrp.telstra.net>
On Wed, 29 Sep 1999 21:25:17 GMT,
osinglet@my-deja.com <osinglet@my-deja.com> wrote:
> Hi,
>
> I'm trying to install mod_perl and PHP3 1.30.12 on Apache 1.3.9. I'm
> getting the following output when I'm configuring it. It seems to have
> something to a missing thing called lgdbm, but I don't know what that
> is.
>
> Here is the output from the configure script:
>
> /usr/lib/perl5/5.00503/i386-linux/auto/DynaLoader/DynaLoader.a
> -L/usr/lib/perl5/5.00503/i386-linux/CORE -lperl -lnsl -lndbm -lgdbm -ldb
> -ldl -lm -lc -lposix -lcrypt
linux hmm? If this is RedHat 6.0 don't bother installing the gdbm
package that comes with the distribution. It's broken. Just get gdbm
from gnu.org, and compile and install it.
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | "Mr Kaplan. Paging Mr Kaplan..."
NSW, Australia |
------------------------------
Date: Mon, 04 Oct 1999 20:38:33 -0700
From: pejman@pejman.com
Subject: Need help with using "format" for String
Message-Id: <f3L5NwV5gIXybXbygk9vu9jneyaH@4ax.com>
Hi,
I have the following code which works perfectly fine.
Now I need to do exactly the same, but instead of writing
the result into stdout, I want to have it as a $string.
format STDOUT =
@<<<<<<< @<<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>> @>>>>>> @>>>>>>>
$form{"P"}, $form{"NAME"}, $form{"DESCR"}, $form{"PRICE"}, $form{"QUANT"}, $form{"TOTAL"}
~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$form{"DESCR"}
.
foreach ... {
write;
}
Does anybody know how to do that ?
I would appreciate any help.
please cc to my email address.
-pejman
------------------------------
Date: Tue, 05 Oct 1999 04:55:22 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Need help with using "format" for String
Message-Id: <37F984C0.8223978C@home.com>
[posted & mailed]
pejman@pejman.com wrote:
>
> I have the following code which works perfectly fine.
> Now I need to do exactly the same, but instead of writing
> the result into stdout, I want to have it as a $string.
perldoc perlfaq5
How can I write() into a string?
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Mon, 4 Oct 1999 22:25:49 -0400
From: "Kevin" <Kdd7@stratos.net>
Subject: Newbie question: Ordering files by Modification time
Message-Id: <rviodotjrad69@corp.supernews.com>
Is there any way to do this? I tried using 'sort' but had problems. Can it
be done with 'sort'? Would it be easier and more efficient to use a
'foreach' loop instead? Or am i a complete idiot and there's a little
argument that allows you to sort files read from a directory by modification
date?
------------------------------
Date: Tue, 05 Oct 1999 03:03:32 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Newbie question: Ordering files by Modification time
Message-Id: <8UdK3.134$xs2.5413@nsw.nnrp.telstra.net>
On Mon, 4 Oct 1999 22:25:49 -0400,
Kevin <Kdd7@stratos.net> wrote:
> Is there any way to do this? I tried using 'sort' but had problems. Can it
> be done with 'sort'? Would it be easier and more efficient to use a
> 'foreach' loop instead? Or am i a complete idiot and there's a little
> argument that allows you to sort files read from a directory by modification
> date?
An assumption:
- When you say 'files', you mean anything which is not a directory,
symlink, etc. (This is reflected in the grep part of the code)
Read everyhtig before the readdir from bottom to top to see what's
going on.
use strict;
my $dir = '..';
opendir(DIR, $dir) or die "Cannot opendir $dir: $!";
my @s_list =
map { $_-> [0] } # Get rid of mtime part
sort { $a->[1] <=> $b->[1] } # Sort on mtime
map { [ $_, (stat "$dir/$_")[9] ] } # Get mtime, and store in anon
# array reference.
grep { -f "$dir/$_" } # Only 'plain' files
readdir(DIR);
closedir(DIR);
And I used this to check it:
my @ls_list =
grep { -f "$dir/$_" }
map { chomp; $_ }
qx(ls -tra $dir);
Contents of these two should be, and in my case are, the same.
There may be more efficient methods, but this one limits the number of
stats per file to one by using a map, instead of doing a stat inside
the sort function, which I have seen suggested in the past :).
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: 04 Oct 1999 23:10:04 -0500
From: Steven Smolinski <sjs@yorku.ca>
Subject: Re: Newbie question: Ordering files by Modification time
Message-Id: <m34sg6fnxf.fsf@hank.yorku.ca>
"Kevin" <Kdd7@stratos.net> writes:
> Is there any way to do this? I tried using 'sort' but had problems. Can it
> be done with 'sort'? Would it be easier and more efficient to use a
> 'foreach' loop instead? Or am i a complete idiot and there's a little
> argument that allows you to sort files read from a directory by modification
> date?
If you're on linux/unix, grep through the 'ls' manpage for '-t'. It should
sort by last mod time, newest files first.
Steve
------------------------------
Date: Tue, 05 Oct 1999 16:18:02 +1300
From: Matthew Stevenson <mj.stevenson@auckland.ac.nz>
Subject: Re: Newbie question: Ordering files by Modification time
Message-Id: <37F96DEA.A6944693@auckland.ac.nz>
Kevin wrote:
>
> Is there any way to do this? I tried using 'sort' but had problems. Can it
> be done with 'sort'? Would it be easier and more efficient to use a
> 'foreach' loop instead? Or am i a complete idiot and there's a little
> argument that allows you to sort files read from a directory by modification
> date?
#!/usr/bin/perl -w
use strict;
my @files = glob("*");
my %file_modtime;
for(@files){
$file_modtime{$_} = (stat($_))[9];
}
# @files = sort { $file_modtime{$a} <=> $file_modtime{$b}} keys
%file_modtime;
@files = sort { $file_modtime{$b} <=> $file_modtime{$a}} keys
%file_modtime;
for(@files){
print "$_\t$file_modtime{$_}\n";
}
Hope this helps look at stat and sort.
perldoc -f stat
perldoc -f sort
--
Matthew Stevenson
University of Auckland
mj.stevenson@auckland.ac.nz
------------------------------
Date: 5 Oct 1999 03:49:03 GMT
From: Colin R. DeVilbiss <crdevilb@mtu.edu>
Subject: Re: Newbie question: Ordering files by Modification time
Message-Id: <7tbsff$kce$1@campus3.mtu.edu>
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
> use strict;
> my $dir = '..';
> opendir(DIR, $dir) or die "Cannot opendir $dir: $!";
> my @s_list =
> map { $_-> [0] } # Get rid of mtime part
> sort { $a->[1] <=> $b->[1] } # Sort on mtime
> map { [ $_, (stat "$dir/$_")[9] ] } # Get mtime, and store in anon
> # array reference.
> grep { -f "$dir/$_" } # Only 'plain' files
> readdir(DIR);
> closedir(DIR);
> There may be more efficient methods,
<snip>
figured I'd see if I could beat larry and uri to it. :)
#!/usr/local/bin/perl -w
use strict;
my $dir = '..';
opendir DIR, $dir or die "Can't open dir '$dir': $!";
my @list = map { unpack('x4 a*', $_) }
sort
map { pack('N', (stat "$dir/$_")[9]).$_ }
grep { -f "$dir/$_" }
readdir DIR;
closedir DIR;
print map { "$_\n" } @list;
__END__
sort of like taking a blowtorch to a candle, but figured I'd see
if I had a handle on the method. :)
tested--should return the same results as the above-quoted.
thanks to larry and uri for the cool technique--I lost the url for
the paper, though--care to post it again?
(will it be cited in 5.6's faq? that'd be cool...)
ps. the technique used above is a modified schwartzian transform
(which is what Martien used in his example), which scales even
better to large datasets.
Colin R. DeVilbiss
crdevilb@mtu.edu
------------------------------
Date: Tue, 05 Oct 1999 04:17:52 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Newbie question: Ordering files by Modification time
Message-Id: <QZeK3.172$xs2.6119@nsw.nnrp.telstra.net>
On 5 Oct 1999 03:49:03 GMT,
Colin R. DeVilbiss <crdevilb@mtu.edu> wrote:
> Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>
[snip Schwartzian transform]
> > There may be more efficient methods,
and indeed:
> figured I'd see if I could beat larry and uri to it. :)
>
> #!/usr/local/bin/perl -w
> use strict;
>
> my $dir = '..';
> opendir DIR, $dir or die "Can't open dir '$dir': $!";
> my @list = map { unpack('x4 a*', $_) }
> sort
> map { pack('N', (stat "$dir/$_")[9]).$_ }
> grep { -f "$dir/$_" }
> readdir DIR;
> closedir DIR;
I still don't like pack and unpack :) Even if they're 100 times faster!
*g*
Martien
--
Martien Verbruggen |
Interactive Media Division | In the fight between you and the world,
Commercial Dynamics Pty. Ltd. | back the world - Franz Kafka
NSW, Australia |
------------------------------
Date: 05 Oct 1999 00:39:19 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Newbie question: Ordering files by Modification time
Message-Id: <x71zbato94.fsf@home.sysarch.com>
>>>>> "CRD" == Colin R DeVilbiss <crdevilb@mtu.edu> writes:
CRD> figured I'd see if I could beat larry and uri to it. :)
CRD> my @list = map { unpack('x4 a*', $_) }
CRD> sort
CRD> map { pack('N', (stat "$dir/$_")[9]).$_ }
CRD> grep { -f "$dir/$_" }
CRD> readdir DIR;
CRD> thanks to larry and uri for the cool technique--I lost the url for
CRD> the paper, though--care to post it again?
CRD> (will it be cited in 5.6's faq? that'd be cool...)
my copy is at http://www.sysarch.com/perl/sort_paper.html.
i am gladdened to see our method infecting the perl community like a
virus. we still need a catchy name so if you like it, post or send a
suggestion.
as for martien and abigail's dislike fo pack/unpack, i don't know what
to do. they are very important parts of perl even if they expose the
dirty underside of c data.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Tue, 05 Oct 1999 05:02:27 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Newbie question: Ordering files by Modification time
Message-Id: <DDfK3.185$xs2.6477@nsw.nnrp.telstra.net>
On 05 Oct 1999 00:39:19 -0400,
Uri Guttman <uri@sysarch.com> wrote:
> as for martien and abigail's dislike fo pack/unpack, i don't know what
> to do. they are very important parts of perl even if they expose the
> dirty underside of c data.
I know. I do use pack, now and again, but I try to stay away from it.
It's just never clear to me immediately what's going on when I see a
pack string or unpack string. I don't mind being close to 'the dirty
underside of c data', not at all. I mind not being able to map pack
strings in my brain to something meaningful. Maybe all I need to do is
sit down, and write a few pack strings for some of the C structs that
I have sitting around in various files on disk. Maybe all I need is
practice.
But I still don't like them. Yet.
:)
Martien
--
Martien Verbruggen |
Interactive Media Division | You can't have everything, where would
Commercial Dynamics Pty. Ltd. | you put it?
NSW, Australia |
------------------------------
Date: Mon, 4 Oct 1999 21:44:34 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: pattern matching question
Message-Id: <MPG.1263220ae27bac5c98a034@nntp.hpl.hp.com>
In article <Pine.LNX.4.10.9910041629250.19541-100000@ns0.jimsoffice.org>
on Mon, 4 Oct 1999 16:34:37 -0700, James Nessen <nessenj@jimsoffice.org>
says...
> Got a quick and hopefully easy question for everyone. I am trying to do
> *exact* pattern matching to remove a user from a file. Well, the script
> that I wrote did that and more. I removed a user "jam" and the script
> went through and removed everyone with "jam" in front, ie "james", "jamie"
> How can I modify my script to only remove the user "jam" and nothing else?
`perldoc perlre`, and pay special attention to '\b'.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 05 Oct 1999 04:27:35 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Perl macros for vi
Message-Id: <X6fK3.559$ffd.188920320@news.frii.net>
In article <7tb2g0$qp4$1@news.tdh.state.tx.us>,
Ken Chesak <ken.chesak@dhs.state.tx.us> wrote:
>Where can I get Perl macros for vi?
>
> I tried the following link in Perl FAQ and it is not valid.
>http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/toms.exrc,
>
>Thanks
>
>
http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/toms.exrc.gz
------------------------------
Date: Tue, 05 Oct 1999 03:47:24 GMT
From: Kermit Lowry, III <ultrak@my-deja.com>
Subject: Re: Pulling positional data from a string
Message-Id: <7tbsc9$5rl$1@nnrp1.deja.com>
In article <7tb8q5$nvc$1@nnrp1.deja.com>,
Kermit Lowry, III <ultrak@my-deja.com> wrote:
>
> My first question is how to cut the positional data from the string?
> And second is how do accomplish the sort?
>
> **************************************
> while read iline
> do
> datalen=`echo "$iline" | cut -c21-24 | tr -d ' '`
> (( totreclen = datalen + 24 ))
> echo "$iline" | eval cut -c1-${totreclen} | sed "s/^/$x /g" >>
> ${cashfile}f
> (( x = x + 1 ))
> done
After doing some research I got the while loop to this:
while (<IN>) {
$datalen=substr ( $_,20,4);
$totreclen=$datalen+24;
print OUT "$x ".substr($_,0,${totreclen})."\n"; # $_ has no \n from IN
$x += 1;
}
>
> # sort by inode (ascii) then sequence (numeric)
>
> sort -T /tmp -k2.1,2.9 -k1,1n ${cashfile}f | sed 's/^[0-9]* //' >
> ${cashfile}.yy
> y
>
here is had to include the sort in tic marks.
`sort -k2.1,2.9 -k1,1n /dbbkup/cashmgmtpl > /dbbkup/cashmgmt.zz`
then I :
open (IN2, "/dbbkup/cashmgmt.zz");
open (OUT2, "> /dbbkup/cashmgmt.zzz");
while (<IN2>) {
s/\d //;
print OUT2 $_;
}
I just want to know if there is another way to sort?
Processing time on a 5000 line file (from ksh to perl) went from 7 mins
to less than a minute.
> TIA,
> -- Kermit Lowry, III
> ----------------
> "Only you can prevent forest fires!" -Smoky
> klowry@DELETEfhlbatl.com
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
--
----------------
"Only you can prevent forest fires!" -Smoky
klowry@DELETEfhlbatl.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 4 Oct 1999 21:33:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Pulling positional data from a string
Message-Id: <MPG.12631f833f065c898a033@nntp.hpl.hp.com>
In article <7tb8q5$nvc$1@nnrp1.deja.com> on Mon, 04 Oct 1999 22:13:36
GMT, Kermit Lowry, III <ultrak@my-deja.com> <Kermit Lowry, III
<ultrak@my-deja.com>> says...
...
> My first question is how to cut the positional data from the string?
perldoc -f substr
> And second is how do accomplish the sort?
perldoc -f sort
perlfaq4: "How do I sort an array by (anything)?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 4 Oct 1999 23:05:54 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: setpwent
Message-Id: <slrn7viuoq.dtc.abigail@alexandra.delanet.com>
Martien Verbruggen (mgjv@comdyn.com.au) wrote on MMCCXXVI September
MCMXCIII in <URL:news:becK3.96$xs2.4015@nsw.nnrp.telstra.net>:
@@ On 1 Oct 1999 04:18:05 -0500,
@@ Abigail <abigail@delanet.com> wrote:
@@ > Martien Verbruggen (mgjv@comdyn.com.au) wrote on MMCCXXII September
@@ > MCMXCIII in <URL:news:vQVI3.130$Fy1.5807@nsw.nnrp.telstra.net>:
@@ > ||
@@ > || Setting fields in passwd strings is a very system and configuration
@@ > || dependent thing (yp, NIS, shadow), and therefore hard to express in a
@@ > || general API. AFAIK you will need to use OS specific tools.
@@ >
@@ >
@@ > vi seems to be on any platform with a /etc/passwd file.
@@
@@ But /etc/passwd is not always where you want to change these things
@@ (see references to NIS).
rsh to the box which is the NIS master. ;-)
Abigail
--
split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 05 Oct 1999 04:10:06 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: setpwent
Message-Id: <ySeK3.169$xs2.6119@nsw.nnrp.telstra.net>
On 4 Oct 1999 23:05:54 -0500,
Abigail <abigail@delanet.com> wrote:
> Martien Verbruggen (mgjv@comdyn.com.au) wrote on MMCCXXVI September
> MCMXCIII in <URL:news:becK3.96$xs2.4015@nsw.nnrp.telstra.net>:
> @@ But /etc/passwd is not always where you want to change these things
> @@ (see references to NIS).
>
>
> rsh to the box which is the NIS master. ;-)
Hmmm..
how does vi behave from within Net::Telnet? Maybe sed or ed would be
better. I believe we're getting somewhere now.
Martien
--
Martien Verbruggen |
Interactive Media Division | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd. | cynical. It's perfectly easy to be
NSW, Australia | cynical.
------------------------------
Date: 05 Oct 1999 00:23:16 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: setpwent
Message-Id: <x74sg6tozv.fsf@home.sysarch.com>
>>>>> "MV" == Martien Verbruggen <mgjv@comdyn.com.au> writes:
MV> On 4 Oct 1999 23:05:54 -0500,
MV> Abigail <abigail@delanet.com> wrote:
>> Martien Verbruggen (mgjv@comdyn.com.au) wrote on MMCCXXVI September
>> MCMXCIII in <URL:news:becK3.96$xs2.4015@nsw.nnrp.telstra.net>:
>> @@ But /etc/passwd is not always where you want to change these things
>> @@ (see references to NIS).
>>
>>
>> rsh to the box which is the NIS master. ;-)
MV> Hmmm..
MV> how does vi behave from within Net::Telnet? Maybe sed or ed would be
MV> better. I believe we're getting somewhere now.
depending on which passwd file you are editing, vipw may be a good
choice. it does a lock on /etc/passwd (separate lock file i believe)
which is obeyed by all programs which mung passwd. it defaults to
calling vi but it will use EDITOR or VISUAL env values if set. i once
did a new user shell script with that and setting EDITOR to ed. this
could be done with perl very easily. a good question is how to make a
single perl program run vipw and still get control of /etc/passwd. maybe
the EDITOR value is a program which just sleeps and the main code edits
passwd and then kills/signals the dummy. or you can just use two
programs, one to manage and the other to edit.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 4 Oct 1999 23:42:08 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: sort routine - can it ignore numeric values?
Message-Id: <slrn7vj0so.dtc.abigail@alexandra.delanet.com>
mikej (mikej@1185design.com) wrote on MMCCXXV September MCMXCIII in
<URL:news:37F8FD6A.707A872A@1185design.com>:
&& Hello,
Bing!
&& I have a list of names and corresponding ID numbers in an array that
&& goes something like this:
&&
&& 0 Rossi, Valentino
&& 1 Abe, Norick
&& 2 Okada, Tadayuki
&& ..................on and on until..............
&& 5089 Roberts, Kenny
&&
&& My dilemma is that I want to sort this list alphabetically by the last
&& names while ignoring any and all the numbers in front. Putting the
&& numbers in back of the name is unfortunately not an option. Is this
&& possible using the sort routine and if so can someone give me an
&& example?
@sorted = map { $_ -> [0]}
sort { $a -> [1] cmp $b -> [1]}
map {[$_ => /\s+([^,]+)/]}
@unsorted;
Or even:
@sorted = do {my (%hash, $h);
map {@{$hash {$_}}}
sort
map {push @{$hash {do {/\s+([^,]+)/; $h = $1}}} => $_;
@{$hash {$h}} == 1 ? $h : ()}
@unsorted
};
Abigail
--
perl -wlne '}{print$.' file # Count the number of lines.
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 4 Oct 1999 23:07:21 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Test this please
Message-Id: <slrn7viuri.dtc.abigail@alexandra.delanet.com>
Danny Verkade (webmaster@mybegin.com) wrote on MMCCXXV September MCMXCIII
in <URL:news:37F915A1.31335ACB@mybegin.com>:
<> Abigail wrote:
<> > Danny Verkade (webmaster@mybegin.com) wrote on MMCCXXV September MCMXCIII
<> > in <URL:news:37F8FDFC.71FEBE1E@mybegin.com>:
<> > $$
<> > $$ I've created a CGI/Perl program and hope that you can test it. The
<> > $$ program will retrieve the latest headlines and displays them in my own
<> > $$ format. Can you please tell me what you think about it?? Is anything
<> > $$ wrong with it, do you see mistakes?
<> >
<> > I think it's perfect. Nice and quiet.
<>
<> Great, any reccomentations.?
Yes. Two.
- Don't change it. It doesn't do anything and I like it that way.
- Don't quote signatures.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 4 Oct 1999 23:09:01 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Test this please
Message-Id: <slrn7viuun.dtc.abigail@alexandra.delanet.com>
Clinton Pierce (cpierce1@ford.com) wrote on MMCCXXV September MCMXCIII in
<URL:news:37fbfe28.194836950@news.ford.com>:
##
## }> look newbie
## newbie is wearing a stupid grin and a nametag which
## reads "webmaster", written in crayon, on a napkin,
## and pinned upside down to his
## "I'm with Stupid" t-shirt.
##
## }> club newbie with cluestick
## newbie dies a horrible death, with multiple contusions,
## lacerations, and broken bones. Whimpering pitifully,
## his last words are "So, did you see mistakes?"
Clinton, you're just way to funny.
Abigail
--
Are you married?
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 5 Oct 1999 00:54:29 -0400
From: Mark Rogaski <wendigo@deathstar.jabberwock.org>
Subject: Re: Using the Expect.pm module w/Perl5.00502
Message-Id: <37f98485@news.eclipse.net>
In comp.lang.perl.modules Mark Jarvis <mark_jarvis@net.com> wrote:
: I know how to "expect" something from an object and
: look for a pattern, both in Tcl and Perl. But how do I
: implement Tcl's "send" function in Perl? Is that one of those
: fancy bidirectional pipe things? If so, why am I bothering
: with Expect?
my $foo = Expect->spawn($command, @parameters);
print $foo "blah\r";
My advice is to study the examples that Austin includes in the distribution,
you will save yourself a lot of hassle (especially if you try to use
expect_before and expect_after ... they are *not* analogs of the expect
functions).
Mark
--
Mark Rogaski | "I want to see movies of my dreams."
wendigo@pobox.com | -- Built To Spill, "Car"
http://www.pobox.com/~wendigo | "Computers save time like kudzu
__END__ | prevents soil erosion." - Al Castanoli
------------------------------
Date: Tue, 05 Oct 1999 04:49:30 GMT
From: nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton)
Subject: Re: What's the quickest way to read a file
Message-Id: <37f97fc7.519876210@news.nikoma.de>
On Tue, 05 Oct 1999 00:00:01 +0200, Frank de Bot <debot@xs4all.nl>
wrote:
>What is the quickest way to read a file of about 2800 Kb?
This is just totally out there, but ISTR that using mmap() is faster
than opening and reading a file the "traditional" way. Though as I
understand it, this would entail using C or similar, rather than Perl.
With Perl, my bets would be on local $/; followed by one <> if you
want it all at once; then you don't have to scan for $/ or split lines
into array elements etc. (Question: Would pre-extending the scalar
which receives the file's contents to the required length, e.g. using
stat() to determine it and saying $contents = ' ' x $length, be any
faster than just assigning $contents = <> without initialisation?)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.net>
------------------------------
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 986
*************************************