As the example given illustrates split is *more general* than just in database usage, or manipulation based on a single character (though these are probably two of the most common uses)....
split can be used on ANY string, and may use ANY regular expression to "split on" no matter where you are getting your string, so from a database, a file (as in the example), a socket, etc. http://danconia.org dan wrote: > split is a command to read files from made up databases.. for example, your > database file reads: > > data1|data2|data3|data4 > > and you want to read from the database, "data2". to do this, you must open > the file, read it to an array (or string if you know it's only going to be 1 > line, but array's recommended for reading files, especially databases), > chomp it (remove /n), and split it up.. like this: > > open(INF,"database.file") or die "Unable to open database.file: $!"; > @database = <INF>; > close(INF); > foreach $entry (@database) { > chomp($entry); > ($var1,$var2,$var3,$var4) = split(/\|/,$entry); > } > > after this code is executed, $var1 becomes "data1", $var2 becomes "data2" > and so on.. > > dan > > "Teresa Raymond" <[EMAIL PROTECTED]> wrote in message > news:p05100300b930547b0793@[67.37.228.239]... > >>Split takes a text delimited file like: >> >>data1|data2|data3|data4 >> >>and splits on the delimiter (in this case the pipe character). I'm >>not sure how it works with a database but assume it's similar. >> >> >>>Can someone explain to me what the purpose of split is? I am assuming >> > you > >>>can take like a text file or something and separate it out? >>> >>>Thanks >>>Mike >>> >>> >>> >>>-- >>>To unsubscribe, e-mail: [EMAIL PROTECTED] >>>For additional commands, e-mail: [EMAIL PROTECTED] >> >> >>-- >>------------------------------- >>- Teresa Raymond - >>- Mariposa Net - >>- http://www.mariposanet.com - >>------------------------------- > > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
