[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] grepps script...



Stevie Strickland wrote:
> 
> On Sat, Jul 31, 1999 at 09:01:20PM -0400, Prakash Kailasa wrote:
>
> [..deleted..]
>
> > Make the last line:
> >   $/ = "\n"; print grep /$ARGV[0]/ && !/\s*(?:$$|$kpid)/, <PS_X>;
> 
> [..deleted..]
>
> However, I have to ask, why did you set the input record separator in
> the first half?  Isn't it newline by default?  I haven't changed it
> anywhere in the script, so I fail to see why that assignment was made.
> Am I missing something here?
> 
> Thanks,
> Stevie

Its completely superfluous there, as I see it now. You are not missing
anything. It was I who wasn't thinking straight.

I was thinking about the way arrays are printed when I wrote the above.

	@a = qw(one two); print @a, "\n"; print "@a\n";

	==>
	onetwo
	one two

When an array is interpolated withing a string, it is printed as if
'join'ed
by a space. I don't know why but somehow I thought by setting $/ to
"\n",
the array returned by grep would be printed on separate lines.

I was at home when I replied to your message, and it was a Windoze
system
I was using (it figures that I was dozing then :-). May be I should
sanitize it by at least installing perl on that machine.

/prakash

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe