Re: Split with backslashes?

2005-10-06 Thread rnmscott
Quoting Jeff 'japhy' Pinyan [EMAIL PROTECTED]:

 O
my @dirs = split /\//, $cd;  # splitting on forward slashes
my @dirs = split '/', $cd;   # same thing, less ugly
 
 

Nice tip Jeff, thanks! :)



This email was sent from Netspace Webmail: http://www.netspace.net.au


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Split with backslashes?

2005-10-05 Thread Muthukumar
my $cd = $arguments;
@dirs = split(/\//,$cd); #Split $cd when there occurs a backslash
 Negate with \
 hth.

 On 10/5/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Hi there!

 I would like to split up a string like this

 my $cd = $arguments;
 @dirs = split(///,$cd); #Split $cd when there occurs a backslash

 but it doesn't seem to work. I guess /// must be rewritten in some way,
 but how?

 /G



 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response





Re: Split with backslashes?

2005-10-05 Thread Jeff 'japhy' Pinyan

On Oct 5, [EMAIL PROTECTED] said:


I would like to split up a string like this

my $cd = $arguments;
@dirs = split(///,$cd); #Split $cd when there occurs a backslash

but it doesn't seem to work. I guess /// must be rewritten in some way,
but how?


'/' is a FORWARD slash.  '\' is a BACK slash.  Here are two solutions to 
your problem:


  my @dirs = split /\//, $cd;  # splitting on forward slashes
  my @dirs = split '/', $cd;   # same thing, less ugly

--
Jeff japhy Pinyan%  How can we ever be the sold short or
RPI Acacia Brother #734%  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %-- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response