[22083] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4305 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 23 11:05:59 2002

Date: Mon, 23 Dec 2002 08:05:08 -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           Mon, 23 Dec 2002     Volume: 10 Number: 4305

Today's topics:
        active perl (activeperl) window closes before I can rea (R Solberg)
    Re: active perl (activeperl) window closes before I can <me@privacy.net>
    Re: ActiveState ppm packages <randy@theoryx5.uwinnipeg.ca>
        Damian Conway Classes in Boston <uri@stemsystems.com>
    Re: Design Tools and Resources on one page . . . it is  <asg779e@earthlink.net>
    Re: Design Tools and Resources on one page . . . it is  <usenet@dwall.fastmail.fm>
    Re: File::Find module ; want to resume search from poin (Anno Siegel)
        how to read(string) instead of read(STDIN)? <marc@nospam.com>
    Re: how to read(string) instead of read(STDIN)? <bart.lateur@pandora.be>
    Re: how to use system to send data to a command that as <nospam@nospam.org>
        MIL-A-8625E Type3 6479 (Cooler Master)
    Re: Need help with octal numbers in substitution (Anno Siegel)
        Problems with "require" (Martin Ulrich)
    Re: Problems with "require" <ubl@schaffhausen.de>
    Re: Problems with "require" (Martin Ulrich)
    Re: Problems with "require" <paul@pco.iis.nsk.su>
    Re: regexp for hostnames <bongie@gmx.net>
    Re: regexp for hostnames <mgjv@tradingpost.com.au>
    Re: Replacing text strings contains more than 1 dot (raj)
        snmp and perl <bastian.zacher@aspect-onlin.de>
        using Perl inside directories and extensions questions <patrick@ocg6.marine.usf.edu>
    Re: using Perl inside directories and extensions questi <usenet@dwall.fastmail.fm>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 22 Dec 2002 22:25:01 -0800
From: flateyjarbok@yahoo.com (R Solberg)
Subject: active perl (activeperl) window closes before I can read anything
Message-Id: <386cc483.0212222225.320a3411@posting.google.com>

Hi,
I have active perl installed on windows 98.  Whenever I run a perl pgm
(by double clicking on the .pl file using windows explorer, a perl
window opens and my error (and other) messages appear, but the window
closes in less than a second and I can't read anything.  How do I keep
this window open so that I can read my error messages?

Thanks!


------------------------------

Date: Mon, 23 Dec 2002 18:16:51 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: active perl (activeperl) window closes before I can read anything
Message-Id: <au6d96$4rcgb$1@ID-172104.news.dfncis.de>


"R Solberg" <flateyjarbok@yahoo.com> wrote in message
news:386cc483.0212222225.320a3411@posting.google.com...
> Hi,
> I have active perl installed on windows 98.  Whenever I run a perl pgm
> (by double clicking on the .pl file using windows explorer, a perl
> window opens and my error (and other) messages appear, but the window
> closes in less than a second and I can't read anything.  How do I keep
> this window open so that I can read my error messages?

Run it from a DOS window.




------------------------------

Date: Mon, 23 Dec 2002 09:57:18 -0600
From: "Randy Kobes" <randy@theoryx5.uwinnipeg.ca>
Subject: Re: ActiveState ppm packages
Message-Id: <vnGN9.6547$7_.27626@news1.mts.net>

"matt" <linuxnb@yahoo.com> wrote in message
 news:bwnM9.398211$P31.145818@rwcrnsc53...
> Hi people,
>
> Just wondering if anyone can help me out with PPM. I am going on a trip,
and
> I won't have Internet access. I downloaded all of the Active State perl
> .ppd files, and the associated tarballs to my laptop so that I would have
> all of the modules I might need during my trip. The problem is that I am
> not running ActiveState perl. I am running the perl that came with my
> Mandrake Linux 9.0 distro - v5.8.0 built for i386-linux-thread-multi.
>
> I installed PPM, and added the local directory as a repository. The
problem
> is the architechture. PPM fails because it says that there are no valid
> architectures found. It wants perl 5.8.0 built for
i686-linux-thread-multi.
> Is there a big difference here? Can I get away with installing these
> modules?
>
> The .ppd files all have the following line in them:
>
> <ARCHITECTURE NAME="i686-linux-thread-multi-5.8" />

Try just deleting the '-5.8' from the ARCHITECTURE ...

In principle these should be compatible, as long as your Perl and
ActiveState's Perl were compiled with the same compile-time flags.
One thing in particular that you might check, especially for use with
mod_perl, is if both were compiled with LARGE_FILES support - if
different, this might affect binary compatibility.

best regards,
randy kobes





------------------------------

Date: Mon, 23 Dec 2002 07:00:35 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Damian Conway Classes in Boston
Message-Id: <x78yyhdxt9.fsf@mail.sysarch.com>


For the past two summers, we have had the privilege of offering in
Boston, Perl classes taught by Damian Conway. The classes have been a
major success and we are happy that Damian is coming back to teach three
classes over four days in January, 2003.

We are bringing back the two day Advanced Object Oriented Perl class
that was so popular in July, 2001. This class is for anyone who wants to
take their OO Perl skills to the next level. Data Munging is being
offered here for the first time and it will cover highly practical ways
to process data in Perl. Parsing for Bioinformatics is very similar to
the popular Parsing with Perl class that Damian taught last summer but
all the examples presented in this course use the language, data sets,
and real-world problems of bioinformatics.  However, none of the
examples delves into arcane biotechologies, so Perl students with any
background or interests can attend and improve their skills.

The classes will be held from January 21-24 (Tue-Fri), 2003 at the
Amethyst Center in Davis Sq., Somerville, MA.

All the information about the classes and how to register can be found
at:

	http://stemsystems.com/class/

and it is mirrored at:

	http://kuiki.net/class/

So start off the New Year with the best Perl teacher anywhere around the
world (and Damian has been around it a few times!).  And a new training
budget comes with the New Year, so get your request in now before it
gets spent elsewhere.

We are again offering a 50% discount to the underemployed and students.


-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


------------------------------

Date: Mon, 23 Dec 2002 14:15:34 GMT
From: "gbd" <asg779e@earthlink.net>
Subject: Re: Design Tools and Resources on one page . . . it is fairly extensive!
Message-Id: <aUEN9.2233$ka5.274836@newsread1.prod.itd.earthlink.net>

Then will somebody please tell those people that placed 234 postings on that
"non-existent newsgroup", dated 12.05.02 to 12.22.02, that the group really
does not exist!  I could have been just imagining those postings, but I just
went and checked...  maybe i am still dreaming.  You perl guys are really,
really smart...  REALLY!  Thanks.
gbd

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnb0c0cj.9q9.tadmc@magna.augustmail.com...
> gbd <asg779e@earthlink.net> wrote:
>
> > I spent some time researching these sites and this page is the results
of
> > that research.
>
>
> comp.lang.perl is a non-existant newsgroup.
>
> It was rmgroup'd many years ago.
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas
>




------------------------------

Date: Mon, 23 Dec 2002 15:40:09 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Design Tools and Resources on one page . . . it is fairly extensive!
Message-Id: <Xns92ED6C8843F50dkwwashere@216.168.3.30>

gbd <asg779e@earthlink.net> wrote on 23 Dec 2002:

> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrnb0c0cj.9q9.tadmc@magna.augustmail.com...

>> comp.lang.perl is a non-existant newsgroup.
>>
>> It was rmgroup'd many years ago.

> Then will somebody please tell those people that placed 234
> postings on that "non-existent newsgroup", dated 12.05.02 to
> 12.22.02, that the group really does not exist!  I could have been
> just imagining those postings, but I just went and checked... 
> maybe i am still dreaming.  You perl guys are really, really
> smart...  REALLY!  Thanks. gbd

It's not Tad's fault if some admins of news servers carelessly carry 
newsgroups that no longer exist.  Maybe you should complain to your 
news admin(s), not this group.  They're doing their users a 
disservice by carrying comp.lang.perl.  

If you promote comp.lang.perl on your web site, you're perpetuating 
the problem.  It encourages new Perl users to post to a newsgroup 
that more knowledgeable people don't bother to read.

-- 
David K. Wall - usenet@dwall.fastmail.fm
"Oook."


------------------------------

Date: 23 Dec 2002 11:32:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: File::Find module ; want to resume search from point of failure.
Message-Id: <au6s8j$55d$1@mamenchi.zrz.TU-Berlin.DE>

According to Mitchell Laks <mlaks2000@yahoo.com>:
> Hi - 
> 
> Dear Perl Gurus
> 
> I am using File::Find to execute a command on the files in a directory
> (i call the command &wanted for cultural reasons :) ).
> 
> However if an exception  is raised, and my search gets aborted, and if
> i keep track of what file was acted upon when the search was
> cancelled, is there a way to resume the search and execution from the
> point of failure and avoid searching through all of the (530,000)
> files again from the beginning?
> 
> Thanks millions - i guess i want to be able to say is
> 
> do the file::find algorithm on a directory tree - but begin at
> specified file xyz in the tree... instead of the beginning...

I don't think you'll find such a feature in File::Find.  In general,
re-starting a process over a file system in this way doesn't make
much sense, because a live file system changes permanently. 

For a practical approach, I'd consider just printing to a log file
all directory names File::Find comes across:

    print LOG "$File::Find::name\n" if -d;

Then start the thing and hope for the best.  If it indeed crashes,
evaluate the log to see which directories have been finished and
set up another run that doesn't repeat too much.

The latter step could certainly be automated, but if this is a one-time
(or rare) thing, I wouldn't bother.

Anno


------------------------------

Date: Mon, 23 Dec 2002 21:32:53 +1300
From: "Marcus" <marc@nospam.com>
Subject: how to read(string) instead of read(STDIN)?
Message-Id: <au6hmu$5jj$1@lust.ihug.co.nz>

I'm trying to make a while loop like this: "while(read(STDIN,$q,$w=3)){...}"
except I'd like to use a string instead of STDIN.  I would use Tie, but
don't know what to put in the read() method. Could anyone please help?

Here's my code (main.pl):


package test;


$z = 0;
$d= "";
$w= 0;

$text = "abcdefghijklmnopqrstuvwxyz";

tie *STDIN, Tie::MySTDIN, $text;

while(<STDIN>) {print;} #this prints $text

#while(read(STDIN,$q,$w=3)) { $d++; print $q . $w; } #this doesn't work

package Tie::MySTDIN;

sub TIEHANDLE {
 my $class = shift;

 return bless { BUFFER => shift }
}


sub READLINE {
 my $self = shift;
 for($self->{BUFFER}) {  # alias
  defined and length or return;  # eof
  (my $line, $_) = split /(?<=\n)/, $_, 2;
  return $line;
 }
}

sub read {
}


__END__








------------------------------

Date: Mon, 23 Dec 2002 12:04:54 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: how to read(string) instead of read(STDIN)?
Message-Id: <fsud0vkoh80q86r9luctmpkms4bie9qr44@4ax.com>

Marcus wrote:

>I'm trying to make a while loop like this: "while(read(STDIN,$q,$w=3)){...}"
>except I'd like to use a string instead of STDIN.  I would use Tie, but
>don't know what to put in the read() method. Could anyone please help?

Look into IO::Scalar.

-- 
	Bart.


------------------------------

Date: Mon, 23 Dec 2002 08:04:44 -0500
From: "Christian Caron" <nospam@nospam.org>
Subject: Re: how to use system to send data to a command that ask for input
Message-Id: <au71ld$k3o6@nrn2.NRCan.gc.ca>


"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message
news:Pine.LNX.4.40.0212202042390.1168-100000@lxplus071.cern.ch...
> On Dec 20, Christian Winter inscribed on the eternal scroll:
>
> [good stuff snipped]
>
> > If you are going to use the standard, unix-style crypt
> > password files, you can also install Apache::Htpasswd from
> > CPAN, which lets you directly alter the password files instead
> > of calling the external utility.
>
> If you're going to be handling password tokens at this level, then you
> really need a careful security walk-through to examine the issues and
> potential loopholes of your procedure.  That's not in itself a matter
> for comp.lang.perl.misc (where you'd be welcome to discuss the
> mechanics of the procedure, as long as they're specific to the Perl
> language) but perhaps rather for the comp.security.* groups (as
> relates to security) or comp.infosystems.www.* groups (as it relates
> to web procedures and server configuration).
>

Sorry if I didn't say enough about the program. It's going to be a command
line utility for people (who don't know how to use command lines) to
generate an .htpasswd and .nsconfig (or .htaccess) files to password protect
parts of websites.

Thanks!

Christian




------------------------------

Date: 23 Dec 2002 11:36:32 GMT
From: market@fortex.com.uk(Cooler Master)
Subject: MIL-A-8625E Type3 6479
Message-Id: <au6sg0$8gl@netnews.hinet.net>

Aluminum Extrusion parts and Heatsink for 
customer design OEM.
      
            
   
      
      Hardcoat anodized of MIL-A-8625E Type Three 
of Aluminum parts.
      
            
   
Please link http://www.coolkeep.com for more information. 








/!yM


------------------------------

Date: 23 Dec 2002 11:47:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Need help with octal numbers in substitution
Message-Id: <au6t55$55d$3@mamenchi.zrz.TU-Berlin.DE>

According to Fred  <No_Mail_Address@cox.net>:
> Hello there,
> 
> I want to remove all 8-bit characters from a file, but keep ü ä ö
> (decimal 129, 132, 148)

    tr/üäö/ /cs;

Anno



------------------------------

Date: 23 Dec 2002 02:27:52 -0800
From: mups@mups.ch (Martin Ulrich)
Subject: Problems with "require"
Message-Id: <1a6131f3.0212230227.218c3c0b@posting.google.com>

Hi 
I have Problems with the require statement on a RHL 8.0 System.
Perl Version is 5.8.0-55, Apache(httpd) is 2.0.40-11 and mod_perl
1.99_05-3.
If I put a line like:

require "test.pl";

in the perlfile, it returns:
Can't locate test.pl in @INC ...
I found out that perl search in the root directory for the file
test.pl.
I tested it on a RedHat 7.1 System and it works fine.

I read the documentation, howtos and usergroups but I didn't found an
usefull answer.
Can someone help me.

P.S. Sorry for my english.


------------------------------

Date: Mon, 23 Dec 2002 11:58:49 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Problems with "require"
Message-Id: <au6ti0$gk2$1@news.dtag.de>

Martin Ulrich wrote:
> Hi 
> I have Problems with the require statement on a RHL 8.0 System.
> Perl Version is 5.8.0-55, Apache(httpd) is 2.0.40-11 and mod_perl
> 1.99_05-3.
> If I put a line like:
> 
> require "test.pl";
> 
> in the perlfile, it returns:
> Can't locate test.pl in @INC ...

Well, then print out @INC and see what in there.

->malte


-- 
srand 108641088; print chr int rand 256 for qw<J A P H>



------------------------------

Date: 23 Dec 2002 06:16:43 -0800
From: mups@mups.ch (Martin Ulrich)
Subject: Re: Problems with "require"
Message-Id: <1a6131f3.0212230616.1f040c2@posting.google.com>

Malte Ubl <ubl@schaffhausen.de> wrote in message news:<au6ti0$gk2$1@news.dtag.de>...
> Martin Ulrich wrote:
> > Hi 
> > I have Problems with the require statement on a RHL 8.0 System.
> > Perl Version is 5.8.0-55, Apache(httpd) is 2.0.40-11 and mod_perl
> > 1.99_05-3.
> > If I put a line like:
> > 
> > require "test.pl";
> > 
> > in the perlfile, it returns:
> > Can't locate test.pl in @INC ...
> 
> Well, then print out @INC and see what in there.
> 
> ->malte

(@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .)

But it can't be the solution to add the directory with the Perl file
to @INC.
In RHL 7.1 it was not require to do this.
An other non usefull solution can also been to add the hole path in
the require statement, like require "var/www/html/test/test.pl".

Thanks Martin


------------------------------

Date: Mon, 23 Dec 2002 20:30:10 +0600
From: "Paul Dortman" <paul@pco.iis.nsk.su>
Subject: Re: Problems with "require"
Message-Id: <au76qf$97u$1@news.itfs.nsk.su>

You could add your own path to @INC array. There are
some ways: foe example you could change @INC directly
or to use

use lib '/path/to/you/files/to/include/';
require "test.pl"

> (@INC contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/5.8.0
> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .)
>
> But it can't be the solution to add the directory with the Perl file
> to @INC.
> In RHL 7.1 it was not require to do this.
> An other non usefull solution can also been to add the hole path in
> the require statement, like require "var/www/html/test/test.pl".
>
> Thanks Martin




------------------------------

Date: Mon, 23 Dec 2002 09:43:12 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: regexp for hostnames
Message-Id: <2838642.ebcBgUQPES@nyoga.dubu.de>

Martien Verbruggen wrote:
> #!/usr/local/bin/perl -w
> use strict;
> 
> while (<DATA>)
> {
>     chomp;
>     if (/(^|\.)(green|red)\..+\.com$/)
>     {
>       print "NO : $_\n";
>     }
>     else
>     {
>       print "YES: $_\n";
>     }
> }
> 
> __DATA__
> grub.com
> b.a.com
> Z.Y.X.W.com
> Z.Y.X.red.W.com
> green.a.com
> red.b.com
> b.green.a.com
> b.a.green.com
> b.agreen.a.com
> foo.bar.reda.c.com

Trying
        green.something.W.com
gives a clear YES, so I assume you .+ is too greedy.

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Have a nice day!" - "No, thank you. I have other plans."



------------------------------

Date: Mon, 23 Dec 2002 22:53:54 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: regexp for hostnames
Message-Id: <slrnb0duai.aid.mgjv@martien.heliotrope.home>

On Mon, 23 Dec 2002 09:43:12 +0100,
	Harald H.-J. Bongartz <bongie@gmx.net> wrote:
> Martien Verbruggen wrote:
>> #!/usr/local/bin/perl -w
>> use strict;
>> 
>> while (<DATA>)
>> {
>>     chomp;
>>     if (/(^|\.)(green|red)\..+\.com$/)

> Trying
>         green.something.W.com
> gives a clear YES, so I assume you .+ is too greedy.

It is. It should be replaced with [^.]+

/(^|\.)(green|red)\.[^.]+\.com$/

Martien
-- 
                        | 
Martien Verbruggen      | Freudian slip: when you say one thing but
                        | mean your mother.
                        | 


------------------------------

Date: 23 Dec 2002 07:06:09 -0800
From: sharda@hotmail.com (raj)
Subject: Re: Replacing text strings contains more than 1 dot
Message-Id: <ac4b6b9a.0212230706.25023c5a@posting.google.com>

"John W. Krahn" <krahnj@acm.org> wrote in message news:<3E023587.66F5858D@acm.org>...
> raj wrote:
> > 
> > perl -pi -e 's/oldstring/newstring' filename
> 
> $ perl -pi -e 's/oldstring/newstring' filename
> Substitution replacement not terminated at -e line 1.
> 
> 
> > HTH.
> 
> Not really.
> 
> 
> 
> John

Whoops, sorry, missed the ending "/"....
perl -pi -e 's/oldstring/newstring/' filename


------------------------------

Date: Mon, 23 Dec 2002 11:40:41 +0100
From: Bastian Zacher <bastian.zacher@aspect-onlin.de>
Subject: snmp and perl
Message-Id: <au6pa5$1853$2@news.f.de.plusline.net>

Hello NG,

got serious problems with snmpget called in this perlscript (NET::SNMP):


#!/usr/bin/perl

use Net::SNMP;

$ENV{'MIBS'} = "ALL";
$ENV{'MIBFILES'} = 
"CISCO-MEMORY-POOL-MIB.my:CISCO-FIREWALL-MIB.my:
         CISCO-PRODUCTS-MIB.my:CISCO-PROCESS-MIB-V1SMI.my";

my $curr_conn = "1.3.6.1.4.1.9.9.147.1.2.2.2.1.5.40.6";

my ($session, $error) = Net::SNMP->session(
               -hostname    => shift || '192.168.1.1',
               -community   => shift || 'public',
               );

die "session() error: $error" unless $session;

my $result = $session->get_request($curr_conn);

die "Fehler: ". $session->error unless(defined $result);

$session->close;

print "Connections: ". $result->{$curr_conn} . "\n";

These are the results:

Use of uninitialized value in concatenation (.) or string at 
 ./pixconn.pl line 25.
Connections:

Calling snmpget manually, everything's ok:

snmpget -c public 192.168.1.1 .1.3.6.1.4.1.9.9.147.1.2.2.2.1.5.40.6

Does anybody know, what's wrong ? Using other OID's, both the scipt
and the cmd doing their job correctly.


Thanx a lot,

Bastian



------------------------------

Date: Mon, 23 Dec 2002 08:24:38 -0500
From: Patrick Smith <patrick@ocg6.marine.usf.edu>
Subject: using Perl inside directories and extensions questions
Message-Id: <3E070E96.9A9E306D@ocg6.marine.usf.edu>

Hello,

I have a couple of questions I hope you might be able to answer.  So
here goes.

1) Is there a way to run the same Perl script on all files in a
directory? Is it best done inside Perl, or from a shell script that
calls the Perl script?

2) Is there a way from inside a Perl script to change the extension on
an input file to create a new file name with a different extension for
output? (Input file read in on command line and output file specified
inside the Perl script)

Eg. Data.in from command line becomes Data.out inside Perl script.

Thanks for any help you might be able to give me.

Patrick

--
Patrick A. Smith, Assistant System Administrator
Ocean Circulation Group
University of South Florida
http://ocg6.marine.usf.edu




------------------------------

Date: Mon, 23 Dec 2002 15:22:12 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: using Perl inside directories and extensions questions
Message-Id: <Xns92ED697D0C914dkwwashere@216.168.3.30>

Patrick Smith <patrick@ocg6.marine.usf.edu> wrote on 23 Dec 2002:

> 1) Is there a way to run the same Perl script on all files in a
> directory? Is it best done inside Perl, or from a shell script
> that calls the Perl script?

perldoc -f opendir
perldoc -f readdir

 
> 2) Is there a way from inside a Perl script to change the
> extension on an input file to create a new file name with a
> different extension for output? (Input file read in on command
> line and output file specified inside the Perl script)

use File::Basename;

Loop through the directory entries, use File::Basename to get the 
portion of the filename that you want, put whatever extension you want 
on the end, open a file with that name for writing, and so on.

-- 
David K. Wall - usenet@dwall.fastmail.fm
"Oook."


------------------------------

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 4305
***************************************


home help back first fref pref prev next nref lref last post