On Friday 02 July 2004 15:55, Rod Za wrote: > Hi all, > > Someone knows an way to do this more easy? > > _BEGIN_ > #!/usr/bin/perl > use warnings; > use strict; > my $job = 15; > my $job_name = 'd00000'; > print "JOBNAME $job_name LENGTH: ".length($job_name)."\n"; > print "JOB...: $job LENGTH: ".length($job)."\n"; > print substr($job_name,-length($job_name),-length($job)).$job."-001\n"; > _END_ >
Hi Rod, take a look at the sprintf function ("perldoc -f sprintf") - something like: #!/usr/bin/perl -w use strict; my $shortnumber = '10'; my $longnumber = '1000'; print sprintf("shortnumber : %06d\n", $shortnumber); print sprintf("longnumber : %06d\n", $longnumber); might do the trick. BTW: It's easier to help if you specify what you want to do - in this case it didn't matter much, but it can take some time to understand what a piece of code should be doing... ;-) HTH, Philipp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>