----- Original Message -----
From: "Harry Putnam" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 17, 2003 1:35 AM
Subject: Re: Capture a printing function into an array
> Mark G <[EMAIL PROTECTED]> writes:
>
> > I am a newbie as well but this line makes no sence to me why do you have
> > ($line = $line) ???
> >> ($line = $line) =~ s/[Dd]estination/Dst/g;
>
> It began life as:
> $line =~ s/[Dd]estination/Dst/g;
> Which is sufficient, but in the course of doggedly changing around
> all kinds of stuff as errors occured, it ended up in that unecessary
> condition. This is not a finished product.
I hear that.
> > Here you dont need to quote your variables
> > printf " %s %s %-28s %s\n", <$.>, $2, $4, $6;
> >
> > BTW why are you doing <$.> ??
>
> Is there something wrong with printing the line number?
Nothing @all. you dont need to do <$.>, $. is fine by it self so can scrap
that to
printf " %s %s %-28s %s\n", $., $2, $4, $6;
> >> if ($opt_l){
> >> @c = sprintf(my_func());
> > sprintf will return a scalar, if you want an array you need to split
> > @c = split "",sprintf(my_func());
>
> Good to know (about the scalar/array)but it does nothing for the
> stated problem. That is, capturing the output rather than printing to
> stdout. Your split doesn't do it either.
Ahh my fault, its getting a bit late must have misread something. printf
will default to STDOUT, you can change that by specifieng a filehnadle as
first argument to printf or usign the 2 arg verssion of select. In either
case that wont help { or atleast will make it a mess } your problem. I think
the simplest thing to do is to replace your printf with sprintf in your
function, like this:
sub my_func{
...
return sprintf " %s %s %-28s %s\n", $., $2, $4, $6;
}
and then you can assign to array:
@c = split "", my_func();
hTh,
Mark G
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]