[30093] in Perl-Users-Digest
Perl-Users Digest, Issue: 1336 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 6 03:09:40 2008
Date: Thu, 6 Mar 2008 00:09:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 6 Mar 2008 Volume: 11 Number: 1336
Today's topics:
Re: CGI file based logging <usenet@davidfilmer.com>
Re: CGI file based logging <howachen@gmail.com>
insert codes dynamically <rose@russ.org>
Re: insert codes dynamically <devnull4711@web.de>
Re: insert codes dynamically <rose@russ.org>
Re: insert codes dynamically <devnull4711@web.de>
module needs to know its own path <lehmannmapson@cnm.de>
Re: module needs to know its own path <tadmc@seesig.invalid>
new CPAN modules on Thu Mar 6 2008 (Randal Schwartz)
Re: Parsing blocks of text in Perl <someone@example.com>
Re: Parsing blocks of text in Perl <ernest.mueller@ni.com>
Re: Rename File Using Strring Found in File? <Entwadumayla@HyenaKiller.com>
Re: Rename File Using Strring Found in File? <someone@example.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 05 Mar 2008 18:32:47 -0800
From: David Filmer <usenet@davidfilmer.com>
Subject: Re: CGI file based logging
Message-Id: <rdadnWEc6dEPylLaRVn_vwA@giganews.com>
howa wrote:
> Apache are running at multi-process, are there any modules which can
> handle file locking issue if I received many requests?
Apache has its own logging utility and it manages to sort out the
problems of having multiple threads. So I would recommend trying to
find a way to let Apache do the heavy lifting by accessing Apache's own
logging utility.
Hmmm... I wonder if somebody might have written such a module?
A quick search of CPAN finds Perl interfaces to Apache's logging
utility. There's the sparsely documented Apache::Log and the very
encouraging Log::Dispatch::Apache::Log which allows you to use the
sooper-dooper excellent Log Dispatch module.
------------------------------
Date: Wed, 5 Mar 2008 23:01:27 -0800 (PST)
From: howa <howachen@gmail.com>
Subject: Re: CGI file based logging
Message-Id: <b49cca42-9355-40e4-a384-ef4837978ab1@59g2000hsb.googlegroups.com>
On 3$B7n(B6$BF|(B, $B>e8a(B10$B;~(B32$BJ,(B, David Filmer <use...@davidfilmer.com> wrote:
>
> A quick search of CPAN finds Perl interfaces to Apache's logging
> utility. There's the sparsely documented Apache::Log and the very
> encouraging Log::Dispatch::Apache::Log which allows you to use the
> sooper-dooper excellent Log Dispatch module.
The Apache::Log only allow you to write log to the apache log, but
sometimes we would want to create a different file.
Btw, I can't find Log::Dispatch::Apache::Log in CPAN...
So far I think the module: Log::Dispatch::FileShared is what I need, I
am testing it now.
Thanks.
Howard
------------------------------
Date: Thu, 6 Mar 2008 11:37:11 +0800
From: "Rose" <rose@russ.org>
Subject: insert codes dynamically
Message-Id: <fqnot7$v49$1@ijustice.itsc.cuhk.edu.hk>
I have to add objects dynamically in a code and therefore the number of
objects are not known beforehand. How to achieve this effectly in a simple
way? e.g.
#fixed codes
$panel = Panel->new(
-length => 1000,
-width => 10,
);
#dynamic codes
my $obj1 = Object::Generic->new(
-start => 10,
-end => 10,
-display_name => 'C'
);
my $obj2 = Object::Generic->new(
-start => 88,
-end => 89,
-display_name => 'T'
);
...
my $objn = Object::Generic->new(
-start => p,
-end => q,
-display_name => 'N'
);
$panel->add_obj($obj1);
$panel->add_obj($obj2);
...
$panel->add_obj($objn);
------------------------------
Date: Thu, 06 Mar 2008 05:18:56 +0100
From: Frank Seitz <devnull4711@web.de>
Subject: Re: insert codes dynamically
Message-Id: <6399lhF2686pmU2@mid.individual.net>
Rose wrote:
> I have to add objects dynamically in a code and therefore the number of
> objects are not known beforehand. How to achieve this effectly in a simple
> way? e.g.
my $panel = Panel->new(...);
my @arr = ([10,10,'C'],[88,89,'T'],...);
for my $e (@arr) {
my $obj = Object::Generic->new(
-start=>$e->[0],
-end=>$e->[1],
-display_name=>$e->[2],
);
$panel->add_obj($obj);
}
Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
------------------------------
Date: Thu, 6 Mar 2008 13:16:58 +0800
From: "Rose" <rose@russ.org>
Subject: Re: insert codes dynamically
Message-Id: <fqnuoa$266$1@ijustice.itsc.cuhk.edu.hk>
"Frank Seitz" <devnull4711@web.de> wrote in message
news:6399lhF2686pmU2@mid.individual.net...
> Rose wrote:
>> I have to add objects dynamically in a code and therefore the number of
>> objects are not known beforehand. How to achieve this effectly in a
>> simple
>> way? e.g.
>
> my $panel = Panel->new(...);
>
> my @arr = ([10,10,'C'],[88,89,'T'],...);
> for my $e (@arr) {
> my $obj = Object::Generic->new(
> -start=>$e->[0],
> -end=>$e->[1],
> -display_name=>$e->[2],
> );
> $panel->add_obj($obj);
> }
>
> Frank
> --
> Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
> Anwendungen für Ihr Internet und Intranet
> Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
Frank, Thanks a lot for your response. Indeed, @arr is not known beforehand
and the content of @arr is generated by another perlscript. How would you
recommend to bridge these 2 perlscripts? The first one, I store the 10, 88,
...; 10, 89, ...; and C, T, ... into separate arrays, say @a1, @a2, @a3. A
simple but dirty way is to copy the contents of the 1st file to the 2nd and
then @arr = (@a1, @a2, @a3), but this does not look to be a good practice.
------------------------------
Date: Thu, 06 Mar 2008 06:43:25 +0100
From: Frank Seitz <devnull4711@web.de>
Subject: Re: insert codes dynamically
Message-Id: <639ejuF26samiU1@mid.individual.net>
Rose wrote:
>
> Frank, Thanks a lot for your response. Indeed, @arr is not known beforehand
> and the content of @arr is generated by another perlscript. How would you
> recommend to bridge these 2 perlscripts? The first one, I store the 10, 88,
> ...; 10, 89, ...; and C, T, ... into separate arrays, say @a1, @a2, @a3.
> A simple but dirty way is to copy the contents of the 1st file to the 2nd and
> then @arr = (@a1, @a2, @a3), but this does not look to be a good practice.
To copy @a1, @a2, @a3 this way would not work.
Copying is not necessary. Try this:
for (my $i = 0; $i < @a1; $i++) {
my $obj = Object::Generic->new(
-start=>$a1[$i],
-end=>$a2[$i],
-display_name=>$a3[$i],
);
$panel->add_obj($obj);
}
Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
------------------------------
Date: Thu, 06 Mar 2008 01:08:03 +0100
From: Marten Lehmann <lehmannmapson@cnm.de>
Subject: module needs to know its own path
Message-Id: <638r2sF26jauuU1@mid.individual.net>
Hello,
within a perl module, I need to access content included with this
module, but stored in separate files (WSDL definitions in my case).
If my module lies in /usr/lib/perl5/xxx/MyModule.pm, the WDSL files
could be stored in /usr/lib/perl5/xxx/MyModule/WSDLs/*.wsdl or similar.
But how can the perl module find out where it has been loaded from? The
files I have to access would always be relative to the perl module. But
that doesn't help much, as the working directory within the perl module
for a perl script in /test/script.pl would always be /test and not the
path to the script. So reading from ./WSDLs/*.wsdl would fail.
Any ideas?
Regards
Marten
------------------------------
Date: Wed, 5 Mar 2008 19:29:01 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: module needs to know its own path
Message-Id: <slrnfsui6t.vhf.tadmc@tadmc30.sbcglobal.net>
Marten Lehmann <lehmannmapson@cnm.de> wrote:
> Hello,
>
> within a perl module, I need to access content included with this
> module, but stored in separate files (WSDL definitions in my case).
>
> If my module lies in /usr/lib/perl5/xxx/MyModule.pm, the WDSL files
> could be stored in /usr/lib/perl5/xxx/MyModule/WSDLs/*.wsdl or similar.
>
> But how can the perl module find out where it has been loaded from? The
> files I have to access would always be relative to the perl module. But
> that doesn't help much, as the working directory within the perl module
> for a perl script in /test/script.pl would always be /test and not the
> path to the script. So reading from ./WSDLs/*.wsdl would fail.
>
> Any ideas?
(my $dir = $INC{'MyModule.pm'}) =~ s#/MyModule.pm$##;
chdir $dir or die "could not cd to '$dir' $!";
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Thu, 6 Mar 2008 05:42:18 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Mar 6 2008
Message-Id: <JxAnuI.1Jo4@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Acme-ManekiNeko-0.02
http://search.cpan.org/~gmccar/Acme-ManekiNeko-0.02/
----
Angel_002
http://search.cpan.org/~mingzhang/Angel_002/
Build up a robust connection to your DUT
----
Apache-AuthTkt-0.08
http://search.cpan.org/~gavinc/Apache-AuthTkt-0.08/
module to generate authentication tickets for mod_auth_tkt apache module.
----
CGI-CMS-0.28
http://search.cpan.org/~lze/CGI-CMS-0.28/
----
CPAN-Dependency-0.15
http://search.cpan.org/~saper/CPAN-Dependency-0.15/
Analyzes CPAN modules and generates their dependency tree
----
Catalyst-Model-DBIC-0.16
http://search.cpan.org/~bricas/Catalyst-Model-DBIC-0.16/
(DEPRECATED) DBIC Model Class
----
Catalyst-View-Download-0.02
http://search.cpan.org/~gaudeon/Catalyst-View-Download-0.02/
----
Class-C3-Componentised-1.0003
http://search.cpan.org/~ash/Class-C3-Componentised-1.0003/
----
DBIx-MoCo-0.16
http://search.cpan.org/~jkondo/DBIx-MoCo-0.16/
Light & Fast Model Component
----
Data-PrioQ-SkewBinomial-0.03
http://search.cpan.org/~mauke/Data-PrioQ-SkewBinomial-0.03/
A functional priority queue based on skew binomial trees
----
Devel-NYTProf-0.02
http://search.cpan.org/~akaplan/Devel-NYTProf-0.02/
line-by-line code profiler and report generator
----
Egg-Plugin-SessionKit-3.03
http://search.cpan.org/~lushe/Egg-Plugin-SessionKit-3.03/
Package kit to use session.
----
Egg-Release-3.07
http://search.cpan.org/~lushe/Egg-Release-3.07/
Version of Egg WEB Application Framework.
----
Egg-Release-Authorize-0.02
http://search.cpan.org/~lushe/Egg-Release-Authorize-0.02/
Package kit for attestation.
----
Egg-Release-DBI-0.03
http://search.cpan.org/~lushe/Egg-Release-DBI-0.03/
Package kit of model DBI.
----
Eludia-08.03.05.1107
http://search.cpan.org/~dmow/Eludia-08.03.05.1107/
----
File-Find-Object-0.1.0
http://search.cpan.org/~shlomif/File-Find-Object-0.1.0/
An object oriented File::Find replacement
----
Games-Go-Sgf2Dg-4.215
http://search.cpan.org/~reid/Games-Go-Sgf2Dg-4.215/
----
Games-Roguelike-Caves-0.01
http://search.cpan.org/~zpmorgan/Games-Roguelike-Caves-0.01/
generation of cave levels using cellular automata
----
Ganglia-Gmetric-0.2
http://search.cpan.org/~fungus/Ganglia-Gmetric-0.2/
perl gmetric wrapper
----
HTML-CTPP2-2.0.5
http://search.cpan.org/~stellar/HTML-CTPP2-2.0.5/
Perl interface for CTPP2 library
----
IPC-MorseSignals-0.10
http://search.cpan.org/~vpit/IPC-MorseSignals-0.10/
Communicate between processes with Morse signals.
----
IPC-MorseSignals-0.11
http://search.cpan.org/~vpit/IPC-MorseSignals-0.11/
Communicate between processes with Morse signals.
----
Image-XWD-0.1
http://search.cpan.org/~nmarci/Image-XWD-0.1/
X Window Dump image reader
----
Lingua-Alphabet-Phonetic-0.056
http://search.cpan.org/~mthurn/Lingua-Alphabet-Phonetic-0.056/
map ABC's to phonetic alphabets
----
Lingua-Alphabet-Phonetic-NetHack-1.04
http://search.cpan.org/~mthurn/Lingua-Alphabet-Phonetic-NetHack-1.04/
map ASCII characters to names of NetHack items
----
MOBY-Client-1.01
http://search.cpan.org/~ekawas/MOBY-Client-1.01/
----
Math-LogRand-0.03
http://search.cpan.org/~lgoddard/Math-LogRand-0.03/
Perl extension to return a random number with log weighting.
----
Module-Which-0.0207
http://search.cpan.org/~ferreira/Module-Which-0.0207/
Finds out which version of Perl modules are installed
----
MooseX-Singleton-0.06
http://search.cpan.org/~sartak/MooseX-Singleton-0.06/
turn your Moose class into a singleton
----
Net-OBEX-0.003
http://search.cpan.org/~zoffix/Net-OBEX-0.003/
implementation of OBEX protocol
----
OOB-0.11
http://search.cpan.org/~elizabeth/OOB-0.11/
out of band data for any data structure in Perl
----
OOPS-0.2004
http://search.cpan.org/~muir/OOPS-0.2004/
Object Oriented Persistent Store
----
OpenResty-0.0.6
http://search.cpan.org/~agent/OpenResty-0.0.6/
General-Purpose Web Services for Web Applications
----
OpenResty-0.0.7
http://search.cpan.org/~agent/OpenResty-0.0.7/
General-Purpose Web Services for Web Applications
----
OpenResty-0.0.8
http://search.cpan.org/~agent/OpenResty-0.0.8/
General-purpose web service platform for web applications
----
OpenResty-0.0.9
http://search.cpan.org/~agent/OpenResty-0.0.9/
General-purpose web service platform for web applications
----
POE-Component-Client-Ident-1.12
http://search.cpan.org/~bingos/POE-Component-Client-Ident-1.12/
A component that provides non-blocking ident lookups to your sessions.
----
POE-Component-IRC-Plugin-QueryDNS-0.02
http://search.cpan.org/~bingos/POE-Component-IRC-Plugin-QueryDNS-0.02/
A POE::Component::IRC plugin for IRC based DNS queries
----
RT-Authen-Bitcard-0.04
http://search.cpan.org/~ruz/RT-Authen-Bitcard-0.04/
Allows RT to do authentication via a service which supports the Bitcard API
----
RT-BugTracker-0.03
http://search.cpan.org/~ruz/RT-BugTracker-0.03/
Adds a UI designed for bug-tracking for developers to RT
----
RT-BugTracker-Public-0.02
http://search.cpan.org/~ruz/RT-BugTracker-Public-0.02/
Adds a public, (hopefully) userfriendly bug tracking UI to RT
----
RT-Extension-TicketAging-0.11
http://search.cpan.org/~ruz/RT-Extension-TicketAging-0.11/
allows tickets to be made inaccessable and finally completely deleted
----
RT-Extension-TicketLocking-0.09
http://search.cpan.org/~ruz/RT-Extension-TicketLocking-0.09/
Enables users to place advisory locks on tickets
----
RT-Extension-rt_cpan_org-0.02
http://search.cpan.org/~ruz/RT-Extension-rt_cpan_org-0.02/
The customizations that turn a RT into a RT for rt.cpan.org
----
SRU-0.97
http://search.cpan.org/~bricas/SRU-0.97/
Search and Retrieval by URL
----
SVN-Notify-Config-0.091
http://search.cpan.org/~jpeacock/SVN-Notify-Config-0.091/
Config-driven Subversion notification
----
Test-Aggregate-0.07
http://search.cpan.org/~ovid/Test-Aggregate-0.07/
Aggregate *.t tests to make them run faster.
----
Text-Trac-0.11
http://search.cpan.org/~mizzy/Text-Trac-0.11/
Perl extension for formatting text with Trac Wiki Style.
----
WWW-Lengthen-0.03
http://search.cpan.org/~ishigaki/WWW-Lengthen-0.03/
lengthen 'shortened' urls
----
WWW-Mixi-Scraper-0.13
http://search.cpan.org/~ishigaki/WWW-Mixi-Scraper-0.13/
yet another mixi scraper
----
WWW-PastebinCom-Retrieve-0.002
http://search.cpan.org/~zoffix/WWW-PastebinCom-Retrieve-0.002/
retrieve content of pastes from <http://pastebin.com>
----
WWW-Search-Yahoo-Deutschland-1.003
http://search.cpan.org/~mthurn/WWW-Search-Yahoo-Deutschland-1.003/
class for searching Yahoo! Deutschland (Germany)
----
WWW-Search-Yahoo-Deutschland-1.004
http://search.cpan.org/~mthurn/WWW-Search-Yahoo-Deutschland-1.004/
class for searching Yahoo! Deutschland (Germany)
----
WWW-Shorten-urlTea-0.02
http://search.cpan.org/~bgilmore/WWW-Shorten-urlTea-0.02/
Perl interface to urltea.com
----
Win32-File-Object-0.01
http://search.cpan.org/~adamk/Win32-File-Object-0.01/
Simplified object abstraction over Win32::File
----
WordNet-Similarity-2.02
http://search.cpan.org/~tpederse/WordNet-Similarity-2.02/
modules for computing semantic relatedness.
----
Yahoo-Marketing-4.02
http://search.cpan.org/~shenj/Yahoo-Marketing-4.02/
an interface for Yahoo! Search Marketing's Web Services.
----
using_mysql_indexes
http://search.cpan.org/~ruz/using_mysql_indexes/
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Thu, 06 Mar 2008 03:00:19 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Parsing blocks of text in Perl
Message-Id: <77Jzj.64681$FO1.27672@edtnps82>
mxyzplk wrote:
> Thanks man. Here's what I was trying to do, without splitting:
>
> #!/bin/perl
use warnings;
use strict;
> #
> # Usage: linkxfer.pl file
> #
>
> ((($file) = @ARGV) == 1 && -f $file)
> || die "Usage: $0 file\n";
Probably better written as:
@ARGV == 1 && -f $ARGV[0] and my $file = shift or die "Usage: $0 file\n";
> open(IN,"$file");
You should *always* verify that the file opened correctly:
open IN, '<', $file or die "Cannot open '$file' $!";
> $|=1;
>
> while ($line=<IN>) {
while ( my $line = <IN> ) {
> $line =~ s/\[\[([^:]+?)\|(.+?\]\])/[[General:\1|\2/g;
Backreferences \1 and \2 should only be used *inside* a regular
expression, you should use $1 and $2 instead.
> print $line;
> }
>
> close IN;
>
> exit;
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Wed, 5 Mar 2008 19:42:39 -0800 (PST)
From: mxyzplk <ernest.mueller@ni.com>
Subject: Re: Parsing blocks of text in Perl
Message-Id: <f83a0dee-69b4-4527-b002-4271c7e68a43@v3g2000hsc.googlegroups.com>
Thanks John, better style noted! (I'm often working off an old first
edn. of the O'Reilly Programming Perl book so my idioms are sadly
decrepit :-)
Ernest
------------------------------
Date: Wed, 05 Mar 2008 23:23:36 -0600
From: He Who Greets With Fire <Entwadumayla@HyenaKiller.com>
Subject: Re: Rename File Using Strring Found in File?
Message-Id: <qgvus31ubl9lnna92ktlkkttmk7c3mtnum@4ax.com>
On Tue, 04 Mar 2008 12:10:16 GMT, Tad J McClellan
<tadmc@seesig.invalid> wrote:
>He Who Greets With Fire <Entwadumayla@HyenaKiller.com> wrote:
>
>> I have a file directory named E:/personalinjury. In the file directory
>> are 821 files named from 1.htm to 821.htm
>>
>> I want to access each file in turn,
>
>
> foreach my $file ( glob 'E:/personalinjury/*.htm' ) { # untested
>
>
>> and use a regex to parse the file
>> contents to see if a string similar to this one is found in it:
>> Citation: 20-333 Dorsaneo, Texas Litigation Guide § 333.103
>
> open my $PI, '<', $file or die "could not open '$file' $!";
> while ( <$PI> ) {
> next unless /Citation: [\d-]+.*([\d.]+)/;
> my $newfile = $1;
>
>
>> So, I want to rename that file to 333.103 from whatever it was before
>
>
> rename $file, "$newfile.htm" or die "could not mv '$file' $!";
> last;
> }
> close $PI;
I have solved all the problems and have created a working script to
accomplish the task I needed to do . THere are however some problems
with the code you posted above here. For one, the rename() function
takes string values as arguments, not file handles. A file handle is a
pointer, and as such, its value is a numerical value representing an
address in RAM memory, not a string value. The $file variable you used
above as the first argument to rename() is a file handle, not a string
value. Second, you cannot rename a file that is presently open for
reading. Above, you closed the file later after you tried to rename
it. You should have closed it before you tried to rename it.
--He Who Greets With Fire
------------------------------
Date: Thu, 06 Mar 2008 07:06:54 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Rename File Using Strring Found in File?
Message-Id: <iKMzj.66833$w57.24263@edtnps90>
He Who Greets With Fire wrote:
> On Tue, 04 Mar 2008 12:10:16 GMT, Tad J McClellan
> <tadmc@seesig.invalid> wrote:
>=20
>> He Who Greets With Fire <Entwadumayla@HyenaKiller.com> wrote:
>>
>>> I have a file directory named E:/personalinjury. In the file director=
y
>>> are 821 files named from 1.htm to 821.htm=20
>>>
>>> I want to access each file in turn,=20
>>
>> foreach my $file ( glob 'E:/personalinjury/*.htm' ) { # untested
>>
>>
>>> and use a regex to parse the file
>>> contents to see if a string similar to this one is found in it:
>>> Citation: 20-333 Dorsaneo, Texas Litigation Guide =A7 333.103
>> open my $PI, '<', $file or die "could not open '$file' $!";
>> while ( <$PI> ) {
>> next unless /Citation: [\d-]+.*([\d.]+)/;
>> my $newfile =3D $1;
>>
>>
>>> So, I want to rename that file to 333.103 from whatever it was before=
>>
>> rename $file, "$newfile.htm" or die "could not mv '$file' $!";
>> last;
>> }
>> close $PI;
>=20
> I have solved all the problems and have created a working script to
> accomplish the task I needed to do . THere are however some problems
> with the code you posted above here. For one, the rename() function
> takes string values as arguments, not file handles.
Yes, it renames files using (surprise) the names of files.
> A file handle is a pointer,
Not in Perl, Perl doesn't have pointers.
> and as such, its value is a numerical value representing an
> address in RAM memory, not a string value. The $file variable you used
> above as the first argument to rename() is a file handle, not a string
> value.
The only filehandle in the code above is $PI. $file is a file name=20
obtained from "glob 'E:/personalinjury/*.htm'".
> Second, you cannot rename a file that is presently open for
> reading. Above, you closed the file later after you tried to rename
> it. You should have closed it before you tried to rename it.
Only on Windows. Other operating systems allow a file to be renamed=20
whether or not it is opened.
John
--=20
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 1336
***************************************