🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.perl.misc
Article #327

Re: Perl script question for gurus

#327
From: Parillo
Date: Wed, 10 Sep 1997 00:00
33 lines
1951 bytes

Will you have to do a printf in order to get the leading zeros?
BTW, the perldoc on printf and sprintf is not helpful to non-c 
programmners. Is there a better source (other than deja news?)

lparillo at suffolk dot lib dot ny dot us


Helmut Llamas Stuhne (llamashe@microtec.de) wrote:
: > A quick-n-dirty sketch, you may have to do a little debugging:
: >
: > #!/usr/bin/perl
: >
: > $dir = shift || ".";    # first argument is directory
: > $start = shift || "0";  # second argument is starting number
: >
: > $fnbase = sprintf "%08d", $start;
: > opendir(D, $dir) || die "can't open $dir? $!\n";
: >
: > @files = map { $_ if (-f $_ and $_ !~ /^0.*txt/)} readdir(D);
: > closedir(D);
: >
: > foreach $file (@files) {
: >         rename($file, $fnbase.".txt");
: >         $fnbase++;
: > }

: Only open(D,$dir) you schould change in opendir(D,$dir).Now your script
: is runnig, I have test it.

: regards
:     H.Stuhne
Technical Details
Message-ID: <5v77us$gc$1@news01.li.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <Pine.SOL.3.96.970825153417.22465A-100000@purple.tmn.com> <yd8u3g8lq0c.fsf@hoshi.engr.sgi.com> <340A846C.D6A042C8@microtec.de>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f72c1,bbbaaa795486a906
X-Google-Attributes: gidf72c1,public
X-Google-Thread: 1133f4,bbbaaa795486a906
X-Google-Attributes: gid1133f4,public
X-Google-Thread: fa0ae,bbbaaa795486a906
X-Google-Attributes: gidfa0ae,public
X-Google-Thread: 10f591,bbbaaa795486a906
X-Google-Attributes: gid10f591,public
X-Google-Thread: 112333,bbbaaa795486a906
X-Google-Attributes: gid112333,public
From: lparillo@newshost.li.net (Parillo)
Subject: Re: Perl script question for gurus
Date: 1997/09/10
Message-ID: <5v77us$gc$1@news01.li.net>
X-Deja-AN: 271415501
References: <Pine.SOL.3.96.970825153417.22465A-100000@purple.tmn.com> <yd8u3g8lq0c.fsf@hoshi.engr.sgi.com> <340A846C.D6A042C8@microtec.de>
Followup-To: comp.lang.perl.misc,comp.lang.perl.modules,comp.lang.perl.tk,de.comp.lang.perl,fr.comp.lang.perl
Organization: LI Net
Newsgroups: comp.lang.perl.misc,comp.lang.perl.modules,comp.lang.perl.tk,de.comp.lang.perl,fr.comp.lang.perl