scalar to list conversion

2003-06-28 Thread Ling F. Zhang
say I have a string scalar $s
I would like to convert it @s in such a way that qw
would do it...
i.e.
if $s = rabbit hole\t goes\tall the way\n
then
@s = (rabbit,hole,goes,all,the,way\n)

notice that I preserved the \n at the end, but I
would settle for a solution that doesn't preserve
it...thanx


__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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



Re: scalar to list conversion

2003-06-28 Thread John W. Krahn
Ling F. Zhang wrote:
 
 say I have a string scalar $s
 I would like to convert it @s in such a way that qw
 would do it...
 i.e.
 if $s = rabbit hole\t goes\tall the way\n
 then
 @s = (rabbit,hole,goes,all,the,way\n)

@s = split ' ', $s;


 notice that I preserved the \n at the end, but I
 would settle for a solution that doesn't preserve
 it...thanx

If you want the same behaviour as qw() then the newline will be removed,
however you can append it later.

$s[ -1 ] .= \n;



John
-- 
use Perl;
program
fulfillment

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



Re: scalar to list conversion

2003-06-28 Thread Shlomi Fish
On Sat, 28 Jun 2003, Ling F. Zhang wrote:

 say I have a string scalar $s
 I would like to convert it @s in such a way that qw
 would do it...
 i.e.
 if $s = rabbit hole\t goes\tall the way\n
 then
 @s = (rabbit,hole,goes,all,the,way\n)


@s = (split /\t/, $s);

Hope it helps.

Regards,

Shlomi Fish

 notice that I preserved the \n at the end, but I
 would settle for a solution that doesn't preserve
 it...thanx


 __
 Do you Yahoo!?
 SBC Yahoo! DSL - Now only $29.95 per month!
 http://sbc.yahoo.com





--
Shlomi Fish[EMAIL PROTECTED]
Home Page: http://t2.technion.ac.il/~shlomif/

An apple a day will keep a doctor away. Two apples a day will keep two
doctors away.

Falk Fish

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



Re: scalar to list conversion

2003-06-28 Thread Rob Dixon
John W. Krahn wrote:
 Ling F. Zhang wrote:
 
  say I have a string scalar $s
  I would like to convert it @s in such a way that qw
  would do it...
  i.e.
  if $s = rabbit hole\t goes\tall the way\n
  then
  @s = (rabbit,hole,goes,all,the,way\n)

 @s = split ' ', $s;

  @s = split for $s

:)

Rob




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



Re: scalar to list conversion

2003-06-28 Thread Steve Grazzini
On Sat, Jun 28, 2003 at 11:04:33AM +0100, Rob Dixon wrote:
 John W. Krahn wrote:
 
  @s = split ' ', $s;
 
   @s = split for $s

(*s,*_) = \($_,@s);

split;

-- 
Steve

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



Re: scalar to list conversion

2003-06-28 Thread Steve Grazzini
On Sat, Jun 28, 2003 at 06:38:34AM -0400, Steve Grazzini wrote:
 On Sat, Jun 28, 2003 at 11:04:33AM +0100, Rob Dixon wrote:
  John W. Krahn wrote:
  
   @s = split ' ', $s;
  
@s = split for $s

Erm, never mind my last post. :-)

  *_ = *s; split;

-- 
Steve

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