[18904] in Perl-Users-Digest
Perl-Users Digest, Issue: 1072 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 6 09:05:32 2001
Date: Wed, 6 Jun 2001 06:05:11 -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: <991832711-v10-i1072@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 6 Jun 2001 Volume: 10 Number: 1072
Today's topics:
Re: 2 questions about flock <m.grimshaw@salford.ac.uk>
Re: 2 questions about flock (Anno Siegel)
Re: 2 questions about flock (Garry Williams)
Re: 2 questions about flock <m.grimshaw@salford.ac.uk>
Re: Connection Pooling... <N.Hirani@hgmp.mrc.ac.uk>
Re: Decimal to Hex <sb@engelschall.com>
Decoding file mode (expressionlibre)
Re: Easier access to system call output - maybe output <EUSWMCL@am1.ericsson.se>
Re: format/write with alternate linefeeds ? <webmaster@webdragon.unmunge.net>
Re: format/write with alternate linefeeds ? (Eric Bohlman)
Re: getpwnam - Unimplemeted Function <abe@ztreet.demon.nl>
Re: help with hashes <bart.lateur@skynet.be>
Re: How to sort by number first then sort by english na <comdog@panix.com>
Re: irc (Anno Siegel)
mod_perl and clashing module names <kennep@stud.ntnu.no>
Re: parsing perl again <bart.lateur@skynet.be>
Re: perl2exe question (Helgi Briem)
question : OO accessing main::a from main::b::c ?? (Robin Breman)
Re: seek backwards, huge file <pef@trasra.noXX>
Very unexpected behavior W2K/Win98SE <lmoran@wtsg.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 06 Jun 2001 11:10:47 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Re: 2 questions about flock
Message-Id: <3B1E01A7.63D1EB2B@salford.ac.uk>
Anno Siegel wrote:
<snip>
>
> That loop does nothing for you because lock() itself waits until
> the lock becomes available. So it will hang on the lock() once
> until the other process exits. Then it will execute "last" and
> never look at the loop again. Only when you use the LOCK_NB
> flag will an attempt to get an unavailable lock return an error.
>
> You really ought to read some of the documentation about flock.
> Note that most of the details aren't in the perldoc page about
> flock, but in the corresponding system man pages.
>
> Anno
I wouldn't dream of entering the lion's den that is comp.lang.perl.misc
without reading the appropriate documentation. However, the reading
doesn't necessarily mean that I understand it which is why I then post
here. With the information you've provided making the documentation
clearer I'm getting a better understanding but I still have problems.
My understanding:
1/ You cannot have more than one simultaneous LOCK_EX on a filehandle
or mix simultaneous LOCK_SH and LOCK_EX on a filehandle but *can* have
multiple simultaneous LOCK_SH.
2/ The first 2 rules above do not mean that you cannot *attempt* them.
If a LOCK_EX or LOCK_SH already exists on a filehandle, another attempt
to LOCK_EX/LOCK_SH it will simply wait at the flock() call until the
previous lock is released at which point the second lock will be
applied.
3/ A successful lock operation returns 0.
If the above is correct, then why does the following still not work as I
think it should:
#!/usr/local/bin/perl -w
# This script simply simulates another user accessing $lock in write
mode
# It waits c. 20 seconds locking the file and then exits releasing the
lock.
use Fcntl qw(LOCK_EX);
$lock = 'db/lock';
$old = time;
open(LOCK, ">$lock") || die "$!\n\n";
flock(LOCK, LOCK_EX);
$new = time;
while(($new - $old) < 20)
{
$new = time;
}
close LOCK;
exit;
Here's the relevant portion of my CGI script where $lock is the same
file as above:
# lock the lock file
open(LOCK, ">$lock");
if(flock(LOCK, LOCK_EX) == 0)
{
print "able to lock file.<P>";
}
print "continuing....<P>";
My logic is that the flock() in the CGI script will wait until the first
script exits and only then will apply its lock.
However, regardless of whether the locking script is running or not,
when I run the CGI script I get:
able to lock file.
continuing....
printed to the web browser.
(Curiously, in the locking script, if I have the same test on flock() as
in the CGI script:
if(flock(LOCK, LOCK_EX) == 0)
{
print "able to lock file.\n\n";
}
or test for -1 (failure), I get nothing printed out so perhaps the
problem is here and the inital lock is not actually being applied.)
------------------------------
Date: 6 Jun 2001 12:21:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: 2 questions about flock
Message-Id: <9fl78j$dib$1@mamenchi.zrz.TU-Berlin.DE>
According to Mark Grimshaw <m.grimshaw@salford.ac.uk>:
[about flock]
> My understanding:
> 1/ You cannot have more than one simultaneous LOCK_EX on a filehandle
> or mix simultaneous LOCK_SH and LOCK_EX on a filehandle but *can* have
> multiple simultaneous LOCK_SH.
Right.
> 2/ The first 2 rules above do not mean that you cannot *attempt* them.
> If a LOCK_EX or LOCK_SH already exists on a filehandle, another attempt
> to LOCK_EX/LOCK_SH it will simply wait at the flock() call until the
> previous lock is released at which point the second lock will be
> applied.
Right again.
> 3/ A successful lock operation returns 0.
A successful flock(2) (the system call) returns 0 on success. Perl
inverts the logic and returns a true value on success and a false
on error.
This convention is true for most or all system- and library calls
that Perl supports: The original returns an error number, or 0
if there is no error. Perl returns a false value if there is an
error (and puts the error message in $!), or returns true for success.
> If the above is correct, then why does the following still not work as I
> think it should:
[code snipped]
Invert the success/failure logic.
Anno
------------------------------
Date: Wed, 06 Jun 2001 12:38:30 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: 2 questions about flock
Message-Id: <slrn9hs926.3vi.garry@zfw.zvolve.net>
On Wed, 06 Jun 2001 11:10:47 +0100, Mark Grimshaw
<m.grimshaw@salford.ac.uk> wrote:
> I wouldn't dream of entering the lion's den that is comp.lang.perl.misc
> without reading the appropriate documentation. However, the reading
> doesn't necessarily mean that I understand it which is why I then post
> here. With the information you've provided making the documentation
> clearer I'm getting a better understanding but I still have problems.
>
> My understanding:
> 1/ You cannot have more than one simultaneous LOCK_EX on a filehandle
> or mix simultaneous LOCK_SH and LOCK_EX on a filehandle but *can* have
> multiple simultaneous LOCK_SH.
> 2/ The first 2 rules above do not mean that you cannot *attempt* them.
> If a LOCK_EX or LOCK_SH already exists on a filehandle, another attempt
> to LOCK_EX/LOCK_SH it will simply wait at the flock() call until the
> previous lock is released at which point the second lock will be
> applied.
> 3/ A successful lock operation returns 0.
Nope. Read the Perl flock() manual page again. The first sentence
says otherwise.
> If the above is correct, then why does the following still not work as I
> think it should:
--
Garry Williams
------------------------------
Date: Wed, 06 Jun 2001 13:56:51 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Re: 2 questions about flock
Message-Id: <3B1E2893.84ADB60A@salford.ac.uk>
Anno Siegel wrote:
<snip>
> > 3/ A successful lock operation returns 0.
>
> A successful flock(2) (the system call) returns 0 on success. Perl
> inverts the logic and returns a true value on success and a false
> on error.
>
> This convention is true for most or all system- and library calls
> that Perl supports: The original returns an error number, or 0
> if there is no error. Perl returns a false value if there is an
> error (and puts the error message in $!), or returns true for success.
>
> Anno
Oh OK will try this later. I got my 3/ understanding from man flock:
RETURN VALUE
Zero is returned if the operation was successful; on an error a -1
is
returned and an error code is left in the global location errno.
------------------------------
Date: Wed, 06 Jun 2001 11:55:03 +0100
From: Naran Hirani <N.Hirani@hgmp.mrc.ac.uk>
To: gnari <gnarinn@hotmail.com>
Subject: Re: Connection Pooling...
Message-Id: <3B1E0C07.78C551D1@hgmp.mrc.ac.uk>
Hi,
I haven't done any timings on how long the connection actually takes.
I don't seriously expect to achieve any significant improvement in this respect
but I just thought it might be a good little exercise for me, from which to learn
some
more perl. Having got some input from others in this NG it seems this may not
be as trivial as I first thought, and so I probably won't have time to take it on
seriously.
Although, I am very interested in trying this out in case it becomes useful in
some
other circumstances in the future.
Thanks for your reply,
Naran.
gnari wrote:
> In article <3B1DE24B.D08E9915@hgmp.mrc.ac.uk>,
> Naran Hirani <N.Hirani@hgmp.mrc.ac.uk> wrote:
> >
> >The problem briefly is as follows: we have numerous perl scripts written by
> >various people which basically connect to our in-house database make some
> >simple
> >query and then disconnect. Some of these scripts are used frequently during
> >the day,
> >other's once or twice a week, etc. I have optimized this database now quite
> >considerably
> >so that even tho' we use this silly inefficient model for querying it, the
> >response times are
> >fairly acceptable, i.e. < 3-5(s) in most cases.
> >
> >However, clearly a better approach is to have a pool of connections sitting
> >there ready
> >to be dished out as and when requested by a trusted user/host/IP
> >address/script?
> >
>
> >So my plan was to write a connection pool server and have these scripts
> >request a connection
> >from this server rather than go directly to the database to see if I can
> >speed up response time
> >any further.
>
> have you tried to test how long the actual connect takes? I cannot believe
> that it is significant if the total query takes 3 to 5 seconds.
>
> gnari
------------------------------
Date: Wed, 6 Jun 2001 13:46:46 +0200
From: Steffen Beyer <sb@engelschall.com>
Subject: Re: Decimal to Hex
Message-Id: <675lf9.qra.ln@imperia.net>
Winston Kotzan <winz@prodigy.net> wrote:
> I'm writing a CGI program for the registration of shareware. The trouble
> I'm having is converting a long decimal number to a hexadecimal number. I
> tried something similar to this:
>
> $CodeStr = 25194917170125117;
> $RegCode = sprintf("%X", $CodeStr);
>
> However, the result of printing RegCode yielded FFFFFFFF. What did I do
> wrong, and is there an alternative to the sprintf() command?
>
> Assistance is very much appreciated.
#!perl
use Bit::Vector;
$CodeStr = '25194917170125117'; # note the quotes which are vital here!
$VecSize = int( 1 + length($CodeStr) * 3.3 / 4 ) * 4; # 3.3 = log(10)/log(2)
$CodeVec = Bit::Vector->new_Dec($VecSize, $CodeStr);
$RegCode = $CodeVec->to_Hex();
$CheckIt = $CodeVec->to_Dec();
print "\$VecSize = '$VecSize'\n";
print "\$CodeStr = '$CodeStr'\n";
print "\$CheckIt = '$CheckIt'\n";
print "\$RegCode = '$RegCode'\n";
This prints:
$VecSize = '60'
$CodeStr = '25194917170125117'
$CheckIt = '25194917170125117'
$RegCode = '05982A4C812193D'
Bit::Vector is available from CPAN or from
http://www.engelschall.com/u/sb/download/
Hope this helps!
--
Steffen Beyer <sb@engelschall.com>
(This message may not be replyable. Use address on line above instead!)
http://www.engelschall.com/u/sb/whoami/ (Who am I)
http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)
------------------------------
Date: 6 Jun 2001 05:07:31 -0700
From: expression_libre@yahoo.com (expressionlibre)
Subject: Decoding file mode
Message-Id: <83c74064.0106060407.6fb1ac2e@posting.google.com>
Hi,
I'm trying to write a function to decode numeric file mode
as returned by Perl "stat" function under Unix.
Ex: 33204 should give -rw-rw-r-- (normal file)
41471 lrwxrwxrwx (symbolic link)
16868 drwxr--r-- (directory)
Can anybody give me some advices ?
Thanks ;o)
------------------------------
Date: Wed, 06 Jun 2001 08:52:16 -0400
From: William Cardwell <EUSWMCL@am1.ericsson.se>
Subject: Re: Easier access to system call output - maybe output to a scaler?
Message-Id: <3B1E2780.A95C9E5D@am1.ericsson.se>
I wrote:
>
> In VMS (sorry), I would like to do system commands and operate on the output
> from the call in the simplest way, say output to a scaler instead of a file.
This works great in VMS:
$x=`DIR *.txt`;
print $x;
... so does this:
open PROG, 'dir *.txt|' or "die can't open program: $!";
while (<PROG>) {
print "$. $_"; # Prove it works
}
Thanks so much for your help, Tad and Damian.
Regards,
Will
------------------------------
Date: 6 Jun 2001 10:37:57 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: format/write with alternate linefeeds ?
Message-Id: <9fl165$lfh$0@216.155.32.224>
In article <9fki1q$ngv$07$1@news.t-online.com>,
buggs <buggs-clpm@splashground.de> wrote:
| Scott R. Godin wrote:
|
| > news://rec.games.roguelike.angband
|
| Actually I think news URLs don't have a '//'.
| So it would be:
| news:rec.games.roguelike.angband
|
| Please correct me if I'm worng :)
|
| Buggs
nope, you're 'rihgt', my bad. :)
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: 6 Jun 2001 10:53:58 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: format/write with alternate linefeeds ?
Message-Id: <9fl246$g2d$1@bob.news.rcn.net>
Scott R. Godin <webmaster@webdragon.unmunge.net> wrote:
> In article <9fki1q$ngv$07$1@news.t-online.com>,
> buggs <buggs-clpm@splashground.de> wrote:
> | Scott R. Godin wrote:
> |
> | > news://rec.games.roguelike.angband
> |
> | Actually I think news URLs don't have a '//'.
> | So it would be:
> | news:rec.games.roguelike.angband
> |
> | Please correct me if I'm worng :)
> |
> | Buggs
> nope, you're 'rihgt', my bad. :)
The general rule in URLs is that "//" introduces the name of a server.
Since the news: protocol doesn't specify a server, there's no "//".
------------------------------
Date: Wed, 06 Jun 2001 13:51:18 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: getpwnam - Unimplemeted Function
Message-Id: <a26sht4m6t4lgltp9pg2fis6s1qt4me8jq@4ax.com>
On Sat, 2 Jun 2001 11:06:12 -0400, "KeysDigital"
<shmink@keysdigital.com> wrote:
> Hello Group:
>
> I'm trying to get a script running on an NT maching running IIS and Perl
> 5.6. The code I'm having a problem with is as follows:
>
> sub CheckLogin {
> if (kDebugLevel >= kShowSubroutines) { print STDERR "CheckLogin - \n"; }
> (my $name, my $passwd) = getpwnam($userlogin);
> if ($passwd ne "") {
> if (crypt(&Obscure($userpassword), kEncryptedPassword) eq
> kEncryptedPassword) {
> $cgi->delete("userlogin");
> $cgi->delete("userpassword");
> return 1;
> }
> }
> $cgi->delete_all();
> return 0;
> }
>
> When I call the program, I get an error message saying that "The getpwanm
> function is unimplemented at XXXXXXX line 382".
perldoc perlport
You can try:
Win32::AuthenticateUser
--
Good luck, Abe
Amsterdam Perl Mongers http://amsterdam.pm.org
perl -e '$_=sub{split//,pop;print pop while@_};&$_("rekcah lreP rehtona tsuJ")'
------------------------------
Date: Wed, 06 Jun 2001 11:39:15 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: help with hashes
Message-Id: <n85sht4aemu0i99jb0hidcd6ap4jua229s@4ax.com>
Steve Marshall wrote:
>Essentially I have a text file that contains a series of records. Should I
>split the records using > ? Now what I want to include is the Query and
>Sbjct lines as well.
>>gi
>junk
>Query
>Sbjct
>>gi
>junk
>Query
>Sbjct
>>gi
>junk
>Query
>Sbjct
It's still not clear to me what exactly you want to count.
Anyway, Id' look through this data, and start a new record every time
you see a ">gi". A bit like:
my @records;
my $current;
while(<>) {
if(/^>gi/) {
push @records, $current = { };
# new record on the stack
# $current points to it
} elsif(/^(Query|Sbjct)/ && $current) {
chomp;
$current->{$1} = $_;
}
}
# see what we've got:
use Data::Dumper;
print Dumper \@records;
--
Bart.
------------------------------
Date: Wed, 06 Jun 2001 07:58:57 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: How to sort by number first then sort by english name?
Message-Id: <comdog-3EACFF.07585706062001@news.panix.com>
In article <OUmT6.61416$ko.984916@news1.frmt1.sfba.home.com>, "jack"
<cad@uk2.net> wrote:
> I have a data after perl handle already save to $out
> I need to sort 2 times to change the print out order
> first sort by number(right side) , and after that,,
> sort by english name(left name)
> then print the $out,
[snip sample data]
what's the output that you want based on the data that
you showed?
--
brian d foy <comdog@panix.com>
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: 6 Jun 2001 12:50:50 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: irc
Message-Id: <9fl8va$dib$2@mamenchi.zrz.TU-Berlin.DE>
According to Todd Smith <todd@designsouth.net>:
> Which IRC server and room is the most packed with perl people all day?
There are #perl channels on efnet, dalnet and undernet and probably
more. Which one is "most packed" with what you consider "perl people"
is up to you to find out.
Anno
------------------------------
Date: Wed, 6 Jun 2001 14:48:56 +0200
From: Kenneth Pedersen <kennep@stud.ntnu.no>
Subject: mod_perl and clashing module names
Message-Id: <Pine.GSO.4.33.0106061434520.23070-100000@jeeves.stud.ntnu.no>
Hi,
I am planning to port an application to mod_perl using Apache::Registry.
However, my problem is that some of the modules in my application uses the
same module names in different directories.
As an example, if I have the following setup:
1/
TestMod.pm
Test.pl
2/
TestMod.pm
Test.pl
The TestMod.pm module in directory 1 contains a subroutine, named
identify, that prints the number 1. The TestMod.pm module in directory 2
contains a subroutine also named identify, that prints out the number 2.
The Test.pl scripts loads TestMod.pm via use TestMod; and calls
TestMod::identify.
Now, when using mod_perl and loading the scripts, they work correctly the
first time. But on subsequent reloads the wrong identify subroutine is
often called (e.g. identify from 1/TestMod.pm is called from 2/Test.pl and
vice versa).
I think this is because mod_perl only loads the modules the first time the
scripts are run, and perl thinks that the modules are the same because
they have the same names. What identify subroutine gets called is
dependent on which httpd server process serves the request.
I have tried modifying @INC, %INC, and using require/import instead of
use, to no avail.
Does anyone have a suggestion on how to make my scripts behave correctly?
Renaming / moving the scripts is not an option.
Thanks in advance,
Kenneth.
------------------------------
Date: Wed, 06 Jun 2001 11:29:02 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: parsing perl again
Message-Id: <gu4shtsbfqpk6a7l8uocnlf8jg01rnvedv@4ax.com>
Damian Conway wrote:
>Actually, Perl *is* like C in that regard except the other way around:
>it needs a recursive descent parser because LALR just doesn't hack it. ;-)
I thought I had read in the dragon book, that LALR is more powerful than
recursive descent? But, it's been a while. I forgot most of the details.
Also note that I do think that *humans* use a recursive descent approach
to comprehend, let alone write, programming code.
--
Bart.
------------------------------
Date: Wed, 06 Jun 2001 12:52:32 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: perl2exe question
Message-Id: <3b1e2727.619798112@news.isholf.is>
On Tue, 5 Jun 2001 20:14:24 +0200, "Miriam Smit"
<miriam@allfineantz.nl> wrote:
>Anyone have experience with the perl2exe, as offered by indigostar????
Yep, some. Good results as advertised.
>I was wondering how QUERY_STRING and STDIN got handeled if converting a
>regular web-"application"
No difference.
>Does the .EXE improve executionspeed?
No. It's not supposed to.
Regards,
Helgi Briem
------------------------------
Date: 6 Jun 2001 04:47:27 -0700
From: rbreman@avensus.nl (Robin Breman)
Subject: question : OO accessing main::a from main::b::c ??
Message-Id: <cc1fb562.0106060347.483f2f22@posting.google.com>
Hi,
I'am writing my first big perl OO program, i did some small ones wich
kept to only 1 package from main.
now i can't get past my next problem :
I've got two pacakges A and B, but package B uses package C,
and package C needs to do something with a function defined in A.
main - a
+- b +- c
+- d
+ ....
in this example i try to access a string from main::a in main::b::c
package main;
use A
use B
$a = new A;
$a->set('varfroma',"here we are");
$b = new B;
print $b->print;
.
.
package A;
sub new {
...
}
sub set {
($self,$var,$key) = @_;
$self->{$var} = $key;
}
sub get {
($self,$key) = @_;
return $self->{$key};
}
.
.
package B;
use C;
sub new {
.... # the bless stuff
}
sub print {
($self) = @_;
my $c = new C;
return $c->var_from_a;
}
.
.
package C;
sub new {
.... # the bless stuff..
}
sub var_from_a {
($self) = @_;
return $main::a->get('varfroma');
# here's my problem get the error
# cannot call method "get" without packet or object reference
}
How can i access (reference to) a->get from package C ???
Robin, thought to be mastering perl OO .... :(
------------------------------
Date: Wed, 06 Jun 2001 12:58:30 +0200
From: "P.Eftevik" <pef@trasra.noXX>
Subject: Re: seek backwards, huge file
Message-Id: <3B1E0CD6.E71B6831@trasra.noXX>
Thanx, I consider 'seek' ruled out as the cause of my problem.
I just scan files for certain patterns. If the files are large,
the script fails to detect certain patterns.
I.e. if I delete the first 100.000 lines, and the last 100.100 lines of
the file,
I may scan what's left, and suddenly detect patterns that weren't there
in the
first place.
Quite tedious to debug this thing.
PEfte
Anno Siegel wrote:
> According to P.Eftevik <pef@trasra.noXX>:
> >
> > Scanning through a file with a while (< >). Occasionally I also
> > do a backward seek. Work well for moderate files.
> > Not work for big ( say 6 MB ) files.
>
> In which way does it not work? Does the seek operation fail? With
> what error message? If it doesn't fail, what do you expect it to do,
> and what does it do instead? Show some code.
>
> > Does seek have any limitation on large files ?
>
> No.
>
> > Are there any other large-file-dangers I should be aware of ?
>
> None before you hit the 2GB limit.
>
> Anno
------------------------------
Date: Wed, 06 Jun 2001 08:46:31 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Very unexpected behavior W2K/Win98SE
Message-Id: <979shts3mbrf21528vhgj3tvv7rv901io2@4ax.com>
--I was working on a script (based on a question here) at work on my
W2K laptop in between actual work and it wasn't doing things they way
I had hoped. So since my wife and son were out for the night I
decided to bring it home.
--While it wasn't working as hoped at work; it was crashing my box at
home! I tried running in MSDOS mode but to no avail. It still
crashed my machine. any ideas? <code below>
#!/usr/bin/perl -w
use diagnostics ;
use strict ;
my $old = `dir /b *.jpg` ;
open (PIX, '+> c:\dir\pix.txt') || die "Can't open file: $!" ;
#intentionally clobbering pix.txt
print PIX $old ;
#get dir /b to a .txt file
close PIX || die "Can't close file: $!" ;
open (PIX, 'c:\dir\pix.txt') || die "Can't open file: $!" ;
#now I just want to read the file
open (NPC, '>>c:\dir\nname.txt') || die "Can't open file: $!" ;
#new .txt file for write function to see what changes were made
my ($oldn, $newn);
while (<PIX>) {
chomp;
$oldn = $newn = $_ ;
$newn =~ tr/A-Z/a-z/;
write NPC;
rename ($oldn, $newn) || die "Didn't rename anything: $!" ;
#this is not working
}
close NPC || die "Can't close file: $!" ;
format NPC_TOP =
---------------- ----------------
Old Name New Name
---------------- ----------------
.
format NPC =
@<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<
$oldn, $newn
.
--
BSOD? In my day we didn't have 0000FF!
lmoran@wtsg.com
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.
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 V10 Issue 1072
***************************************