RE: Toper variable question

  • From: "Gogala, Mladen" <MGogala@xxxxxxxxxxxxxxxxxxxx>
  • To: "'spikey.mcmarbles@xxxxxxxxx'" <spikey.mcmarbles@xxxxxxxxx>, ORACLE-L <oracle-l@xxxxxxxxxxxxx>
  • Date: Tue, 23 Nov 2004 16:04:54 -0500

There is no need to write your own functions. There is a module
which implements PHP functions. It's called PHP::Strings and one 
of the functions that is implemented is str_pad. The most interesting 
thing  in the whole module is the fact that it is full of rant against 
PHP by its authors, but they've chosen to implement PHP string functions
in perl, nevertheless.
--
Mladen Gogala
Ext. 121
-----Original Message-----
From: Greg Norris [mailto:spikey.mcmarbles@xxxxxxxxx] 
Sent: Tuesday, November 23, 2004 11:46 AM
To: ORACLE-L
Subject: Re: OT:perl variable question

Here's a quick-n-dirty padding function I've used in the past.

sub lpad {
   return($_[1] x ($_[2] - length($_[0])) . $_[0]);
}

To pad a string with spaces to 10 characters, you'd invoke it like:

   $myvar = &lpad($myvar, " ", 10);


On Tue, 23 Nov 2004 10:37:14 -0500, Michael McMullen
<ganstadba@xxxxxxxxxxx> wrote:
> 
> 
> I'm trying to get the length of a variable and if the variable isn't a
> certain length pad it to the specified length.
> Can anyone help?
> 
> Thanks
> Mike
> --
> //www.freelists.org/webpage/oracle-l
> 


-- 
"I'm too sexy for my code." - Awk Sed Fred.
--
//www.freelists.org/webpage/oracle-l


--
//www.freelists.org/webpage/oracle-l

Other related posts: