
Perl's split function takes a string of text, and divides it up at a delimiter of your choice into a list of shorter strings ... it's one of the "power tool" functions of Perl and a vital part of the language. So how come that you can write a Tcl program and use its version of split - or omit the split command - and it seems to work either way. Does that seem odd
In Tcl, the split function also turns a string into a list ... it's just that a Tcl list is a string that's formatted with an unprotected space between each list element, which is probably where you started from the in the first place. In other words, the reason you can often include or leave out the call is because in Tcl's case it often does nothing at all!!
Python has two split methods - one that uses an explicit string as the delimiter on which it's to split, and the other in its regular expression class that makes it much more closely akin to the Perl flavour, and in PHP the split function splits at a literal string (you should use preg_split or explode in PHP to split at a regular expression).
Do you ever wonder why I only teach one language per day?
(written 2005-10-13, updated 2011-03-01)
Associated topics are indexed under
H107 - String Handling in PHP [3534] Learning to program in PHP - Regular Expression and Associative Array examples - (2011-12-01)
[3516] Regular Expression modifiers in PHP - summary table - (2011-11-12)
[3515] PHP - moving from ereg to preg for regular expressions - (2011-11-11)
[3424] Divide 10000 by 17. Do you get 588.235294117647, 588.24 or 588? - Ruby and PHP - (2011-09-08)
[3020] Handling (expanding) tabs in PHP - (2010-10-29)
[2629] Curly braces within double quoted strings in PHP - (2010-02-09)
[2238] Handling nasty characters - Perl, PHP, Python, Tcl, Lua - (2009-06-14)
[2165] Making Regular Expressions easy to read and maintain - (2009-05-10)
[2046] Finding variations on a surname - (2009-02-17)
[1799] Regular Expressions in PHP - (2008-09-16)
[1613] Regular expression for 6 digits OR 25 digits - (2008-04-16)
[1603] Do not SHOUT and do not whisper - (2008-04-06)
[1533] Short and sweet and sticky - PHP form input - (2008-02-06)
[1372] A taster PHP expression ... - (2007-09-30)
[1336] Ignore case in Regular Expression - (2007-09-08)
[1195] Regular Express Primer - (2007-05-20)
[1058] PHP Regular expression to extrtact link and text - (2007-01-31)
[1008] Date conversion - PHP - (2006-12-26)
[728] Looking ahead and behind in a Regular Expression - (2006-05-22)
[716] Evaluating arithmetic expressions in configuration files - (2006-05-10)
[642] How similar are two words - (2006-03-11)
[608] Don't expose your regular expressions - (2006-02-15)
[589] Robust PHP user inputs - (2006-02-03)
[574] PHP - dividing a string up into pieces - (2006-01-23)
[560] The fencepost problem - (2006-01-10)
[558] Converting between acres and hectares - (2006-01-08)
[493] Running a Perl script within a PHP page - (2005-11-12)
[422] PHP Magic Quotes - (2005-08-22)
[337] the array returned by preg_match_all - (2005-06-06)
[54] PHP and natural sorting - (2004-09-19)
[31] Here documents - (2004-08-28)
P208 - Perl - Lists [3548] Dark mornings, dog update, and Python and Lua courses before Christmas - (2011-12-10)
[3400] $ is atomic and % and @ are molecular - Perl - (2011-08-20)
[2996] Copying - duplicating data, or just adding a name? Perl and Python compared - (2010-10-12)
[2833] Fresh Perl Teaching Examples - part 2 of 3 - (2010-06-27)
[2813] Iterating over a Perl list and changing all items - (2010-06-15)
[2484] Finding text and what surrounds it - contextual grep - (2009-10-30)
[2295] The dog is not in trouble - (2009-07-17)
[2226] Revision / Summary of lists - Perl - (2009-06-10)
[2067] Perl - lists do so much more than arrays - (2009-03-05)
[1918] Perl Socket Programming Examples - (2008-12-02)
[1917] Out of memory during array extend - Perl - (2008-12-02)
[1828] Perl - map to process every member of a list (array) - (2008-10-09)
[1703] Perl ... adding to a list - end, middle, start - (2008-07-09)
[1316] Filtering and altering Perl lists with grep and map - (2007-08-23)
[1304] Last elements in a Perl or Python list - (2007-08-16)
[968] Perl - a list or a hash? - (2006-12-06)
[928] C++ and Perl - why did they do it THAT way? - (2006-11-16)
[773] Breaking bread - (2006-06-22)
[762] Huge data files - what happened earlier? - (2006-06-15)
[622] Queues and barrel rolls in Perl - (2006-02-24)
[355] Context in Perl - (2005-06-22)
[240] Conventional restraints removed - (2005-03-09)
[230] Course sizes - beware of marketing statistics - (2005-02-27)
[140] Comparison Chart for Perl programmers - list functions - (2004-12-04)
[28] Perl for breakfast - (2004-08-25)
T206 - Tcl/Tk - Lists [3583] Expanding a list of parameters in Tcl - {*} and eval - (2012-01-17)
[3582] Tcl collections - lists, dicts and array - (2012-01-16)
[3415] User defined sorting and other uses of callbacks in Tcl and Tk - (2011-09-02)
[3394] The difference between lists and strings - Tcl - (2011-08-16)
[3285] Extracting data from a string / line from file - Tcl - (2011-05-10)
[2472] split and join in tcl and expect - (2009-10-23)
[2468] What are Tcl lists? - (2009-10-22)
[1601] Replacing the last comma with an and - (2008-04-04)
[1405] Sorting in Tcl - lists and arrays - (2007-10-24)
[1402] Tcl - append v lappend v concat - (2007-10-23)
[1334] Stable sorting - Tcl, Perl and others - (2007-09-06)
[1283] Generating traffic for network testing - (2007-07-29)
[1282] Stringing together Tcl scripts - (2007-07-29)
[781] Tcl - lappend v concat - (2006-06-27)
[144] Tcl sandwich - lists in Tcl - (2004-12-08)
Y108 - Python - String Handling [3469] Teaching dilemma - old tricks and techniques, or recent enhancements? - (2011-10-08)
[3468] Python string formatting - the move from % to str.format - (2011-10-08)
[3349] Formatting output in Python through str.format - (2011-07-07)
[3218] Matching a license plate or product code - Regular Expressions - (2011-03-28)
[3090] Matching to a string - what if it matches in many possible ways? - (2010-12-17)
[2814] Python - splitting and joining strings - (2010-06-16)
[2780] Formatted Printing in Python - (2010-05-25)
[2765] Running operating system commands from your Python program - (2010-05-14)
[2721] Regular Expressions in Python - (2010-04-14)
[2692] Flexible search and replace in Python - (2010-03-25)
[2406] Pound Sign in Python Program - (2009-09-15)
[2284] Strings as collections in Python - (2009-07-12)
[1876] Python Regular Expressions - (2008-11-08)
[1608] Underlining in Perl and Python - the x and * operator in use - (2008-04-12)
[1517] Python - formatting objects - (2008-01-24)
[1110] Python - two different splits - (2007-03-15)
[970] String duplication - x in Perl, * in Python and Ruby - (2006-12-07)
[954] Splitting Pythons in Bradford - (2006-11-29)
[943] Matching within multiline strings, and ignoring case in regular expressions - (2006-11-25)
[903] Pieces of Python - (2006-10-23)
[496] Python printf - (2005-11-15)
[324] The backtick operator in Python and Perl - (2005-05-25)
Y115 - Additional Python Facilities [3442] A demonstration of how many Python facilities work together - (2011-09-16)
[3089] Python regular expressions - repeating, splitting, lookahead and lookbehind - (2010-12-17)
[2790] Joining a MySQL table from within a Python program - (2010-06-02)
[2786] Factory methods and SqLite in use in a Python teaching example - (2010-05-29)
[2764] Python decorators - your own, staticmethod and classmethod - (2010-05-14)
[2746] Model - View - Controller demo, Sqlite - Python 3 - Qt4 - (2010-04-29)
[2745] Connecting Python to sqlite and MySQL databases - (2010-04-28)
[2655] Python - what is going on around me? - (2010-02-28)
[2462] Python - how it saves on compile time - (2009-10-20)
[2435] Serialization - storing and reloading objects - (2009-10-04)
[2407] Testing code in Python - doctest, unittest and others - (2009-09-16)
[1337] A series of tyre damages - (2007-09-08)
[1305] Regular expressions made easy - building from components - (2007-08-16)
[1149] Turning objects into something you can store - Pickling (Python) - (2007-04-15)
[1136] Buffering output - why it is done and issues raised in Tcl, Perl, Python and PHP - (2007-04-06)
[1043] Sending an email from Python - (2007-01-18)
[901] Python - listing out the contents of all variables - (2006-10-21)
[753] Python 3000 - the next generation - (2006-06-09)
[672] Keeping your regular expressions simple - (2006-04-05)
[663] Python to MySQL - (2006-03-31)
[239] What and why for the epoch - (2005-03-08)
[208] Examples - Gadfly, NI Number, and Tcl to C interface - (2005-02-10)
[183] The elegance of Python - (2005-01-19)
Some other Articles
Tell them three timesSeparating 'per instance' data from binaries and web sitesChanging Tomcat's web.xml and reloading a web applicationTechnical LonelinessSplitting the differenceBig numberShortened interactive commandsNew NetworkKiss and RideFinal courses of '05 coming up ....