Tad said:
I suspect that what you need done is a great deal different
from the subject of this thread.
IMO it is not, but I'm sorry that you disagree. The OP wanted a script
for splitting long files, and did I.
The OP has markers only at the beginning of records, you have
them at the beginning and at the end.
True, but that is not relevant, because I don't need to split my file
at the top and bottom of each PHP file... I only need to split it at
the top *or* bottom of each PHP file (because the one's bottom is also
the next one's top, if you see what I mean).
The OP's markers are variable length, yours are fixed strings.
I would have thought that a procedure fixed stings would be easier and
simpler to implement that that of variable length. I would have
thought that some of the characters in the search string are regex code
for "variable things", which one could simply remove to be left with
that which refers to a fixed string. At least, this is what the regex
find functions of other languages that I have dealt with, does.
The OP's output filenames are derived from what is matched, you
haven't indicated any way of naming the files.
That is true, but I think I would have realised it and probably have
included the equivalent of a for-next loop (and on how to do that, I
would probably have searched various Perl forums for existing answers
to similar questions asked by equally clueless people). Alternatively,
I may have written a script in a different languge (say, AutoIt) which
creates unique names for each PHP file... although to do that, I would
have to know how to call the name in the Perl script's find function.
It answers the underlying unspoken question quite well.
You appear to want to write code in a language that you do not know.
Yes.
The implication is that you want us to write your code for you.
No. I did not ask for a completely new script. I asked for help with
the regex only. The script was already in existence, and it required
very, very little adaptation... so very little in fact that I might
have been able to figure it out myself if I had the missing
information.
(most especially since you have asked us to write code for you before.)
I do ask for scripts to be written, yes. If you enjoy writing simple
scripts to solve problems that haven't been solved before, you're
welcome to respond. If you do not, then feel free not to respond. I'm
not asking because I believe I have the right to expect to be helped.
I'm asking simply on the off-chance that someone might want to help (or
point me into some direction).
That is absurd.
If you do not know a language, you go learn the language.
I do not agree. Sorry, but my purpose is not to learn a single
language, but to discover a solution to my problem using whatever means
is available. If it's a Perl script, then good. If it's Java, Python,
Ruby, AutoIt, VB macro, StarBasic, Tcl, Yabasic, etc... then also good.
I have limited knowledge of some of these languages, and if I see
something which I *think* I understand partially, I'll fiddle with it.
But I won't read the whole manual, and I won't try to learn everything
there is about the language.
What you're saying, has some merit, though. Not knowing the entire
language can be extremely limiting in that you won't be able to solve
problems when they arise, except "blindly". In the above case, I had
believed that my only obstacle to success was the regex line of code.
Before your post, much of the responses I've had to my query had been
utterly unuseful (but I have no right to complain or blame). Your
answer about iterations was very useful because it shows me an
additional error in my thinking and it made me learn more about Perl
(though not enough to write programs, heh-heh).
You can learn about the syntax for the m// operator and for
Perl's regular expression in the documentation that came with perl.
Thanks... now at least I know what to look for.
Since you have a question about pattern matching, you would
eventually try:
perldoc -q pattern
Thanks. So it's called "pattern matching"...
Anyway, here is a short and complete program that *you* can run.
Thanks.
You have already used up all of your coupons.
Thanks. I'll ask for free scripts again, though. Does that offend
you? The OP's request didn't seem to, and unlike myself he didn't even
bother to try anything before asking on the forum (but maybe he's a
regular here).
I don't post free script requests and then just sit back and wait for
the free stuff to roll on in. I post, yes, and then I continue in my
search elsewhere for other possible solutions to my problem. And when
I have found a solution, I tell those in my group about it so that they
too can use it when they encounter that problem in future. I'm sorry
if this offends you.
Samuel Murray (aka voetleuce, leuce, throw)