[10356] in Perl-Users-Digest
Perl-Users Digest, Issue: 3949 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 11 22:07:18 1998
Date: Sun, 11 Oct 98 19:00:19 -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 Sun, 11 Oct 1998 Volume: 8 Number: 3949
Today's topics:
Re: .htaccess Problem (brian d foy)
A Faster Way?? <ranson@rlaj.com>
Re: Any possible way to do graphics in perl?? (brian d foy)
File Statistics <hn40@columbia.edu>
Re: File Statistics (Mark-Jason Dominus)
Re: File Statistics (brian d foy)
Re: File Statistics (Mark-Jason Dominus)
Re: Help me in getting source code of counter in perl! (brian d foy)
Re: How do I use die? (brian d foy)
Re: How do I use die? (Mark-Jason Dominus)
Re: How do I use die? (Mark-Jason Dominus)
Re: I'm looking for someone who wants to write a comple <matt@whiterabbit.co.uk>
Re: I'm looking for someone who wants to write a comple <Christian@oliveoilstudios.com>
Re: Is there any way to compile perl scripts? (brian d foy)
Re: Keeping a running list of the top n values retrieve (Sam Holden)
need help writing to a text file <mbarg@mail.usyd.edu.au>
Re: NETWORK & GRAPHIC CARD INFO (brian d foy)
Re: Newbie: using strict with filehandles (Mark-Jason Dominus)
Re: Newbie: using strict with filehandles (George Defenbaugh)
Peculiar behavior of system() <dklaus1@home.com>
Re: Peculiar behavior of system() (Mark-Jason Dominus)
Pelr book or WWW Recources (George)
Perl 5.00502 error in subroutines (O2)
Re: Problem with perlmodules (Mark-Jason Dominus)
Re: reg-exp: change < to < but keep <I> (Bart Lateur)
Re: sorting hack (Larry Rosler)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 11 Oct 1998 20:07:37 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: .htaccess Problem
Message-Id: <comdog-ya02408000R1110982007370001@news.panix.com>
Keywords: from just another new york perl hacker
In article <362123E8.1C1BF1C1@crec08.bus.utexas.edu>, Juha Vehnia <juha@crec08.bus.utexas.edu> posted:
>We are using perl to dynamically generate Apache's (user authentication)
>.passwd file when ever new users registerer to use our system. We don't
>use any file locking or anything, we just generate tmp file and then
>replace the original .passwd file with the new file. There is a problem,
>the whole .passwd file gets somehow corrupted and nobody can login.
um, file locking is good. how about solving that mis-design first?
> Any idea what's the problem, how the
>generate bullet proof file locking or is there any other way to
>authenticate users ?
various database products can bu used. see your server documentation.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: Sun, 11 Oct 1998 19:49:20 -0500
From: Raydance <ranson@rlaj.com>
Subject: A Faster Way??
Message-Id: <36215210.3801@rlaj.com>
Greetings perl gurus,
Just wondering if there is a 'faster' way for perl to do the following:
# there are 12 categories
foreach $key (sort keys %category) {
opendir (MYDIR, "$base_dir$key") || &open_error("$base_dir$key");
@allfiles = grep -T, map "$base_dir$key/$_", readdir MYDIR;
closedir MYDIR;
}
Thanks to all the Perl gurus out there that answer our questions, no
matter how simple they may seem.
Ray
------------------------------
Date: Sun, 11 Oct 1998 20:00:30 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Any possible way to do graphics in perl??
Message-Id: <comdog-ya02408000R1110982000300001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6vrcc7$9jl$5@santaclara.santafe.edu>, "Robin Bank" <rbank@csf.edu> posted:
yes.
>E-mail me your responses!
post here, read here.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: Sun, 11 Oct 1998 19:03:26 -0400
From: Himani Naresh <hn40@columbia.edu>
Subject: File Statistics
Message-Id: <Pine.GSO.3.95qL.981011190244.4302A-100000@monire.cc.columbia.edu>
Hello,
How do I get a file creation date using the stat function.
I get some crazy number. How do I covert it back to a real date?
Thanks
HN
_______________________________________________________________________
Himani Naresh
Computer Science Department
Columbia University
hn40@columbia.edu
God put me on earth to accomplish a certain number of things.
Right now I am so far behind, I will never die.
-- Calvin and Hobbes
------------------------------
Date: 11 Oct 1998 19:54:02 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: File Statistics
Message-Id: <6vrgeq$8ps$1@monet.op.net>
In article <Pine.GSO.3.95qL.981011190244.4302A-100000@monire.cc.columbia.edu>,
Himani Naresh <hn40@columbia.edu> wrote:
>How do I get a file creation date using the stat function.
>I get some crazy number. How do I covert it back to a real date?
You use the `localtime' function, or you put `use POSIX' into your
program and then use the `strftime' function.
------------------------------
Date: Sun, 11 Oct 1998 20:04:00 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: File Statistics
Message-Id: <comdog-ya02408000R1110982004000001@news.panix.com>
Keywords: from just another new york perl hacker
In article <Pine.GSO.3.95qL.981011190244.4302A-100000@monire.cc.columbia.edu>, Himani Naresh <hn40@columbia.edu> posted:
>Hello,
>How do I get a file creation date using the stat function.
you don't. perhaps you're refering to ctime, the inode change time?
>I get some crazy number. How do I covert it back to a real date?
what is the crazy number? it should be seconds since the epoch, whose
start varies from place to place. localtime() is useful in converting
it to something you are used to.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: 11 Oct 1998 20:30:25 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: File Statistics
Message-Id: <6vrij1$910$1@monet.op.net>
Keywords: Brian D. Foy
In article <comdog-ya02408000R1110982004000001@news.panix.com>,
brian d foy <comdog@computerdog.com> wrote:
>>How do I get a file creation date using the stat function.
>
>you don't. perhaps you're refering to ctime, the inode change time?
On DOS-like systems, the ctime is some sort of creation time.
------------------------------
Date: Sun, 11 Oct 1998 20:14:39 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Help me in getting source code of counter in perl!
Message-Id: <comdog-ya02408000R1110982014390001@news.panix.com>
Keywords: from just another new york perl hacker
In article <01bdf184$dfd50a60$042bb0cb@crimson>, "Mark N. Salvador" <markns@nsclub.net> posted:
>Pls. help me in finding source code of perl script counter!
>I badly need it... thanks!
% head -n 1 * | grep ^#! | grep -c perl
why are you counting perl scripts?
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: Sun, 11 Oct 1998 19:52:20 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: How do I use die?
Message-Id: <comdog-ya02408000R1110981952200001@news.panix.com>
Keywords: from just another new york perl hacker
In article <361EF9A2.F605196E@vpservices.com>, jeff@vpservices.com posted:
>brettr wrote:
>> #!/usr/bin/perl
>> chdir('/user/printer')or die;
>> [snip]
>> I get Internal Server Error.
>Mistake #3: (and this is the big one) there's no way you can find out
>what went wrong by accessing that script from your browser
are you sure there's no way? i can think of several, including
CGI::Carp::fatalsToBrowsers().
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: 11 Oct 1998 20:45:29 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: How do I use die?
Message-Id: <6vrjf9$95n$1@monet.op.net>
In article <6vpkj3$h8o$1@newsread1-mx.centuryinter.net>,
brettr <brettr@centuryinter.net> wrote:
>What versions of Perl support die()?
All of them.
------------------------------
Date: 11 Oct 1998 20:51:12 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: How do I use die?
Message-Id: <6vrjq0$97e$1@monet.op.net>
In article <1dgqp5r.18oxfglzmbvgiN@host016-210.seicom.net>,
Joergen W. Lang <jwl@_munged_worldmusic.de> wrote:
> BEGIN {
> use CGI::Carp qw(carpout);
> open(LOG, ">>/usr/local/cgi-logs/mycgi-log") or
> die("Unable to open mycgi-log: $!\n");
> carpout(LOG);
> }
I like to do it a little differently:
BEGIN {
$ERR = '/tmp/program.err'; # ***
$ERR and open (STDERR, ">> $ERR")
or die "Couldn't open error log file $ERR: $!; aborting";
# carpout goes here if you want it
}
Then later on, I can have
$ERR and print STDERR "Some diagnostic message.\n";
When the program is ready for distribution, I comment out the `***'
line, and all the diagnostic stuff diasappears from the program.
------------------------------
Date: Mon, 12 Oct 1998 02:15:04 +0100
From: Matt Pryor <matt@whiterabbit.co.uk>
Subject: Re: I'm looking for someone who wants to write a complete perl-script (for free)
Message-Id: <36215818.E462B3B3@whiterabbit.co.uk>
PsIoNnEkE wrote:
> =
> Hi !
> =
> I'm looking for one (or a few) persons who want to write a complete
> perl-script for my new web-project. The project ain't the one you know
> from everybody, no, it's very professional.
Hey, great! Sounds like a real hoot! I bet it's really professional,
too, judging by your tremendous grasp of the English language!
> What I need:
> I need 2 or 3 scripts that use the same resources. It's all for the
> same purpose: voting.
Weh-hey, this sounds like an original and exciting project for me to
spend my spare time on! (yawn..)
=
> Script 1: for the visitors.
> They can submit URL's (through the script) and vote on other URL's.
Gets better all the time...
=
> More information and more details are available at my e-mail adres
> (bdispa@bigfoot.com)... (Dutch / English)
> Do you want to help me ? Mail me ASAP. The deadline is January 1st.
I hope Mike Schutz read this request. Does this chap count as a "worthy
recipient" for your freebie programming?
(My quote: estimated 200 hours work @ =A310.00 per hour + vat =3D =A32,35=
0.00)
-- =
Matt's daily comic strip
Porridge and Fartcakes
http://www.whiterabbit.co.uk/cartoons
------------------------------
Date: Mon, 12 Oct 1998 03:32:42 +0000
From: Christian Verschaeren <Christian@oliveoilstudios.com>
Subject: Re: I'm looking for someone who wants to write a complete perl-script (for free)
Message-Id: <36217857.4C879A9@oliveoilstudios.com>
PsIoNnEkE wrote:
> Hi !
>
> I'm looking for one (or a few) persons who want to write a complete
> perl-script for my new web-project. The project ain't the one you know
> from everybody, no, it's very professional.
>
> What I need:
lemme guess, a sence of reality?
--
mailto:christian@oliveoilstudios.com
http://www.oliveoilstudios./com
------------------------------
Date: Sun, 11 Oct 1998 20:01:35 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Is there any way to compile perl scripts?
Message-Id: <comdog-ya02408000R1110982001350001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6vrcc4$9jl$3@santaclara.santafe.edu>, "Robin Bank" <rbank@csf.edu> posted:
yes. your script is compiled every time you run it (unless you're talking
about mod_perl).
>IF you have a response, please e-mail it to me.
post here, read here.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: 12 Oct 1998 01:50:45 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Keeping a running list of the top n values retrieved
Message-Id: <slrn722o3l.ail.sholden@pgrad.cs.usyd.edu.au>
On 7 Oct 1998 16:11:20 GMT, Abigail <abigail@fnx.com> wrote:
>Sam Holden (sholden@pgrad.cs.usyd.edu.au) wrote on MDCCCLXIII September
>MCMXCIII in <URL:news:slrn71lel6.mjt.sholden@pgrad.cs.usyd.edu.au>:
>++ On 6 Oct 1998 16:42:20 GMT, Abigail <abigail@fnx.com> wrote:
>++ >
>++ >If we have n values, and want to get the top m, sorting takes O (n log n).
>++
>++ And looses on space in a big way for n >> m.
>
>How's that? All methods use O (n) memory.
All the methods use O(m) memory... storing everything and sorting at the end
uses O(n).
>
>++
>++ >Using a sorted array of size m, and splice each new element in, takes O (n m).
>++
>++ Which is basically what the above does the sort is O(n log (m+1)) the
>++ assignment is O(n m) so we have O(n m) all up.
>
>You've lost me here. What do you mean?
I couldn't understand what I wrote either... anyway here is what I meant (I
really need a perl script to translate what I mean to what a type)...
The sorted array is at most m+1 in length. There are n valeus that we are
going to insert into this array.
So we have n inserts which each take O(m log m) which gives O(nm log m) - I
made a thinko in the above and thus got it _very_ wrong.
After each sort we assign the sorted array to the old array - there are m+1
elements and we do this n times so that gives O(nm).
So all up we have O(nm log m) - which is not what I said...
>
>++ >Using a heap gives a running time of O (n log m).
>++ >
>++ >If m is small compared to n, the heap clearly wins.
>++
>++ The smaller m gets the closer O(n m) gets to being as good as O(n log m)...
>++ Since a smaller m has a bigger impact on (n m) than (n log m)
>++
>++ If n is 1000000 and m is 16 then we have
>++ n*m = 16000000
>++ n*log m = 4000000
>++ So it's only 4 times slower. With m = 1024 n*m is over 100 times slower.
>
>Rubbish. You can't ignore the constant.
I mentioned this in the next line I thought...
There shouldn't be that large a constant for an array traversal followed
by a moving O(m) elements up one in the array, although I could be wrong. I can
do it with O(m) swaps, and a heap is really just O(log m) swaps so the constant
should be the same.
>
>++ Though log m is better than m especially since a heap has little overhead.
>++
>++
>++ I agree the heap is probably the best solution, though displaying the
>++ top m elements in decreasing order takes O(m) with the sorted array and
>++ O(m log m) with the heap (though once sorted it can stay sorted until the
>++ next insertion). Unless someone knows a way of getting at the elements in a h
>++ in sored order in less than O(m log m)?
>
>You can't do that. If you can, you can sort in time less than O (n log n),
>as building a heap can be done in linear time.
I knew that and yet again worded my question wrong... Getting sorted output from
a heap takes O(n log n) and thus displaying the top scores would also take that
long (whereas a sorted list would take O(n)). However, there might be some
property that the heap will have since it has been constructed in a restricted
fashion - I doubt it very much though.
>
>++ So a skip list would actually give O(n log m) insertions and O(m) displays, b
>++ would be a lot more work to implement than a heap.
>
>Since m <= n, O (m log m) = O (n log m). The insertions in the heap will
>dominate reporting the result anyway.
True, and as I said a heap takes _much_ less effort to code...
--
Sam
Even if you aren't in doubt, consider the mental welfare of the person
who has to maintain the code after you, and who will probably put parens
in the wrong place. --Larry Wall
------------------------------
Date: Mon, 12 Oct 1998 10:25:38 +1000
From: Mike Barg <mbarg@mail.usyd.edu.au>
Subject: need help writing to a text file
Message-Id: <36214C82.E44DF985@mail.usyd.edu.au>
Hi there.
I am trying to write things to a text file, and having problems doing what I
want. I understand that I can use:
print FILEHANDLE "stuff"
to print to a file. This seems to work fine if I am appending to a file or
overwriting a file.
What I want to do, however, is to read, say, the first 3 lines of a file,
replace line 3, and leave the rest of the file untouched.
I have tried doing this (with a text file that had lines numbered
1:
2:
3:
4:
5:
6:
with the following piece of code:
open (DOC, "+<write.txt") || die "opening didn't work";
do
{
chomp ($a = <DOC>);
@a = split (/:/, $a);
print "$a[0]\n";
} until ($a[0] eq "3");
print DOC "3:yet even more stuff";
What actually happens is that everything runs happily (nothing dies - as far as
I can tell the text is actually written to the file). However, when I go and
look, the file remains unchanged.
I have ASSUMED that when reading through a file, there is some sort of marker to
tell PERL where it is up to, and by reading thru until I find that place, I can
then add/delete things at this point. For some reason, this does not seem to be
working for me.
Any suggestions would be GREATLY appreciated.
I would appreciate it if you could also CC a copy of your reply to me personally
at; mbarg@mail.usyd.edu.au
Thanks in advance
Mike
------------------------------
Date: Sun, 11 Oct 1998 19:57:18 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: NETWORK & GRAPHIC CARD INFO
Message-Id: <comdog-ya02408000R1110981957180001@news.panix.com>
Keywords: from just another new york perl hacker
In article <%EaU1.13$Rd3.77339@nsw.nnrp.telstra.net>, mgjv@comdyn.com.au (Martien Verbruggen) posted:
>[Posted and Mailed]
>
>In article <19981010181928.01520.00008841@ng104.aol.com>,
> sattars@aol.com (SattarS) writes:
>> Can anyone tell me how to get Network card and Graphic Card details from Perl?
>> Thanks
>In addition to posting this message to this newsgroup, you also
>emailed it to me, and many other people that frequent this group.
i think many is understated. from my mail headers it seemed to be the
set of anyone who has ever posted to this group. some people may balk
at his stupidity and utter crassness, but i was kinda wondering how he
got all the addresses - alphabetized even. he's certainly not a pro
spammer or he would have used Bcc:.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: 11 Oct 1998 19:49:54 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Newbie: using strict with filehandles
Message-Id: <6vrg72$8p7$1@monet.op.net>
In article <3621b97c.144291072@news.net1.net>,
George Defenbaugh <george@defenbaugh.com> wrote:
>#use strict;
>my $fn;
>my $fh = "fh00";
>$fn = <STDIN>;
>open($fh, $fn) || die "Open: $!";
>while (<$fh>) {
> print "$fn:$_";
>}
Try this:
use strict;
my $fn;
local *fh = "fh00";
chomp($fn = <STDIN>);
open(fh, $fn) || die "Open: $!";
while (<fh>) {
print "$fn:$_";
}
Here's a more realistic example of how to use this:
use strict;
# Argument: An already opened filehandle
# (optional) A line label string
# Prints out all the data from that handle, with the line
# label prepended (if one was supplied) and then closes the handle
sub print_from_handle {
local *FH = shift;
my $label = shift;
$label = defined($label) ? "$label:" : '';
while (<FH>) { print $label, $_ }
close FH;
}
chomp(my $filename = <STDIN>);
open FH00, $filename or die "Couldn't open $filename; $!; aborting";
print_from_handle(*FH00, $filename);
# Or: print_from_handle('FH00', $filename);
------------------------------
Date: Mon, 12 Oct 1998 00:14:06 GMT
From: george@defenbaugh.com (George Defenbaugh)
Subject: Re: Newbie: using strict with filehandles
Message-Id: <3621496d.181145794@news.net1.net>
Worked great. Just what I needed. Thanks! Some of these concepts
aren't in the Learning... book, and even the Programming book doesn't
cover them well. I need to look at the Advanced book I guess.
If you have a recommendation for another book to augment the ORA
series, I'd appreciate the suggestion.
On Sun, 11 Oct 1998 21:02:08 GMT, "Garry T. Williams"
<garry@america.net> wrote:
>Try:
>
> use strict;
> use FileHandle;
> my $fh = new FileHandle;
> open ($fh, "x") || die "can't open x, $!";
>
>-Garry Williams
>
>George Defenbaugh wrote:
>>
>> Thank you for your help, and your comments are appreciated, but my
>> original question remains:
>>
>> ?How does one declare a file handle in advance so it passes the strict
>> test?
------------------------------
Date: Mon, 12 Oct 1998 00:01:27 GMT
From: Dwight Klaus <dklaus1@home.com>
Subject: Peculiar behavior of system()
Message-Id: <36214827.7FEE0507@home.com>
Hi,
I have been fighting with a peculiar behaviour in using system() to
invoke an executable command. Maybe you are one step ahead of me on
this one, and can offer me some advice (or simpathy, or whatever...).
When invoking:
system("<some_long_command_string>")
the results I see indicate that the command interpreter that this string
is passed to is somehow seeing newlines inserted before the entire
string is scanned. I know this because the last argument in the command
string is missing from the perspective of the program invoked, and when
this program completes, the command interpreter tries to execute the
last argument as if it were the next command. To make matters worse,
the behavior seems to be intermittant, and related to the length of the
command string being executed. I wonder if there is a buffer limit that
I am reaching in the command interpreter, and that its default action is
to truncate the command string after the last full word prior to the
buffer overflowing.???
No idea on this one - and I also question how perl chooses the command
interpreter that system() uses. Is it based on passwd file entry, or
environment variable SHELL or something else?
TIA,
Dwight Klaus
dklaus1@home.com
dklaus@microchip.com
--
------------------------------
Date: 11 Oct 1998 20:40:50 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Peculiar behavior of system()
Message-Id: <6vrj6i$938$1@monet.op.net>
In article <36214827.7FEE0507@home.com>,
Dwight Klaus <dklaus1@home.com> wrote:
>When invoking:
>
> system("<some_long_command_string>")
>
>the results I see indicate that the command interpreter that this string
>is passed to is somehow seeing newlines inserted before the entire
>string is scanned.
There are no newlines put there unless you put them there yourself.
Pepole often have this problem that they do something like this:
$filename = <STDIN>;
system("command $filename other_file");
Then they seem surprised that the command ignored `other_file'. But
`$filename' contains a newline, so that the command was actually
command the_file
other_file
That is probably what you are doing.
Rule #3 of debugging: Blame your own software before you blame
someone else's. This is called `looking for the wallet under the
lamppost'.
>I wonder if there is a buffer limit that I am reaching in the command
>interpreter, and that its default action is to truncate the command
>string after the last full word prior to the buffer overflowing.???
If so, I never heard of that. I think it is much more likely that the
command string does not contain what you think it does. Instead of
this:
system("some long string with $files and @variables interpolated");
try this:
$command = "some long string with $files and @variables interpolated";
print STDERR "The command is:\n\t$command\n";
system($command);
and see what it says.
>I also question how perl chooses the command interpreter that
>system() uses. Is it based on passwd file entry, or environment
>variable SHELL or something else?
If it uses a command interpreter, it uses /bin/sh. For commands that
don't require the shell, it just execs the command directly.
------------------------------
Date: Mon, 12 Oct 1998 01:56:05 GMT
From: george9684@my-dejanews.com (George)
Subject: Pelr book or WWW Recources
Message-Id: <3621619d.22548613@news.uniserve.com>
I have read books from our local library about perl. They are geared
for people who have experience in programming in other languages and
certain assumptions are made.
Could someone please suggest a good book that explains from the ground
up OR are there recources on the www that I could access and study?
Thank you
george9684@my-dejanews.com
------------------------------
Date: Sun, 11 Oct 1998 23:00:11 GMT
From: oxygen@nospam.dnc.net (O2)
Subject: Perl 5.00502 error in subroutines
Message-Id: <362237a6.62203943@205.139.105.25>
I grabbed perl 5.00502 today and installed in onto my linux
box(slackware 3.5). I had a script that ran fine on 5.004 but now
gives this error when I run it.
Unable to create sub named "*main::search" at ./dbopen.pl line 22.
This script will run fine on the most updated perl for windows. Line
22 is just
"&search;"
The subroutine begins on line 222.
sub search{
#stuff to happen
}
Any ideas where this error is coming from
Scott
to E-mail me remove the nospam. from my E-mail address
------------------------------
Date: 11 Oct 1998 21:10:42 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Problem with perlmodules
Message-Id: <6vrkui$99n$1@monet.op.net>
In article <361f49e8.1213652990@192.168.0.1>,
Hampus Brynolf <hampus@globetree.org> wrote:
>* When i write :
>use vfv.pm;
>is that script actually executed, and the 'open' instructions in the
>script performed?
Yes, almost as if you executed `vfv.pm' from the command line.
To avoid this, put the `open' into a subroutine. Code inside
subruotines is not executed unless you call the subroutine. Then have
the main script call the subroutine when it wants to open the file.
------------------------------
Date: Sun, 11 Oct 1998 22:01:23 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: reg-exp: change < to < but keep <I>
Message-Id: <36252982.3155221@news.ping.be>
To respond to your subject line alone: try
s/(<I>)|</$1 || '<'/ge;
The left side of the vertical bar is tested first; if it's found, the
right side is ignored. So "<I>" is left alone, while other occurences of
"<" are replaced by "<".
You'd have to extend the left side for other exception too.
p.s. This is not an intro on how to write solid code, but how you could
tackle things LIKE this using Perl. Yes, it's a plug for Perl.
Using a module, like Abigail suggested, migh be a more professionally
sound approach.
Bart.
------------------------------
Date: Sun, 11 Oct 1998 17:39:47 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sorting hack
Message-Id: <MPG.108aefb2beab68f29898af@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <6vqlr2$aga$1@nntp2.ba.best.com> on Sun, 11 Oct 1998 09:28:31
+0000, Xah <xah@best.com> says...
>
> I have an array of arrays of the form [[a1,a2,...],[b1,b2,...],...]. I want
> to sort them first by their digits starting from the left, then by their
> length. For example, here's a sorted result
> [[0], [1], [1, 0], [1, 1], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 2], [1, 2,
> 0], [1, 2, 1], [1, 2, 2], [2], [2, 0], [2, 1], [2, 1, 0], [2, 1, 1], [2, 1,
> 2], [2, 2], [2, 2, 0], [2, 2, 1], [2, 2, 2]]
>
> [1,1,2] comes before [1,2] because the second digit of first is smaller.
> [1, 2] come before [1, 2, 0] because even their index comparison is neutral,
> but the first has shorter length.
>
> How would one best implement this in Perl? I couldn't figure out a way to
> avoid a loop in the sort comparison subroutine. (I'm interested in speed
> here.) This will be a function. The argument is not known until runtime.
Look, Mom -- no loop in the sort comparison subroutine!
(This is a classical Schwartz Transform. See perlfaq4: "How do I sort
an array by (anything)?" for details. You'll be surprised at how fast it
will run.)
I replaced your outer square brackets by parentheses for simplicity of
input, but you can change them trivially. This program returns its
(already sorted) input exactly, except for newlines in the input.
#!/usr/local/bin/perl -w
use strict;
my @in =
([0], [1], [1, 0], [1, 1], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 2],
[1, 2, 0], [1, 2, 1], [1, 2, 2], [2], [2, 0], [2, 1], [2, 1, 0],
[2, 1, 1], [2, 1, 2], [2, 2], [2, 2, 0], [2, 2, 1], [2, 2, 2]);
my @out = map $_->[0] => sort { $a->[1] cmp $b->[1] }
map { [ $_, sprintf '%.9d' x @$_ => @$_ ] } @in;
print '(';
{
local ($,, $") = (', ', ', ');
print map "[@$_]" => @out;
}
print ")\n";
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
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 3949
**************************************