please dont rip this site

Perl Function

split(delimeter, string);

Note that the delimeter is used as a part of a regular expression that splits the string. It is NOT a simple string. So if you try to split a file name at the period with split(".",$filename) you will get nothing. Useing split("\.", $filename) also doesn't work, be cause that just passes the "." to the regexp. You need to use split("\\.", $filename) so that split get a first parameter of "\." which perl apparently turns into a regexp of "m/\./".

For even more fun, try splitting $path = "C:\\perl\\bin" on the "\": split("\\", $path) just generates a lovely "Trailing \ in regex m/\/" error message. The secret? Two pair. split("\\\\",$path) works just great. Split actually gets "\\" which gets turned into "m/\\/" which then splits on "\".

If you try to just supply the string and not the delimiter, it takes the string from $_. i.o.w. delimeter is not optional

See also: http://www.perldoc.com/perl5.6.1/pod/func/split.html

Questions:


file: /Techref/language/perl/split.htm, 2KB, , updated: 2008/4/17 12:48, local time: 2024/11/24 16:47,
TOP NEW HELP FIND: 
18.221.192.248:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/techref/language/perl/split.htm"> Perl Command split(delimeter, string)</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .