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:
Hi,James Newton replies: I don't see how you can seperate those even as a human. Do the "FIX" tags always have one digit past the decimal? Are the "#=" seperators always one digit followed by the equal sign?+
I need to separate tags that are all grouped together with no spacing in between eg,
2005-11-28 15:51:22: DEBUG: importFixPumpdata: 2005/11/18 00:06:46:187: FIXPump: Received data on connection {CLIENT} [8=FIX.4.29=024335=D50=DCN3230197=N57=RISKGATEWAY34=93849=CLIENTFUT_EXLINK56=EXLINK_CLIENT43=N52=20051118-05:06:46200=200512207=Japan40=255=TSE 01 0F2005Z11=fud630_20051118167=FUT54=159=044=138.0821=238=1560=20051118-05:06:461=ATOP1110=032]
In the [] there are a number of FIX tags, eg '8=FIX.4.2' and there are no spaces in between, so the next FIX tag immediately foloows the previous one, 8=FIX.4.29=02433 and so on. Any ideas on how I can separate them? I have tried a number of REGEX and using split.
PS They are all on the one line as well.
Many thanks
Giles
file: /Techref/language/perl/split.htm, 2KB, , updated: 2008/4/17 12:48, local time: 2024/11/8 14:48,
3.144.37.147:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©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? <A HREF="http://techref.massmind.org/techref/language/perl/split.htm"> Perl Command split(delimeter, string)</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to techref.massmind.org! |
.