--- Darryl Schnell <[EMAIL PROTECTED]> wrote:
> Forgive all the questions however now I've stumbled accross another problem that has 
>me baffled.
> 
> In the search routine I am working on I have a variable
> 
> $search_str = $x->param('search_str')
> 
> Now the user inputes this string after either choosing from a select statement of 
>EmailName or
> an Account Number. If it is an account number I need to have something check 
>search_str to see
> if it is at least 6 numbers long and if not pad 0's to the front of the account 
>number until it
> is (IE 1616 would be 001616), what I'm confused about is how I would do it. 
> 
> $search_str = &padacctno($search_str)

If I understood you correctly:  if your account number is less than 6 digits long, pad 
it with
zeroes until it is six digits.  We can determine if something is an account number 
because it's
all digits?  (just a guess)

see "perldoc -f sprintf" and "perldoc -f printf"

    # it's an account number if it's one or more digits
    if ( $search_str =~ /^\d+$/ )
    {
        $search_str = sprintf( "%06d", $search_str ) if length $search_str < 6;
    }

If that's not what you're looking for, let us know.  I suspect that it's close to what 
you want,
but not quite it.  I really couldn't tell from your question.

Cheers,
Curtis "Ovid" Poe

=====
"Ovid" on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A

__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to