CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
help with split

 



legobuff
Deleted

Oct 17, 2000, 10:53 PM

Post #1 of 4 (248 views)
help with split Can't Post

is there a better way to do this?

@split_arr = split(/\t/,$tab_delim_str);
$wanted_value = $split_arr[0];

thanks


dws
Deleted

Oct 18, 2000, 11:16 AM

Post #2 of 4 (248 views)
Re: help with split [In reply to] Can't Post

($wanted_value) = $tab_delim_str =~ s/^(.*?)\t/;


japhy
Enthusiast

Oct 18, 2000, 11:33 AM

Post #3 of 4 (248 views)
Re: help with split [In reply to] Can't Post

You could do this:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


($wanted) = split /\t/, $string;
</pre><HR></BLOCKQUOTE>

Perl will translate that to:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


($wanted) = split /\t/, $string, 2;
</pre><HR></BLOCKQUOTE>

Which means you'll only split once (not at EACH \t), and so you'll be saved some time.

------------------
Jeff "japhy" Pinyan -- accomplished author, consultant, hacker, and teacher



vpopper
Deleted

Oct 24, 2000, 3:11 PM

Post #4 of 4 (248 views)
Re: help with split [In reply to] Can't Post

Or, you could do this:

$wanted = (split /\t/,$tab_delim_str)[0];



 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives