"Kristin A. I." wrote:
> 
> I am trying to indent a scroll-thru menu which has been made
> into a tree using the following database query:
>   select dept_id, LPAD(' ',2*(Level-1))||dept_name dept_name
>   from depts
>   start with dept_id = 1
>   connect by dept_parent = PRIOR dept_id;
> My problem is that the query uses spaces to indent the list,
> and spaces seem to be automatically removed from the beginnings
> of items in scroll-thru menus.  To remedy this, I have decided
> to replace the spaces with underscores.  This is where I become
> confused.
> s/ /_/g replaces even spaces between words in the list;
> s/^(_*) /_/g would require multiple iterations to catch all the spaces...
> Is there a simple way to replace one thing with another in the
> amount in which the first thing appeared?  Ex.: 2 spaces becomes
> 2 underscores, 4 becomes 4, etc. Thank you for any help.


If this is for display in HTML then maybe you want   instead of _

$ perl -le'
$_ = "    one  two    three";
print;
s/^(\s+)/($a=$1)=~s|\s| |g;$a/e;
print;
'
    one  two    three
    one  two    three



John
-- 
use Perl;
program
fulfillment

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

Reply via email to