I am using clojure in Emacs with cider and the cider repl (0.7.0). This is pretty fine, but whenever I run cider-referesh (or hit C-c C-x), I get an exception:
ClassNotFoundException clojure.tools.namespace.repl java.net.URLClassLoader$1.run (URLClassLoader.java:372)
1. Unhandled java.lang.ClassNotFoundException
clojure.tools.namespace.repl
URLClassLoader.java: 372 java.net.URLClassLoader$1/run
URLClassLoader.java: 361 java.net.URLClassLoader$1/run
AccessController.java: -2 java.security.AccessController/doPrivileged
URLClassLoader.java: 360 java.net.URLClassLoader/findClass
DynamicClassLoader.java: 61 clojure.lang.DynamicClassLoader/findClass
ClassLoader.java: 424 java.lang.ClassLoader/loadClass
ClassLoader.java: 357 java.lang.ClassLoader/loadClass
Class.java: -2 java.lang.Class/forName0
Class.java: 340 java.lang.Class/forName
RT.java: 2065 clojure.lang.RT/classForName
Compiler.java: 978 clojure.lang.Compiler$HostExpr/maybeClass
Compiler.java: 756 clojure.lang.Compiler$HostExpr/access$400
Compiler.java: 6583 clojure.lang.Compiler/macroexpand1
Compiler.java: 6613 clojure.lang.Compiler/macroexpand
Compiler.java: 6687 clojure.lang.Compiler/eval
Compiler.java: 6666 clojure.lang.Compiler/eval
core.clj: 2927 clojure.core/eval
main.clj: 239 clojure.main/repl/read-eval-print/fn
main.clj: 239 clojure.main/repl/read-eval-print
main.clj: 257 clojure.main/repl/fn
main.clj: 257 clojure.main/repl
RestFn.java: 1096 clojure.lang.RestFn/invoke
interruptible_eval.clj: 56 clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 624 clojure.core/apply
core.clj: 1862 clojure.core/with-bindings*
RestFn.java: 425 clojure.lang.RestFn/invoke
interruptible_eval.clj: 41 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 171 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
core.clj: 2402 clojure.core/comp/fn
interruptible_eval.clj: 138 clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn
AFn.java: 22 clojure.lang.AFn/run
ThreadPoolExecutor.java: 1142 java.util.concurrent.ThreadPoolExecutor/runWorker
ThreadPoolExecutor.java: 617 java.util.concurrent.ThreadPoolExecutor$Worker/run
Thread.java: 745 java.lang.Thread/run
What is the reason for this, and how can I fix it?
It seems that this exception was a bug, that has now been fixed in cider.
Try adding [org.clojure/tools.namespace "0.2.5"] to your project.clj
Related
I have more than one image open, and I'd like to run scrip-fu functions on the currently selected image. How can I get the image reference number to the currently selected image so I can use the reference in other functions (e.g. (gimp-image-width 7))? I'm using GIMP 2.10.12.
Using (gimp-image-list) lists all the image references:
> (gimp-image-list)
(12 #(12 11 10 9 8 7 6 5 4 3 2 1))
I've been using (gimp-image-latest) for this, which should work for the general case
(define (gimp-image-list-items)
(cadr (gimp-image-list)))
(define (gimp-image-latest)
(aref (gimp-image-list-items) 0))
(define img (gimp-image-latest))
Then it's in img. E.g.:
> (gimp-image-get-layers img)
(283 #(770 769 768 767 766 765 764 763 762 761 760 759 758 757 756 755 754 753 752 751 750 749 748 747 746 745 744 743 742 741 740 739 738 737 736 735 734 733 732 731 730 729 728 727 726 725 724 723 722 721 720 719 718 717 716 715 714 713 712 711 710 709 708 707 706 705 704 703 702 701 700 699 698 697 696 695 694 693 692 691 690 689 688 687 686 685 684 683 682 681 680 679 678 677 676 675 674 673 672 671 670 669 668 667 666 665 664 663 662 661 660 659 658 657 656 655 654 653 652 651 650 649 648 647 646 645 644 643 642 641 640 639 638 637 636 635 634 633 632 631 630 629 628 627 626 625 624 623 622 621 620 619 618 617 616 615 614 613 612 611 610 609 608 607 606 605 604 603 602 601 600 599 598 597 596 595 594 593 592 591 590 589 588 587 586 585 584 583 582 581 580 579 578 577 576 575 574 573 572 571 570 569 568 567 566 565 564 563 562 561 560 559 558 557 556 555 554 553 552 551 550 549 548 547 546 545 544 543 542 541 540 539 538 537 536 535 534 533 532 531 530 529 528 527 526 525 524 523 522 521 520 519 518 517 516 515 514 513 512 511 510 509 508 507 506 505 504 503 502 501 500 499 498 497 496 495 494 493 492 491 490 489 488))
How to get to run a minimal Clojure app with boot-clj and Emacs?
I installed the Boot application and ran boot -h twice. Then I got this
s#Lux:~$ boot -V
#http://boot-clj.com
#Mon Feb 04 00:23:28 CET 2019
BOOT_CLOJURE_NAME=org.clojure/clojure
BOOT_CLOJURE_VERSION=1.8.0
BOOT_VERSION=2.8.2
s#Lux:~$
My Emacs is of the version as follows
GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
of 2017-09-15, modified by Debian
I installed cider, clojure-mode and projectile.
I configured Emacs with a tutorial of this https://github.com/boot-clj/boot/wiki/Cider-REPL#a-better-way
and got a configuration file:
s#Lux:~$ cat ~/.emacs.d/init.el
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(custom-set-variables
'(cider-boot-parameters (quote "cider repl -s wait"))
'(package-selected-packages (quote (projectile clojure-mode-extra-font-locking cider))))
s#Lux:~$
Then I typed out this
C-x C-f ~/Dropbox/Clojure/myapp2/src/myapp2/core.clj
and the file opened.
Here you are the file's code:
s#Lux:~$ cat ~/Dropbox/Clojure/myapp2/src/myapp2/core.clj
(ns myapp2.core
(:gen-class))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!"))
s#Lux:~$
The file is in a project generated by a boot-clj command boot -d boot/new new -t app -n myapp2
Then I typed out this M-x cider-jack-in and got an error:
line: 1
error in process sentinel: Could not start nREPL server: Classpath conflict: org.clojure/clojure version 1.8.0 already loaded, NOT loading version 1.10.0
Classpath conflict: org.clojure/clojure version 1.8.0 already loaded, NOT loading version 1.10.0
Classpath conflict: org.clojure/clojure version 1.8.0 already loaded, NOT loading version 1.10.0
java.lang.Thread.run Thread.java: 748
java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java: 624
java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java: 1149
java.util.concurrent.FutureTask.run FutureTask.java: 266
...
clojure.core/binding-conveyor-fn/fn core.clj: 1938
boot.core/boot/fn core.clj: 1032
boot.core/run-tasks core.clj: 1022
boot.task.built-in/fn/fn/fn/fn built_in.clj: 492
clojure.core/deref core.clj: 2228
...
boot.task.built-in/fn/fn/fn built_in.clj: 489
clojure.core/apply core.clj: 646
...
boot.core/launch-nrepl core.clj: 1313
boot.repl/launch-nrepl repl.clj: 60
boot.repl-server/start-server repl_server.clj: 68
boot.repl-server/->mw-list repl_server.clj: 59
...
clojure.core/mapcat core.clj: 2674 (repeats 2 times)
clojure.core/apply core.clj: 646
...
clojure.core/map/fn core.clj: 2644
boot.repl-server/->mw-list repl_server.clj: 55
boot.repl-server/->var repl_server.clj: 49
...
clojure.core/require core.clj: 5796 (repeats 2 times)
clojure.core/apply core.clj: 648
...
clojure.core/load-libs core.clj: 5758
clojure.core/load-libs core.clj: 5774
clojure.core/apply core.clj: 648
...
clojure.core/load-lib core.clj: 5717
clojure.core/load-lib core.clj: 5736
clojure.core/load-lib/fn core.clj: 5737
clojure.core/load-one core.clj: 5697
...
clojure.core/load core.clj: 5876
clojure.core/load core.clj: 5892
clojure.core/load/fn core.clj: 5893
...
refactor-nrepl.middleware/eval2021 middleware.clj: 1
refactor-nrepl.middleware/eval2021/loading--auto-- middleware.clj: 1
...
clojure.core/require core.clj: 5796 (repeats 2 times)
clojure.core/apply core.clj: 648
...
clojure.core/load-libs core.clj: 5758
clojure.core/load-libs core.clj: 5774
clojure.core/apply core.clj: 648
...
clojure.core/load-lib core.clj: 5717
clojure.core/load-lib core.clj: 5736
clojure.core/load-lib/fn core.clj: 5737
clojure.core/load-one core.clj: 5697
...
clojure.core/load core.clj: 5876
clojure.core/load core.clj: 5892
clojure.core/load/fn core.clj: 5893
...
refactor-nrepl.ns.resolve-missing/eval14613 resolve_missing.clj: 1
refactor-nrepl.ns.resolve-missing/eval14613/loading--auto-- resolve_missing.clj: 1
...
clojure.core/require core.clj: 5796 (repeats 2 times)
clojure.core/apply core.clj: 648
...
clojure.core/load-libs core.clj: 5758
clojure.core/load-libs core.clj: 5774
clojure.core/apply core.clj: 648
...
clojure.core/load-lib core.clj: 5717
clojure.core/load-lib core.clj: 5755
clojure.core/apply core.clj: 648
...
clojure.core/refer core.clj: 4087
clojure.core/refer core.clj: 4119
java.lang.IllegalAccessError: info-clj does not exist
clojure.lang.ExceptionInfo: info-clj does not exist
line: 1
But when I removed the
'(cider-boot-parameters (quote "cider repl -s wait"))
line from the configuration, restarted Emacs, run cider-jack-in, cider started successfully. So I could run Clojure commands such as (range 5) etc.
But when I tried to run the application and put out (-main) it crashed and an info that an error took place and the main symbol could not be resolved:
user> (-main)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: -main in this context, compiling:(*cider-repl Clojure/myapp2:localhost:45545(clj)*:43:7)
user>
Show: Project-Only All
Hide: Clojure Java REPL Tooling Duplicates (24 frames hidden)
2. Unhandled clojure.lang.Compiler$CompilerException
Error compiling *cider-repl Clojure/myapp2:localhost:45545(clj)* at (43:7)
Compiler.java: 6688 clojure.lang.Compiler/analyze
Compiler.java: 6625 clojure.lang.Compiler/analyze
Compiler.java: 3766 clojure.lang.Compiler$InvokeExpr/parse
Compiler.java: 6870 clojure.lang.Compiler/analyzeSeq
Compiler.java: 6669 clojure.lang.Compiler/analyze
Compiler.java: 6625 clojure.lang.Compiler/analyze
Compiler.java: 6001 clojure.lang.Compiler$BodyExpr$Parser/parse
Compiler.java: 5380 clojure.lang.Compiler$FnMethod/parse
Compiler.java: 3972 clojure.lang.Compiler$FnExpr/parse
Compiler.java: 6866 clojure.lang.Compiler/analyzeSeq
Compiler.java: 6669 clojure.lang.Compiler/analyze
Compiler.java: 6924 clojure.lang.Compiler/eval
Compiler.java: 6890 clojure.lang.Compiler/eval
core.clj: 3105 clojure.core/eval
core.clj: 3101 clojure.core/eval
main.clj: 240 clojure.main/repl/read-eval-print/fn
main.clj: 240 clojure.main/repl/read-eval-print
main.clj: 258 clojure.main/repl/fn
main.clj: 258 clojure.main/repl
main.clj: 174 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 83 nrepl.middleware.interruptible-eval/evaluate/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 646 clojure.core/apply
core.clj: 1881 clojure.core/with-bindings*
core.clj: 1881 clojure.core/with-bindings*
RestFn.java: 425 clojure.lang.RestFn/invoke
interruptible_eval.clj: 81 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 50 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 221 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
interruptible_eval.clj: 189 nrepl.middleware.interruptible-eval/run-next/fn
AFn.java: 22 clojure.lang.AFn/run
ThreadPoolExecutor.java: 1149 java.util.concurrent.ThreadPoolExecutor/runWorker
ThreadPoolExecutor.java: 624 java.util.concurrent.ThreadPoolExecutor$Worker/run
Thread.java: 748 java.lang.Thread/run
1. Caused by java.lang.RuntimeException
Unable to resolve symbol: -main in this context
Util.java: 221 clojure.lang.Util/runtimeException
Compiler.java: 7164 clojure.lang.Compiler/resolveIn
Compiler.java: 7108 clojure.lang.Compiler/resolve
Compiler.java: 7069 clojure.lang.Compiler/analyzeSymbol
Compiler.java: 6648 clojure.lang.Compiler/analyze
Compiler.java: 6625 clojure.lang.Compiler/analyze
Compiler.java: 3766 clojure.lang.Compiler$InvokeExpr/parse
Compiler.java: 6870 clojure.lang.Compiler/analyzeSeq
Compiler.java: 6669 clojure.lang.Compiler/analyze
Compiler.java: 6625 clojure.lang.Compiler/analyze
Compiler.java: 6001 clojure.lang.Compiler$BodyExpr$Parser/parse
Compiler.java: 5380 clojure.lang.Compiler$FnMethod/parse
Compiler.java: 3972 clojure.lang.Compiler$FnExpr/parse
Compiler.java: 6866 clojure.lang.Compiler/analyzeSeq
Compiler.java: 6669 clojure.lang.Compiler/analyze
Compiler.java: 6924 clojure.lang.Compiler/eval
Compiler.java: 6890 clojure.lang.Compiler/eval
core.clj: 3105 clojure.core/eval
core.clj: 3101 clojure.core/eval
main.clj: 240 clojure.main/repl/read-eval-print/fn
main.clj: 240 clojure.main/repl/read-eval-print
main.clj: 258 clojure.main/repl/fn
main.clj: 258 clojure.main/repl
main.clj: 174 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 83 nrepl.middleware.interruptible-eval/evaluate/fn
AFn.java: 152 clojure.lang.AFn/applyToHelper
AFn.java: 144 clojure.lang.AFn/applyTo
core.clj: 646 clojure.core/apply
core.clj: 1881 clojure.core/with-bindings*
core.clj: 1881 clojure.core/with-bindings*
RestFn.java: 425 clojure.lang.RestFn/invoke
interruptible_eval.clj: 81 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 50 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 221 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
interruptible_eval.clj: 189 nrepl.middleware.interruptible-eval/run-next/fn
AFn.java: 22 clojure.lang.AFn/run
ThreadPoolExecutor.java: 1149 java.util.concurrent.ThreadPoolExecutor/runWorker
ThreadPoolExecutor.java: 624 java.util.concurrent.ThreadPoolExecutor$Worker/run
Thread.java: 748 java.lang.Thread/ Show: Project-Only All
So it looks like cider cannot find the -main function. Perhaps I should type cider-jack-in command in another place? But where? And the cider-boot-parameters issue is also strange. How to run any Clojure application with boot-clj and emacs-25. (The problem occurred also at emacs26 and emacs27).
I reinstalled Debian, installed boot and emacs25.
Then created a configuration file:
s#Windown:~/Dropbox/Clojure/myapp2$ cat ~/.emacs.d/init.el
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(cider-boot-parameters (quote "repl -s wait"))
'(package-selected-packages
(quote
(clojure-mode projectile clojure-mode-extra-font-locking cider))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
s#Windown:~/Dropbox/Clojure/myapp2$
Then installed cider, clojure-mode and projectile. Then it worked.
Version Info
s#Windown:~/Downloads2$ boot -V
#http://boot-clj.com
#Mon Feb 04 13:34:49 CET 2019
BOOT_CLOJURE_NAME=org.clojure/clojure
BOOT_CLOJURE_VERSION=1.8.0
BOOT_VERSION=2.8.2
s#Windown:~/Downloads2$
This is GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
of 2017-09-15, modified by Debian
Emacs Package Library
projectile 20190126.1117 installed Manage and navigate projects in Emacs easily
clojure-mode 20190105.1043 installed Major mode for Clojure code
cider 20190125.1339 installed Clojure Interactive Development Environment that Rocks
I have a MATLAB polygon (below) which self intersects to make the zero volume part (which I will call a sliver) in the image (also below).
I am having a lot of trouble finding and removing the zero volume sliver.
Hope anyone can help. Thanks.
IMAGE:
enter image description here
Polygon:
newBoundary =
1 1
1 216
8 221
25 239
46 255
60 269
70 282
81 296
92 313
113 323
127 326
145 336
163 349
170 368
174 374
192 388
209 400
229 416
236 433
252 450
266 470
268 488
274 504
284 523
274 518
249 513
246 532
246 538
224 527
216 541
206 554
205 573
192 589
185 590
169 609
148 620
154 641
170 646
172 660
165 683
154 673
140 654
130 648
116 656
105 660
92 679
82 700
69 719
90 730
77 751
87 770
66 763
48 774
37 791
28 804
18 804
9 817
1 834
1 838
1 1049
131 1049
141 1044
164 1029
181 1014
193 1004
208 995
221 979
239 979
239 962
253 951
270 940
290 926
299 908
317 899
332 879
353 869
364 857
379 841
376 856
386 870
383 889
380 913
382 933
383 958
378 975
379 993
378 1016
374 1029
367 1040
366 1049
616 1049
615 1049
610 1037
615 1016
612 993
618 978
612 953
609 936
606 913
608 894
609 874
606 854
622 839
633 853
651 869
670 883
690 900
706 916
721 934
740 951
747 971
765 978
785 992
795 1007
816 1015
831 1028
848 1049
1049 1049
1049 781
1027 784
1003 780
997 798
974 812
973 796
964 780
947 765
930 773
922 760
926 736
917 722
898 713
879 719
883 704
886 679
873 663
853 670
847 649
841 627
839 607
835 621
814 631
794 620
778 604
761 588
744 601
729 592
716 577
705 556
698 537
689 517
698 502
711 486
726 486
730 463
743 446
760 439
764 420
784 404
802 388
816 373
837 366
846 344
866 337
881 324
901 314
912 299
926 283
946 272
951 253
970 242
977 225
998 223
1006 207
1025 192
1049 186
1049 1
789 1
792 6
778 20
774 37
762 49
753 70
736 79
715 90
695 100
672 91
668 109
663 131
668 153
651 156
657 168
648 170
633 153
612 150
613 127
610 114
613 97
615 74
613 54
612 36
613 21
620 1
380 1
379 9
377 34
371 56
379 78
387 98
379 117
376 136
384 151
372 156
350 164
332 174
318 168
327 150
309 139
299 129
281 127
290 108
275 107
261 90
236 76
235 60
219 52
206 35
187 22
168 4
156 1
1 1
Zero volume slivers may occur when there are three or more consecutive points aligned. In this particular case those were:
366 1049
616 1049
615 1049
since they fall on the same horizontal line.
If you want to automate this, you should check every group of three consecutive points to see if they fall on the same line. If they do, you need to discard the one in the middle, according to appearance order.
In this particular case, the one in the middle is:
616 1049
I am conducting Spearman's Correlation with two data sets with 300 objects. These are my variables and commands:
a = [1:300]
b = [1 2 5 11 9 7 24 10 31 23 3 40 6 17 14 20 16 12 33 46 70 37 87 43 98 26 59 58 77 100 35 42 78 80 243 36 33327 4 83 160 163 198 86 94 406 111 28 29 55 113 239 295 110 196 177 32679 229 342 305 300 254 96 210 514 167 172 232 190 117 32081 25 158 19333 241 82 149 159 66 178 24487 68 30 1016 725 266 391 638 348 320 681 242 319 228 381 408 442 202 369 471 821 191 426 8 270 211 2266 619 576 441 680 3431 1167 723 74 318 556 640 395 1059 579 614 212 325 437 323 687 373 599 26637 985 54 84 802 724 154 417 240 1120 818 2309 462 109 104 509 494 427 57 2475 549 396 419 123 580 79 225 1132 351 76 16859 596 862 315 470 992 257 120 409 751 832 285 1534 714 1665 1376 2129 678 416 721 209 31971 183 356 1346 1015 1003 188 1076 1634 608 1056 338 308 145 418 625 1313 121 2484 996 783 329 1185 697 157 1100 175 622 235 456 277 166 2700 1439 461 653 433 540 1191 234 774 1894 1004 741 1062 948 48 99 405 797 237 1104 2286 22620 1429 30672 1808 169 458 22 1115 10660 872 474 1063 88 1727 1017 1107 1398 1519 703 1092 1027 272 263 1152 1770 1099 507 385 2118 19356 1778 2458 410 2110 7522 17166 4065 15136 13294 10876 17174 2434 9898 5663 13594 10506 11552 15635 9322 3223 8949 12388 13216 13851 13852 6696 12177 4700 17199 2067 11110 15486 5664 6593 4701 527 8616 268]
[RHO,PVAL] = corr(b',a','Type', 'Spearman')
RHO =
0.6954
PVAL =
0
Out of the 5 comparisons I made with other data sets of 300 objects, only 1 returned significant P-values. Is there an explanation for this?
I tried a different data set and got a value that was not significant (PVAL > 0.05). I also displayed the answer in a long (15 digits) and exponential form and got 0.00000000000000e+000 using:
format longEng
I also checked with another statistics program that reported the p-value as < 0.0001. This means that the p-value is just really, really small.
I have a huge 1.1 GB File. It contains only 1 line and 1167889705 characters. I want to replace all the occurences of "LFENT" by "\nLFENT".
I am using
perl 5, version 18, subversion 1 (v5.18.1) built for x86_64-linux –
Perl Script
perl -ne 's/LFENT/\nLFENT/g; print;' queries.txt
Sample
22 serialization::archive 10 0 0 0 0 134477 0 0 0 9 LFENT_1_1 6 LFDOC1 20 documents/LFDOC1.xml 6 PERSON 12 barack obama 0 0 1 0 12 barack obama 0 0 6 LFDOC1 0 76 127 0.11599133 151 0.11042373 331 0.057491675 389 0.05621225 396 0.065223008 398 0.12416559 421 0.10331947 502 0.055213902 641 0.08908961 642 0.084330745 690 0.11456303 699 0.16876614 720 0.080576144 791 0.077269703 792 0.077503696 849 0.08224529 854 0.074629158 1028 0.11078026 1039 0.091981322 1300 0.070129424 1359 0.06072164 1390 0.05564769 1424 0.076605573 1461 0.15357952 1467 0.083702087 1583 0.069745384 1960 0.088143557 2118 0.064093992 2192 0.054430917 2304 0.089718938 2417 0.10173298 2436 0.069064997 2683 0.12296619 2700 0.068218805 2715 0.14005794 2786 0.084942013 3016 0.08474879 3113 0.083180025 3183 0.07413847 3202 0.081254445 3351 0.21241546 3587 0.061469007 3711 0.068944298 3949 0.10349752 5284 0.087500088 5775 0.092185706 5816 0.20625457 6320 0.11784423 6435 0.076852165 6794 0.094336778 6805 0.063363358 6946 0.11133534 7277 0.074097082 7588 0.12458359 7590 0.099151991 7629 0.28773388 7790 0.1194713 8137 0.11009126 8214 0.10754209 8889 0.12056628 9326 0.13841057 9701 0.25610805 9863 0.11877144 9908 0.11499001 10500 0.12205271 11917 0.11144774 12750 0.11285295 13453 0.13751692 19236 0.12948024 20390 0.12416928 20795 0.11188922 23777 0.13165452 23887 0.10065161 27644 0.1620737 73361 0.16295943 75521 0.17926371 9 LFENT_1_2 6 LFDOC1 20 documents/LFDOC1.xml 6 PERSON 5 obama 2 0 12 barack obama 5 obama 6 LFDOC1 0 76 127 0.11599133 151 0.11042373 331 0.057491675 389 0.05621225 396 0.065223008 398 0.12416559 421 0.10331947 502 0.055213902 641 0.08908961 642 0.084330745 690 0.11456303 699 0.16876614 720 0.080576144 791 0.077269703 792 0.077503696 849 0.08224529 854 0.074629158 1028 0.11078026 1039 0.091981322 1300 0.070129424 1359 0.06072164 1390 0.05564769 1424 0.076605573 1461 0.15357952 1467 0.083702087 1583 0.069745384 1960 0.088143557 2118 0.064093992 2192 0.054430917 2304 0.089718938 2417 0.10173298 2436 0.069064997 2683 0.12296619 2700 0.068218805 2715 0.14005794 2786 0.084942013 3016 0.08474879 3113 0.083180025 3183 0.07413847 3202 0.081254445 3351 0.21241546 3587 0.061469007 3711 0.068944298 3949 0.10349752 5284 0.087500088 5775 0.092185706 5816 0.20625457 6320 0.11784423 6435 0.076852165 6794 0.094336778 6805 0.063363358 6946 0.11133534 7277 0.074097082 7588 0.12458359 7590 0.099151991 7629 0.28773388 7790 0.1194713 8137 0.11009126 8214 0.10754209 8889 0.12056628 9326 0.13841057 9701 0.25610805 9863 0.11877144 9908 0.11499001 10500 0.12205271 11917 0.11144774 12750 0.11285295 13453 0.13751692 19236 0.12948024 20390 0.12416928 20795 0.11188922 23777 0.13165452 23887 0.10065161 27644 0.1620737 73361 0.16295943 75521 0.17926371 9 LFENT_1_3 6 LFDOC1 20 documents/LFDOC1.xml 4 MISC 8 american 1 0 8 american 6 LFDOC1 0 76 127 0.11599133 151 0.11042373 331 0.057491675 389 0.05621225 396 0.065223008 398 0.12416559 421 0.10331947 502 0.055213902 641 0.08908961 642 0.084330745 690 0.11456303 699 0.16876614 720 0.080576144 791 0.077269703 792 0.077503696 849 0.08224529 854 0.074629158 1028 0.11078026 1039 0.091981322 1300 0.070129424 1359 0.06072164 1390 0.05564769 1424 0.076605573 1461 0.15357952 1467 0.083702087 1583 0.069745384 1960 0.088143557 2118 0.064093992 2192 0.054430917 2304 0.089718938 2417 0.10173298 2436 0.069064997 2683 0.12296619 2700 0.068218805 2715 0.14005794 2786 0.084942013 3016 0.08474879 3113 0.083180025 3183 0.07413847 3202 0.081254445 3351 0.21241546 3587 0.061469007 3711 0.068944298 3949 0.10349752 5284 0.087500088 5775 0.092185706 5816 0.20625457 6320 0.11784423 6435 0.076852165 6794 0.094336778 6805 0.063363358 6946 0.11133534 7277 0.074097082 7588 0.12458359 7590 0.099151991 7629 0.28773388 7790 0.1194713 8137 0.11009126 8214 0.10754209 8889 0.12056628 9326 0.13841057 9701 0.25610805 9863 0.11877144 9908 0.11499001 10500 0.12205271 11917 0.11144774 12750 0.11285295 13453 0.13751692 19236
Problem
The script will work on the sample that I posted. But when I try it on the whole line I get the following error:
Substitution loop at -e line 1, <> line 1.
It is simplest to use LFENT as the record separator. That reduces the blocks to a more manageable size and ensures that there is no more than one LFENT to be replaced in each block
Command-line perl allows for setting the record separator with the -0 modifier, but the value of the parameter must be the code point in octal of a single character, and you can't specify a string. So here you have to set it once in a BEGIN block
Like this
perl -p -e'BEGIN{$/="LFENT"} s/LFENT/\nLFENT/'
output
22 serialization::archive 10 0 0 0 0 134477 0 0 0 9
LFENT_1_1 6 LFDOC1 20 documents/LFDOC1.xml 6 PERSON 12 barack obama 0 0 1 0 12 barack obama 0 0 6 LFDOC1 0 76 127 0.11599133 151 0.11042373 331 0.057491675 389 0.05621225 396 0.065223008 398 0.12416559 421 0.10331947 502 0.055213902 641 0.08908961 642 0.084330745 690 0.11456303 699 0.16876614 720 0.080576144 791 0.077269703 792 0.077503696 849 0.08224529 854 0.074629158 1028 0.11078026 1039 0.091981322 1300 0.070129424 1359 0.06072164 1390 0.05564769 1424 0.076605573 1461 0.15357952 1467 0.083702087 1583 0.069745384 1960 0.088143557 2118 0.064093992 2192 0.054430917 2304 0.089718938 2417 0.10173298 2436 0.069064997 2683 0.12296619 2700 0.068218805 2715 0.14005794 2786 0.084942013 3016 0.08474879 3113 0.083180025 3183 0.07413847 3202 0.081254445 3351 0.21241546 3587 0.061469007 3711 0.068944298 3949 0.10349752 5284 0.087500088 5775 0.092185706 5816 0.20625457 6320 0.11784423 6435 0.076852165 6794 0.094336778 6805 0.063363358 6946 0.11133534 7277 0.074097082 7588 0.12458359 7590 0.099151991 7629 0.28773388 7790 0.1194713 8137 0.11009126 8214 0.10754209 8889 0.12056628 9326 0.13841057 9701 0.25610805 9863 0.11877144 9908 0.11499001 10500 0.12205271 11917 0.11144774 12750 0.11285295 13453 0.13751692 19236 0.12948024 20390 0.12416928 20795 0.11188922 23777 0.13165452 23887 0.10065161 27644 0.1620737 73361 0.16295943 75521 0.17926371 9
LFENT_1_2 6 LFDOC1 20 documents/LFDOC1.xml 6 PERSON 5 obama 2 0 12 barack obama 5 obama 6 LFDOC1 0 76 127 0.11599133 151 0.11042373 331 0.057491675 389 0.05621225 396 0.065223008 398 0.12416559 421 0.10331947 502 0.055213902 641 0.08908961 642 0.084330745 690 0.11456303 699 0.16876614 720 0.080576144 791 0.077269703 792 0.077503696 849 0.08224529 854 0.074629158 1028 0.11078026 1039 0.091981322 1300 0.070129424 1359 0.06072164 1390 0.05564769 1424 0.076605573 1461 0.15357952 1467 0.083702087 1583 0.069745384 1960 0.088143557 2118 0.064093992 2192 0.054430917 2304 0.089718938 2417 0.10173298 2436 0.069064997 2683 0.12296619 2700 0.068218805 2715 0.14005794 2786 0.084942013 3016 0.08474879 3113 0.083180025 3183 0.07413847 3202 0.081254445 3351 0.21241546 3587 0.061469007 3711 0.068944298 3949 0.10349752 5284 0.087500088 5775 0.092185706 5816 0.20625457 6320 0.11784423 6435 0.076852165 6794 0.094336778 6805 0.063363358 6946 0.11133534 7277 0.074097082 7588 0.12458359 7590 0.099151991 7629 0.28773388 7790 0.1194713 8137 0.11009126 8214 0.10754209 8889 0.12056628 9326 0.13841057 9701 0.25610805 9863 0.11877144 9908 0.11499001 10500 0.12205271 11917 0.11144774 12750 0.11285295 13453 0.13751692 19236 0.12948024 20390 0.12416928 20795 0.11188922 23777 0.13165452 23887 0.10065161 27644 0.1620737 73361 0.16295943 75521 0.17926371 9
LFENT_1_3 6 LFDOC1 20 documents/LFDOC1.xml 4 MISC 8 american 1 0 8 american 6 LFDOC1 0 76 127 0.11599133 151 0.11042373 331 0.057491675 389 0.05621225 396 0.065223008 398 0.12416559 421 0.10331947 502 0.055213902 641 0.08908961 642 0.084330745 690 0.11456303 699 0.16876614 720 0.080576144 791 0.077269703 792 0.077503696 849 0.08224529 854 0.074629158 1028 0.11078026 1039 0.091981322 1300 0.070129424 1359 0.06072164 1390 0.05564769 1424 0.076605573 1461 0.15357952 1467 0.083702087 1583 0.069745384 1960 0.088143557 2118 0.064093992 2192 0.054430917 2304 0.089718938 2417 0.10173298 2436 0.069064997 2683 0.12296619 2700 0.068218805 2715 0.14005794 2786 0.084942013 3016 0.08474879 3113 0.083180025 3183 0.07413847 3202 0.081254445 3351 0.21241546 3587 0.061469007 3711 0.068944298 3949 0.10349752 5284 0.087500088 5775 0.092185706 5816 0.20625457 6320 0.11784423 6435 0.076852165 6794 0.094336778 6805 0.063363358 6946 0.11133534 7277 0.074097082 7588 0.12458359 7590 0.099151991 7629 0.28773388 7790 0.1194713 8137 0.11009126 8214 0.10754209 8889 0.12056628 9326 0.13841057 9701 0.25610805 9863 0.11877144 9908 0.11499001 10500 0.12205271 11917 0.11144774 12750 0.11285295 13453 0.13751692 19236[Finished in 0.2s]
By the way, it is unlikely to cause a problem but LFENT is always preceded by a space character in your example data. You may want to remove it by using s/\s*LFENT/\nLFENT for your substitution
And a look-ahead might be more appropriate too s/\s*(?=LFENT)/\n/ so that you don't have to remove and replace the unchanged part of the match
Try updating your perl to a more current version.
This was a known bug for a long time (fixed in v5.22.0): perl #123071: substitution loop issue with long strings
You can do so with the following commands (assuming you are on linux):
wget http://www.cpan.org/src/5.0/perl-5.22.1.tar.gz
tar -xzf perl-5.22.1.tar.gz
cd perl-5.22.1
./Configure -des -Dprefix=$HOME/localperl
make
make test
make install
Then test it by running $HOME/localperl/bin/perl -v and add it to your PATH using this: export PATH=$HOME/localperl/bin/:$PATH.