in reply to Howto separate one file into three and refer to each of these three chuncks later on
There is, of course, More Than One Way To Do This.
You could localize $/ to your section separator. This may cause trouble if your file is really big, as could your technique of un-defining $/.
Or your could read the file line-by-line, switching output files as required (I would probably do this; my preference is usually in the realm of Brute Force & Ignorance).
Or you could correct your various spelling errors, like $chunck1 for what (probably) should be $chunk1. Note, too, that when you split with capturing parentheses, as you did, the separators are included in the list split returns. I would probably write your split somewhat differently:
There's a couple of reasons for this. First, when I see variable names like /\$chunkΎ-9]+$/, I immediately think "this should be an array." Secondly, typing sectionname thrice, as opposed to once, adds several opportunities for typographical errors (like omitting one of the n's in sectionname), and involves typing a dozen or extra characters, and, finally, what happens when you decided to chop the file into four, five, or 137 pieces?my @chunks = split(/^\!(sectionname[1-9][0-9]*)$/m, <>);
emc
Any New York City or Connecticut area jobs? I'm currently unemployed.
There are some enterprises in which a careful disorderliness is the true method.
|
|---|