forked from snoopyjc/pythonizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_guide.html
623 lines (621 loc) · 164 KB
/
user_guide.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
<html>
<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" />
<base href="https://www.softpanorama.org/Scripting/Pythonorama/Python_for_perl_programmers/Pythonizer/user_guide.shtml" target="_blank" />
<title>Pythonizer user guide</title>
<style type="text/css">body {Background-color: #FFFFFF link: #0000CC vlink: #660066}
h1 { font-family: arial; text-align: Center; color: #CC0000 }
h2 { font-family: arial; text-align: Center; color: #0000CC }
h3 { font-family: arial; text-align: Center }
h4 { font-family: Arial; color: #006400}
h5 { font-family: Arial; color: #333300; font-style: italic}
h6 { font-family: Arial; font-size: 10pt; font-style: bold}
em { font-style: italic; font-weight: bold; color: #FF0000}
cite { font-style: italic; font-weight: bold; color: blue }
a {color: #0000FF;}
td {font-family:arial,helvetica,sans-serif; font-size:10pt;}
p.petit { font-family: arial; font-size: smaller }
table.swb {Background-color: cyan}
td.swb { border-right-style: solid; border-bottom-style: solid }
table.nb {Background-color: #ffffcc}
tr.nb { text-align: Center; font-weight: bold }
td.nb { border-style: solid }
kbd {font-family: Fixedsys; font-size: 12pt; color: #0000FF;}
tt {font-family: Fixedsys; font-size: 12pt; color: #0000FF;}
code {font-family: Fixedsys; font-size: 12pt; color: #0000FF;}
pre {font-family: Fixedsys; color: #0000FF; font-size: 12pt; margin: 1em 40px; }
pre.code {font-family: Fixedsys; color: #0000FF; margin: 1em 40px;}
blockquote {font-size: 10pt; font-family: arial; background: #F9F9F9}
</style>
<script>
document.addEventListener('DOMContentLoaded', function(){
var es = document.getElementsByTagName('a')
for(var i=0; i<es.length; i++){
var attr = es[i].getAttribute('href');
if(attr.substr(0,1) == '#') {
es[i].addEventListener('click', function(e) {
e.preventDefault()
document.location.hash = e.target.getAttribute('href')
})
}
}
})
</script>
</head>
<body>
<p></p>
<h1 style="font-family: arial; text-align: center; color: #cc0000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Pythonizer user guide</h1>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Version 1.030 (Mar 27, 2023)</h3>
<table style="font-family: 'Times New Roman'; letter-spacing: normal; orphans: 2; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;" border="1" width="100%" bgcolor="#FFFFCC">
<tbody>
<tr>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center" width="14%"><a style="color: #0000ff;" href="#News">News</a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center" width="14%"> <a style="color: #0000ff;" href="../index.shtml">Python for Perl programmers</a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center" width="14%">
<p align="center"><strong><a style="color: #0000ff;" href="../Bookshelf/Computers/python.shtml">Best Python books for system administrators</a></strong></p>
</td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center" width="14%"><a style="color: #0000ff;" href="#Recommended_Links">Recommended Links</a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center" width="14%"><strong><a style="color: #0000ff;" href="../Pl2py_reference/pl2py_functions_map.shtml">Perl to Python functions map</a></strong></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center" width="15%"><strong><a style="color: #0000ff;" href="../Py_shell_commands_execution/index.shtml">Execution of commands and shell scripts using subprocess module</a></strong></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center" width="15%"><strong><a style="color: #0000ff;" href="protocol_of_translation_of_pre_pythonizer.shtml">Full protocol of translation of pre_pythonizer.pl by the current version of Pythonizer</a></strong></td>
</tr>
</tbody>
</table>
<ul style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<li><strong><a style="color: #0000ff;" href="#Introduction">Introduction</a></strong></li>
<li><strong><a style="color: #0000ff;" href="#Pre-pythonizer__implements_the_first_phase_of_translation">(Deprecated) Pre-pythonizer implements the first phase of translation</a></strong></li>
<li><strong><a style="color: #0000ff;" href="#Pythonizer_implements_actual_transformation_of_Perl_into_Python">Pythonizer implements actual transformation of Perl into Python</a></strong>
<ul>
<li><strong><a style="color: #0000ff;" href="#Options">Options</a></strong></li>
<li><strong><a style="color: #0000ff;" href="#Built_In_Packages">Built-In Packages</a></strong></li>
<li><strong><a style="color: #0000ff;" href="#Logs">Logs</a></strong></li>
<li><strong><a style="color: #0000ff;" href="#Structure">Structure</a></strong></li>
<li><strong><a style="color: #0000ff;" href="#Installation">Installation</a></strong></li>
<li><strong><a style="color: #0000ff;" href="#Invocation">Invocation</a></strong></li>
<li><strong><a style="color: #0000ff;" href="#History">History</a></strong></li>
<li><strong><a style="color: #0000ff;" href="#Known_errors">Known errors</a></strong></li>
<li><strong><a style="color: #0000ff;" href="#Troubleshooting">Troubleshooting</a></strong></li>
<li><strong><a style="color: #0000ff;" href="#Submission_of_tickets">Submission of tickets</a></strong></li>
</ul>
</li>
<li><strong><a style="color: #0000ff;" href="#Recommended_manual_transformations_of_Perl_code">Recommended manual transformations of Perl code</a></strong>
<ul>
<li><a style="color: #0000ff;" href="#Decision_to_remove_round_brackets">Decision to remove opening and closing round brackets in Perl built-in function opened a can of worms</a></li>
<li><a style="color: #0000ff;" href="#Other_recommended_transformation_of_Perl_code">Other recommended transformations of Perl code</a></li>
</ul>
</li>
<li><strong><a style="color: #0000ff;" href="#Debugging_generated_Python_code">Debugging generated Python code</a></strong></li>
</ul>
<hr style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;" noshade="noshade" size="7" width="33%" />
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Introduction"></a>Introduction</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Pythonizer is a professional tool designed to facilitate the process of converting Perl code to Python. It is particularly useful for organizations looking to modernize their codebase, as well as for individuals seeking to maintain existing Perl scripts without prior knowledge of the language.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Pythonizer is also an excellent resource for system administrators looking to learn Python, as it demonstrates the compatibility between the two languages and allows for the translation of programs with minimal effort.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Overall, Pythonizer is a reliable and efficient solution for those looking to bridge the gap between Perl and Python.</p>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Installation"></a>Installation</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">For installation, the main program <span style="color: #0000ff;">pythonizer</span> and all the perl modules (*.pm) should reside in a single directory from which you can run the program. </p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">You need to download files or replicate the directory via git . Let's assume that you downloaded or replicated them into <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">/home/softpano/Pythonizer</tt></p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Then you invoke the program directly:</p>
<pre style="font-family: Fixedsys; color: #0000ff; font-size: medium; margin: 1em 40px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">~/Pythonizer/pythonizer script_to_be_tranlated.pl</pre>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">In order to specify <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">pythonizer</tt> without path you need to add the directory in which you installed it to the <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">PATH </tt>or copy the program to one of the directories already in <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">PATH</tt>, for example<tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;"> /use/local/bin i</tt>f you are root<tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;"> or ~/bin </tt>if you are a regular user<tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">.</tt></p>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Invocation"></a>Invocation</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">You can run Pythonizer in git bash, cygwin, and Linux.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The simplest invocation can look like: <span style="font-size: medium;"> </span></p>
<pre style="font-family: Fixedsys; color: #0000ff; font-size: medium; margin: 1em 40px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">/opt/Pythonizer/pythonizer /path/to/your/program/script_to_be_translated.pl</pre>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">If the program runs to the end you will get "pythonized" text in <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">/path/to/your/program.py</tt></p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">It also optionally produces protocol of translation in <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">/tmp/Pythonizer</tt> with size by side Perl and Python code, which allows you to analyses the protocol detect places that need to be commented out translated manually.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">If <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;"> __DATA__</tt> or <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">__END__</tt> are used a separate file with the extension <strong>.data </strong> (<tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">/path/to/your/program.data </tt>for the example above) will be created with the content on this section of Perl script.</p>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Pythonizer_implements_actual_transformation_of_Perl_into_Python"></a>Pythonizer implements actual transformation of Perl into Python</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Running <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">pythonizer -h</tt> provides a list of options.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Here is example of the protocol <a style="color: #0000ff;" href="protocol_of_translation_of_pre_pythonizer020.shtml" target="_blank" rel="noopener">Full protocol of translation of pre_pythonizer.pl by version 0.953 of pythonizer</a></p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><strong>Some features:</strong></p>
<ul style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<li>The Pythonizer is implemented in Perl 5.10+ and does not use any non standard Perl libraries.</li>
<li>Converts most of Perl 5 code Python. That includes loops, special variables, function calls, lists, hashes, etc.</li>
<li>Recognizes many Perl idioms and special cases. Perform limited peephole optimization of Perl within individual statements in case this is possible (for example use of replace function instead or regular expression in case both the source and target are plain strings. it also optimizes some types of split function when the regex supplied to Perl actually is a string and does not contain any metacharacters.</li>
<li>Whenever there is no equivalent Python function for a Perl function, or the corresponding Python function raises exceptions, the function is emulated using a simple library function. The code for these library functions can be generated inline or using an <span style="color: #0000ff;">import perllib</span>. More information can be found in the <span style="text-decoration: underline;"><a href="https://perllib.readthedocs.io/en/latest/">documentaton for perllib</a></span>.</li>
<li>Perl special variables are renamed to selected Python names and used consistently. (Not all of them are supported, however.)</li>
<li>Most double quoted literals with scalars inside list elements and hash elements and ‘here-documents’ are supported using Python <span style="color: #0000ff;">f"strings"</span>. Most common special variable are also translated to their equivalents in double quoted operators.</li>
<li>Arguments to Perl subroutines generate native python argument lists, with <span style="color: #0000ff;">*args</span> used in the subroutine definitions.</li>
<li>In case of Perl control constructs that are missing in Python (for example
<p><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">(debug>0) && say $line</tt>;</p>
<p>or</p>
<p><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">open(SYSIN,'<',',$mytext) || die("Can't open the file $mytest\n");<span lang="ru">)</span></tt></p>
<p>they are translated into equivalent Python constructs.</p>
</li>
<li>Tail data after <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">__DATA__</tt> or <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">__END__ </tt> are converted to a separate file with the same name as the script and<tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;"> </tt>the extensio<tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">n .data</tt></li>
<li>List of statements for which pythonizer encountered difficulties and most probably did not translate correctly are produced at the end.</li>
<li>Summary of diagnostic statements is produced at the end.</li>
</ul>
<h4 style="font-family: Arial; color: #006400; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Limitations"></a>Limitations</h4>
<ul style="font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<li style="color: #000000; font-weight: 400;">Block scoped variables (defined with <span style="color: #0000ff;">my</span>) are extended to be subroutine scoped, which is what is available in Python. Normally you shouldn't notice the difference. They are, however, properly implemented in <span style="color: #0000ff;">for</span>(<span style="color: #0000ff;">each</span>) loops.</li>
<li style="color: #000000; font-weight: 400;">Perl <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">tie </tt>statements are only handled for arrays, hashes, and scalars. Scalars in <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">tie </tt>statements cannot be declared as <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">my </tt>, except if they are declared as <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">my </tt>on the <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">tie </tt>statement itself, that will be ignored.</li>
<li style="color: #000000; font-weight: 400;">The <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">use</tt> and <span style="color: #0000ff;">require </span>statements will attempt correct translation, including recursively calling the pythonizer to translate the module <span style="color: #0000ff;">use</span>d<span style="color: #0000ff;">/require</span>d. This works well on local modules, but not well on standard packages. Some packages are built-in to Pythonizer though, like Carp, IO::File, and several others.</li>
<li style="color: #000000; font-weight: 400;">The <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">do EXPR</tt> statement is implemented, but the result is always 1 on success and None on failure.</li>
<li style="color: #000000; font-weight: 400;">The contents of <span style="color: #0000ff;">BEGIN</span>, <span style="color: #0000ff;">END</span> blocks (and others similarly defined by the language) are translated correctly. Please note that these blocks are normally executed at the time of execution of Perl interpreter, not at the time of execution of the script, but we run the BEGIN blocks as soon as possible, and the END blocks via <span style="color: #0000ff;">atexit</span>, so Perl semantics are almost preserved. </li>
<li style="color: #000000; font-weight: 400;">Except in limited cases, references to scalar variables are usually not translated correctly. In many cases of usage of references in Perl this is very difficult to express in Python. Array, Hash, and Subroutine references are handled correctly. Typeglobs (like *VAR) are only partially implemented. Scalar variables cannot be modified by means of using <span style="color: #0000ff;">\</span> references to them. A special exception is made for subroutine arguments where scalar references are usually handled properly using a perllib routine that also handles out parameters. Pythonizer needs to be able to use static analysis to figure out which of the arguments are being modified in order for this to work properly. Things like conditionally <span style="color: blue">shift</span>ing the argument list can cause issues, but most cases do work properly.</li>
<li style="color: #000000; font-weight: 400;">Automatic <span style="color: blue">return</span> of the last expression defined may not always work. Pythonizer makes a very good attempt to insert an appropriate <span style="color: blue">return</span> statement, but not all cases can be handled. In the first pass, Pythonizer marks lines that may be potential return values, and in the second pass, it tries to insert a <span style="color: blue">return</span> statement. However, this may not always be successful in all cases. If you find a case it doesn't handle, then open an issue and an attempt will be made to come up with a fix for you.</li>
<li style="color: #000000; font-weight: 400;"><span style="color: #0000ff;">eval</span> with a "double quoted string" interpolated arguments are not and cannot be supported, except in the very limited case of eval "require ...";. In this case, a dynamic import is generated, but Pythonizer does not scan the imported module, so, for example, if the package name being imported clashes with a variable name, this may cause the generated code to be incorrect. A warning is produced in this case.</li>
<li style="color: #000000; font-weight: 400;"><span style="color: #0000ff;">goto</span> LABEL is not supported, unless the goto is at the statement level and the label is a forward declaration (the code is effectively commented out in this case).</li>
<li>Conditional <span style="color: #0000ff; font-weight: 400;">continue</span> statements inside <span style="color: #0000ff; font-weight: 400;">when</span> blocks are not supported. Similarly, conditional <span style="color: #0000ff; font-weight: 400;">next</span> statements inside <span style="color: #0000ff; font-weight: 400;">case</span> blocks are not supported.
<li>Experimental <span style="color: #0000ff; font-weight: 400;">for_list</span> feature and <span style="color: #0000ff; font-weight: 400;">try</span> blocks are not supported.</li>
<li>Most perl regular expression features are supported, except for the following: The \G regex assertion (match at pos), regex recursion (?R), regex subroutines (?1) or (?&name). Many common regex unicode properties are supported \p{prop}, however many are not supported. Same goes for \P{prop}. If \P{prop} is used in a [...] character class, it must be the first thing in the class.</li>
</ul>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Options"></a>Options</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><em style="font-style: italic; font-weight: bold; color: #ff0000;">NOTE: </em>All options with small numeric values can be expressed by repeating the letter, so<tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;"> -v2</tt> is equivalent to <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-vv.</tt> <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-d 3 -ddd</tt></p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Currently user options are supported (<tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">pythonizer -h</tt> provides a list of options): </p>
<ul style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<li><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-V</tt> -- <strong>version</strong> - print the version and exit</li>
<li><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-v</tt> -- <strong>verbosity</strong> <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-v0</tt> -minimal verbosity <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-v3</tt> -- max verbosity; can also be expressed as <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-v -vv</tt> and <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-vvv. <span style="color: #000000;">The default is -v1.</span></tt></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-k</span> -- <strong>black</strong> - run the Python Black code formatter (if it's available) on the generated python code (default)</span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-K</span> -- Turn off <span style="color: #0000ff;">-k</span></span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-l <span style="color: #000000;">-- the output line length - how many characters per line to generate by the Black code formatter (default 98)</span></span></span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-m</span> -- <strong>implicit global my</strong> - Make global variables into <span style="color: #0000ff;">my</span> filescope variables, else they use a separate global namespace.</span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-M</span> -- Turn off <span style="color: #0000ff;">-m</span> (<strong>NOTE:</strong> If neither <span style="color: #0000ff;">-m</span> nor <span style="color: #0000ff;">-M</span> are passed, the pythonizer uses heuristics to make a best guess here. See also <a style="color: #0000ff;" href="#pragma"><span style="color: #0000ff;"># pragma pythonizer</span></a>)</span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-u</span> -- <strong>replace usage - </strong>Replace strings of the form "Usage: filename.pl ..." in the generated Python code with "Usage: filename.py ...". Also replaces cases where "filename.pl" is the entire contents of a string. (default)</span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-U</span> -- Turn off <span style="color: #0000ff;">-u</span></span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-y </span></span>-- <strong>pl_to_py</strong> - Replace ".pl" references to perl scripts as the first path-like word of a string or in a backtick reference to refer to ".py" instead, changing calls to perl scripts to instead call the pythonized version. (default)</li>
<li><span style="color: #0000ff;">-Y</span> -- Turn off <span style="color: #0000ff;">-y</span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-s</span> -- <strong>pythonize standard library</strong> - Attempt to run standard library functions thru Pythonizer for <span style="color: #0000ff;">use</span>/<span style="color: #0000ff;">require</span> - this is not recommended as most of them use constructs (e.g. <span style="color: #0000ff;">bless </span>or dynamic <span style="color: #0000ff;">eval</span>) which are not currently supported by Pythonizer.</span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-S</span> -- Turn off <span style="color: #0000ff;">-s</span>. This is the default.</span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-p</span> -- <strong>import perllib</strong> library instead of including functions inline to emulate perl built-in functions. This is the default.</span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-P</span> -- Turn off <span style="color: #0000ff;">-p</span></span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-A</span> -- <strong>autodie - </strong>Imply <a href="https://perldoc.perl.org/autodie" target="_blank" rel="noopener"><span style="color: #0000ff;">use autodie qw(:all);</span></a> (<strong>NOTE</strong>: This can be enabled at runtime by setting <span style="color: #0000ff;">perllib.AUTODIE = 1</span> at the start of the program, or by setting the <span style="color: #0000ff;">PERLLIB_AUTODIE</span> environment variable to a non-zero value.)</span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-T</span> -- <strong>traceback</strong> - Perform a traceback in the generated code on errors. (<strong>NOTE</strong>: This can be enabled at runtime by setting <span style="color: #0000ff;">perllib.TRACEBACK = 1</span> at the start of the program, or by setting the <span style="color: #0000ff;">PERLLIB_TRACEBACK</span> environment variable to a non-zero value.)</span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-n</span> -- <strong>trace run</strong>: Generate code to trace subprocess.run results - used in qx, `backtick`, open('|'), and system(). (<strong>NOTE</strong>: This can be enabled at runtime by setting <span style="color: #0000ff;">perllib.TRACE_RUN = 1</span> at the start of the program, or by setting the <span style="color: #0000ff;">PERLLIB_TRACE_RUN</span> environment variable to a non-zero value.)</span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-o</span> -- <strong>output directory</strong> - Specify the output directory for .py and .data files, created if need be (specified as <span style="color: #0000ff;">-o</span><em>path</em> - defaults to the same location as the input file)</span></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-N</span> -- <strong>vivification</strong> - Imply <a href="https://metacpan.org/pod/autovivification" target="_blank" rel="noopener"><span style="color: #0000ff;">no autovivification qw(fetch delete exists store strict);</span></a></span></li>
<li><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-w</tt> -- <strong>width</strong> - the width of the screen on which you plan to view the protocol of translation (which is only generated if <span style="color: #0000ff;">-v3</span> is specified). The default is 188 which is good for 24" displays and <strong>Fixedsys 11</strong> font. Has no effect on the generated code.</li>
<li><span style="color: #0000ff;">-R</span> -- <strong>remap</strong> comma separated list of variables: variables specified as var or *var will map all variables named 'var', <br /> $var will just map scalar to var_v, @var will just map array to var_a, %var will just map hash to var_h,<br /> <span style="color: #0000ff;">:global</span> will remap all global vars (default), <span style="color: #0000ff;">:all</span> will remap all variables, <span style="color: #0000ff;">:none</span> will remap no variables. </li>
<li><span style="color: #0000ff;">-a</span> --<strong> author</strong> - Add __author__, __email__, and __version__ variables to the generated file. This help facilitate the addition of new automatically translated Perl packages to Python. The values for __author__ and __email__ are taken from the last line of AUTHORS.rst matching "* Name <email@address>". The __version__ is taken from the current Pythonizer version.</li>
<li><span style="color: #000000;"><span style="color: #0000ff;">-e</span> -- <strong>input_encoding,output_encoding</strong> -
Specify the encoding to use for the perl input file and the python output file
If this option is not specified, then Pythonzer attempts to discern the input encoding by looking for "use utf8;" in
the input file or a special coding comment like # -*- coding: latin1 -*-. If neither are found, Pythonizer effectively uses
<a href="https://metacpan.org/pod/Encoding::FixLatin" target="_blank">Encoding::FixLatin::fix_latin</a> to read the input if there are any non-ascii characters present, which does a pretty good job
of reading any encoding.<br>
If <span style="color: #0000ff;">-e</span> is specified, then the next argument is used to determine the input file encoding and the output file encoding.
If <span style="color: #0000ff;">-e</span> is specified and ",output_encoding" is not included, then the output encoding defaults to the same
as the input encoding. If input_encoding is not included (and you only include ",output_encoding", then
Pythonizer attempts to detect the input encoding as if <span style="color: #0000ff;">-e</span> was not specified, but with the specified output encoding.
If the input_encoding is specified and is followed by only a comma, then the output_encoding defaults to utf8.
<li><span style="color: #000000;"><span style="color: #0000ff;">-f </span></span>-- <strong>fully qualify calls</strong> - Fully qualify method calls. If not specified, and -M is specified or implied, then this is turned on</li>
<li><span style="color: #0000ff;">-F</span> -- Turn off <span style="color: #0000ff;">-f</span>. If not specified, and -m is specified or implied, then -f is turned off</li>
</li>
<li><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-t</tt> -- <strong>tab size</strong> for generated code; the default<tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;"> -t4</tt></li>
<li><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-r</tt> -- (deprecated) <strong>refactor Perl code</strong>. If specified, before processing the script by the pythonizer, it invokes the <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">pre_pythonizer</tt> preliminary pass on the source code. Of course this can be done manually with more control but this provides an integrated way to refactor the program.</li>
</ul>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><strong>Options mainly for developers</strong></p>
<ul style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<li><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-d</tt> -- <strong>debug option</strong> <em style="font-style: italic; font-weight: bold; color: #ff0000;">for developers</em>; The default is<tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;"> -d0;</tt></li>
<li><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-b</tt> -- <strong>breakpoint option</strong><em style="font-style: italic; font-weight: bold; color: #ff0000;"> for developers only</em>; stop execution in pass 2 at input statement on line <span style="color: #0000ff;">N</span> (specified as -<span style="color: #0000ff;">b<em>N</em></span>)</li>
<li><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-B</tt> -- <strong>breakpoint option</strong><em style="font-style: italic; font-weight: bold; color: #ff0000;"> for developers only</em>; stop execution in pass 1 at input statement on line <span style="color: #0000ff;">N </span>(specified as -<span style="color: #0000ff;">B<em>N</em></span>)</li>
</ul>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">On the Symantic Mismatch between Perl and Python</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">In many cases, perl code translates quite logically to python code. This section describes the cases where that is not true, and how Pythonizer handles them.</p>
<ol>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Global Variables and Packages: In perl, variables that are not declared as <span style="color: #0000ff;">my </span>are global variables. Their scope is of the package, though. If this is a self-contained perl script, there is no issue. However, if the script uses <span style="color: #0000ff;">require </span>to bring in other scripts, variables global to the initial script are visible to the other scripts, and vice-versa. In python, global variables have file scope, which means that they cannot be shared across multiple files. To solve this issue, Pythonizer creates a <span style="color: #0000ff;">SimpleNamespace</span> for each package, and stores all global variables there. These <span style="color: #0000ff;">SimpleNamespace</span>s are stored for safe keeping in the Python <span style="color: #0000ff;">builtins</span> module, which is available across file boundaries. Don't worry - only 1 is created per package, though, so there shouldn't be a ton of them. Here is where the <span style="color: #0000ff;">-M</span> and <span style="color: #0000ff;">-m</span> options come into play. <span style="color: #0000ff;">-m</span> stands for "implicit global my", which means to implicitly declare all global variables as if they had <span style="color: #0000ff;">my</span> in front of them. This better aligns with how global variables work in python and is safe to use for stand-alone Perl scripts. With <span style="color: #0000ff;">-M</span>, all references to a global variable <span style="color: #0000ff;"><em>var</em> </span>(not declared with <span style="color: #0000ff;">my</span>) will be replaced by <span style="color: #0000ff;">main.<em>var</em></span>, where <span style="color: #0000ff;">main</span> is the package name. If the options <span style="color: #0000ff;">-M</span> or <span style="color: #0000ff;">-m</span> are not used, Pythonizer runs a quick pass 0 over the source code using some heuristics to determine which of those options should be used. It tries to err on the <span style="color: #0000ff;">-M</span> side, as that code is always correct, but if you don't use <span style="color: #0000ff;">require</span>, and the file isn't just all initialization code or unreferenced functions, and especially if you use <span style="color: #0000ff;">GetOptions</span> or reference <span style="color: #0000ff;">ARGV</span>, or have unconditional <span style="color: #0000ff;">print </span>statements to <span style="color: #0000ff;">STDOUT</span>, it will assume <span style="color: #0000ff;">-m</span>, which makes the generated code more readable. Additionally, Pythonizer makes use of the<span style="color: #0000ff;"> := </span>(walrus) operator in Python for when variables are assigned in expressions. Unfortunately, Python severely restricts the value that can be used on the LHS of the walrus operator to a single unqualified name. This means that <span style="color: #0000ff;">(main.var<strong>:=</strong>...) </span>is a syntax error. To avoid this issue, Pythonizer uses a library function <span style="color: #0000ff;">perllib.assign_global('main', 'var', ...)</span> in these cases.</li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Autovivification: In Perl variables, including complex data structures, can be created out of whole cloth. For example <span style="color: #0000ff;">$myhash{key1}{key2} = [1, 2]; </span>creates a hash of hashes containing an array. <span style="color: #0000ff;">$myarr[2] = 4;</span> will create an array, initialize the first two elements to <span style="color: #0000ff;">undef</span>, and set the third element to 4. Pythonizer handles this using defined <span style="color: #0000ff;">Array</span> and <span style="color: #0000ff;">Hash</span> classes (which internally are actually the same class). Unless your code specifies <span style="color: #0000ff;">no autovivification;</span>, or the <span style="color: #0000ff;">-V</span> flag is passed to Pythonizer, all arrays and hashes are defined using these classes. If you create an array element or a hash value out of nothing, it becomes an <span style="color: #0000ff;">ArrayHash</span> object, as Pythonizer doesn't know if this value will become a scalar, an array, or a hash. This special object will convert to an empty string, will increment to 1, and will compare as equal to 0, equal to the empty string, equal to <span style="color: #0000ff;">undef</span>, or equal to an empty list (less than is implemented too so it can participate in a <span style="color: #0000ff;">sort </span>operation).</li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Block scoped variables: In Perl you can define a <span style="color: #0000ff;">my</span> variable in any { block } of code and that variable is only available in that block. Python has no such equivalent - variable scope extends to the entire subroutine (<span style="color: #0000ff;">def </span>in Python) where the variable is defined. Normally you shouldn't notice the difference.</li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Variable naming: By default <span style="color: #0000ff;">$name</span>, <span style="color: #0000ff;">@name</span>, <span style="color: #0000ff;">&name</span>, <span style="color: #0000ff;">*name</span>, and <span style="color: #0000ff;">name </span>(filehandle) are all translated to <span style="color: #0000ff;">name </span>in Python. Obviously, this will not work. Pythonizer detects if multiple Perl names map to the same Python name, and makes changes as follows: subroutine and filehandle names are not changed. If a scalar (<strong>$</strong>) variable name collides, it is mapped to <span style="color: #0000ff;">name_v</span>. If an array (<strong>@</strong>) variable name collides, it is mapped to <span style="color: #0000ff;">name_a<span style="color: #000000;">, while hash (<strong>%</strong>) variable names are mapped to</span> name_h</span>. The -R flag determines how this mapping is performed - normally all package-level global variables are mapped (<span style="color: #0000ff;">:global</span> option). This is most likely what you want. TypeGlobs are not fully handled, and are mapped based on how they are used. For example if the typeglob is referenced as a hash, the name <span style="color: #0000ff;">name_h</span> will be used, and a message will be generated at translation time with the details. Perl names that conflict with Python keywords or builtins such as <span style="color: #0000ff;">in</span> or <span style="color: #0000ff;">max</span> get mapped to<span style="color: #0000ff;"> in_</span> or <span style="color: #0000ff;">max_</span> appropriately. The default package in Perl is called <span style="color: #0000ff;">main</span>, so other references to <span style="color: #0000ff;">main </span>will be mapped to <span style="color: #0000ff;">main_</span>. Variables declared as <span style="color: #0000ff;">state</span> become file-scope global variables and their names are changes to <em><span style="color: #0000ff;">subname</span></em>_<em><span style="color: #0000ff;">varname</span></em>. Loop counter variables in <span style="color: #0000ff;">for</span>(<span style="color: #0000ff;">each</span>) loops when declared using <span style="color: #0000ff;">my</span> or in <span style="color: #0000ff;">foreach</span> style loops are mapped to <span style="color: #0000ff;">name_l</span> so they don't conflict with variables of the same name outside the loop. This is only done if the same named variable is defined outside of the loop.</li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Type conversion: In Perl, scalar variables have no types and they are converted dynamically on use. In Python, while types are not generally declared, scalars do have internal types and attempts to use a variable of the wrong type in an expression will raise an exception. This is handled by Pythonizer by using a simple string conversion function declared inline as <span style="color: #0000ff;">_str = lambda s: "" if s is None else str(s) </span>and more complex functions<span style="color: #0000ff;"> perllib.num </span>and<span style="color: #0000ff;"> perllib.int<span style="color: #000000;">, which convert to a number or an integer, respectfully (integer conversion is only used in subscripts). In the main scope (not so much in subroutines), Pythonizer attempts to infer varable types and eliminate calls to these conversion functions as much as possible.</span></span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #0000ff;"><span style="color: #000000;">Initialization: In Perl, variables do not have to be initialized and magically appear out of nowhere the first time they are referenced. In Python, referencing a non-initialized variable will raise an exception. Pythonizer handles this by initializing all variables, either when they are first declared (if they are declared) or at the start of the generated code otherwise. An attempt is made to initialize variables to an initial value of the proper type (see Type conversion above). Package scope global variables are initialized using <span style="color: #0000ff;">perllib.init_global</span>, which only initializes the variable if it is otherwise not initialized, as the initialization could actually be in a different source file. Variables declared as <span style="color: #0000ff;">state <span style="color: #000000;">and are initialized with constants</span> <span style="color: #000000;">are initialized just below the subroutine they are defined in. If they are initialized with variables or expressions, their initialization will occur where they are defined and will be protected by a boolean variable so they are only initialized once. In both cases, their names are changed as defined above in Variable naming.</span></span></span></span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Perl built-in and library functions: In Perl, built-in and library functions typically return 1 on success and undef or 0 on failure. In Python, the equivalent functions typically raise exceptions on error. In order to correct this semantic mismatch, many of the Perl functions are translated to calls to library functions that implement the Perl semantics. This library is called perllib, which comes with Pythonizer, but is also available via Pypi. Calls to the library functions can also be generated inline when the <span style="color: #0000ff;">-P</span> flag is used. Some pretty interesting code may be generated for functions that have multiple output values, such as open, opendir, read, RegEx matches, etc. In these cases, the library function returns a tuple of the output value and the result value and the generated code has to unpack it into 2 variables. Here is an example in Perl with the generated Python code:<br /> Perl: <span style="color: #0000ff;">read($fh, $buffer, 5) == 4</span><br /> Python: <span style="color: #0000ff;">((buffer:=(_s:=perllib.read(fh, buffer, 5, need_len=True))[0]), _s[1])[1] == 4</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The Perl open function can generate 2 different library calls depending on if the Pythonizer can figure out at translation time what the mode is. The simpler <span style="color: #0000ff;">perllib.open_</span> routine is called in that case. In the case where the mode is not specified or is specified in a variable, then the more complex <span style="color: #0000ff;">perllib.open_dynamic</span> function is used.</li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The whole concept of list context vs. scalar context and <span style="color: #0000ff;">wantarray</span> is foreign to Python. Pythonizer does a pretty good job at figuring out the context and generating the right code. Even the <span style="color: #0000ff;">wantarray</span> function is converted to a keyword argument in functions.</li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Perl supports references to scalar variables where you can then modify the scalar via the reference. In Python, only lists (arrays) and dicts (hashes) are handled as references (by default). There is no way to take a reference to a scalar variable and then modify the variable using it. Given Python's limitations, however, Pythonizer is still able to handle scalar references being passed to (like mysub(\$var)) and modified by subroutines (like $$var = ...) using the same perllib functions used to handle out parameters (see the next semantic mismatch).</li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Perl supports scalar out parameters in subroutines where a scalar is passed and the argument is changed in the subroutine, which changes the value of the corresponding scalar. Python does not support this. Pythonizer does the best job it can in emulating this functionality using perllib functions to store the output parameters inside the function body, then fetch them and assign them to the proper scalars in the caller. (Internally, perllib uses special attributes of the Python builtins module to store the values temporarily.)</li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Support for <span style="color: #0000ff;">use warnings;</span> is implemented, however specific warning types are not distinguished - warnings are either on or off, on a per-block basis. Warnings for uninitialized variables are not supported and the generated code will run like <span style="color: #0000ff;">no warnings 'uninitialized';</span> is specified. Fatal warnings with <span style="color: #0000ff;">use warnings FATAL;</span> is supported on a per-block basis, but currently only numeric warnings are promoted to fatal errors. This works by setting the <span style="color: #0000ff;">$^W (perllib.WARNING)</span> variable to 2.</li>
</ol>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Built_In_Packages"></a>Built-In Packages</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The following packages/pragmas are built-in to Pythonizer:</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">autodie, autovivification, builtin (blessed, ceil, floor), Carp, Carp::Assert, CGI, CGI::Carp, CGI::Cookie, CGI::Util, CGI::File::Temp, charnames, Class::Struct, Config (config_sh, %Config), constant, CORE, CORE::GLOBAL (file, die), Cwd, Data::Dumper (Dumper), Encode, Encode::Encoding, Encode::MIME::Name, English, Env, Exporter, Fcntl, feature, File::Basename, File::Path, File::Spec, File::Spec::Functions (file_name_is_absolute, catfile, rel2abs, abs2rel, splitpath, splitdir, curdir, updir), File::stat, File::Temp, FileHandle, FindBin, Getopt::Long, Getopt::Std, HTML::Entities, integer, IO::File, IO::Handle, lib, List::Util (sum, min, max, minstr, maxstr, product, sum0), Math::Complex, open, overload, parent, POSIX (tmpnam, tmpfile, ceil, floor, trunc, round, strftime), Scalar::Util (openhandle, blessed), Storable (dclone), strict, Switch, Sub::Util (subname), subs, Sys::Hostname, Text::Balanced (extract_bracketed), Text::ParseWords, Time::HiRes, Time::Local, Time::localtime, Time::tm, UNIVERSAL, utf8 and utf8:: functions, warnings, vars</p>
<p><a style="color: #0000ff;" name="Logs"></a></p>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Logs</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Logs are written to <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">/tmp/Pythonizer </tt>You can redirect this to any directory via symlink.<tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;"> </tt>Currently there is no option to customize the location of the log.</p>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Structure"></a>Structure and Operation</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Pythonizer consists of the main program called, as you can guess, <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">pythonizer</tt>, five modules and a helper script:</p>
<ul style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<li><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">PyConfig.pm <span style="color: #000000;">- Definitions and configuration options</span></tt></li>
<li><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">Pass0.pm <span style="color: #000000;">- Pre-pass which uses heuristics to determine if -M or -m should be used (unless these options are specified)</span></tt></li>
<li><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">Perlscan.pm <span style="color: #000000;">- Lexical analysis and Code Generation routines</span></tt></li>
<li><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">Pythonizer.pm <span style="color: #000000;">- First pass, which computes which variables are global and attempts to track the type of variables (int, str, float, array, hash)</span></tt></li>
<li><tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">Softpano.pm <span style="color: #000000;">- Messaging and Utilities</span></tt></li>
<li><span style="color: #000000;"><span style="color: #0000ff;">pythonizer_importer.pl</span> - Helper script to import user modules for <span style="color: #0000ff;">use</span>/<span style="color: #0000ff;">require</span> statements and gather their package, $VERSION, @EXPORT, @EXPORT_OK, and %EXPORT_TAGS</span></li>
</ul>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The Pythonizer begins by invoking<span style="color: #0000ff;"><span style="color: #000000;"> Pass0 (unless the -m or -M options are used). If Pass0 is run, or else if the pragma is specified as the first non plain comment line of the file, then a special comment in the source code is recognized that can pass options to Pythonizer:</span></span></p>
<p><a name="pragma"></a></p>
<ul>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #0000ff;"># pragma pythonizer <em>options</em></span></li>
</ul>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Where the <em>options</em> can be specified as flags like <span style="color: #0000ff;">-M</span> or <span style="color: #0000ff;">-v2</span> as defined above or using the following words, which can be separated by commas or spaces:</p>
<ul>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">traceback -- <span style="color: #0000ff;">-T</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #0000ff;"><span style="color: #000000;">trace run --</span> -n</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">autodie -- <span style="color: #0000ff;">-A</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">implicit global my -- <span style="color: #0000ff;">-m</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">no implicit global my -- <span style="color: #0000ff;">-M</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">pythonize standard library -- <span style="color: #0000ff;">-s</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">no pythonize standard library -- <span style="color: #0000ff;">-S</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">import perllib -- <span style="color: #0000ff;">-p</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">no import perllib -- <span style="color: #0000ff;">-P</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">no autovivifiction -- <span style="color: #0000ff;">-V</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #0000ff;"><span style="color: #000000;">black -- </span>-k</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #0000ff;"><span style="color: #000000;">no black -- </span>-K</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #0000ff;"><span style="color: #000000;">replace usage -- </span>-u</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #0000ff;"><span style="color: #000000;">no pl_to_py -- </span>-Y</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #0000ff;"><span style="color: #000000;">pl_to_py -- </span>-y</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #0000ff;"><span style="color: #000000;">no fully qualify calls -- </span>-F</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #0000ff;"><span style="color: #000000;">fully qualify calls -- </span>-f</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #0000ff;"><span style="color: #000000;">no replace usage -- </span>-U</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #0000ff;"><span style="color: #000000;">author -- </span>-a</span></li>
<li style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span style="color: #0000ff;"><span style="color: #000000;">verbose -- </span>-v2</span></li>
</ul>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Next pass 1 is run by Pythonizer.pm, which computed global variables, notes what variables may need initializing, notes what loops may need try/except blocks to handle thinks like next OUTER, and also what subroutines use local variables that need to have those variables stacked and unstacked. It also attempts to get the type of scalar variables so less string and number conversions are generated.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Pass 2 is in the pythonizer main program, which does most of the work in translating the Perl code to python. To handle use and require, it invokes <span style="color: #0000ff;">pythonizer_importer.pl</span> as a subprocess, which runs a <span style="color: #0000ff;">require</span> on each of the modules mentioned by the source program being translated. This is done to gather the package name, <span style="color: #0000ff;">$VERSION, @EXPORT, @EXPORT_OK</span>, and <span style="color: #0000ff;">%EXPORT_TAGS</span> from the modules without the module's namespace being loaded into the Pythonizer proper.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Finally, a post-pass, contained within Perlscan.pm is run over the generated Python code to remove unreferenced <span style="color: #0000ff;">import</span>s, clean up the code somewhat, remove a few oddities like <span style="color: #0000ff;">if not var is not None, <span style="color: #000000;">and remove multiple blank lines. Here we also do a toplogical sort on the generated <span style="color: #0000ff;">def</span>'s and we move them all up to the top of the generated code to ensure that all references to them occur after they are defined. (Perl does this differently as they have a compile pass followed by a run pass - Python starts running the code from top down without a separate compile pass.) The <strong>Black Uncompromizing Code Formatter</strong> is then run on the generated code, if it's installed on the machine and the <span style="color: #0000ff;">-K</span> flag is not passed.</span></span></p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The total size of the codebase in version 0.953 is around 16K lines:</p>
<pre style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; padding-left: 40px;"><span style="color: #0000ff;"># wc -l *.pm pythonizer</span>
<span style="color: #0000ff;"> 265 Pass0.pm</span>
<span style="color: #0000ff;"> 4875 Perlscan.pm</span>
<span style="color: #0000ff;"> 267 Pyconfig.pm</span>
<span style="color: #0000ff;"> 2653 Pythonizer.pm</span>
<span style="color: #0000ff;"> 344 Softpano.pm</span>
<span style="color: #0000ff;"> 7980 pythonizer</span>
<span style="color: #0000ff;"> 16384 total</span></pre>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Plus another 2K lines in the library:</p>
<pre style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; padding-left: 40px;"><span style="color: #0000ff;"># wc -l perllib/__init__.py</span>
<span style="color: #0000ff;">2445 perllib/__init__.py</span></pre>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The total size of the codebase in version 0.8 is around 4.3K lines:</p>
<pre style="font-family: Fixedsys; color: #0000ff; font-size: medium; margin: 1em 40px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"> # wc -l Perlscan.pm Pythonizer.pm pythonizer Softpano.pm pre_pythonizer.pl
1123 Perlscan.pm
474 Pythonizer.pm
1615 pythonizer
340 Softpano.pm
797 pre_pythonizer.pl
4349 total</pre>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The total size of the codebase in version 0.7 is slightly over 4K lines.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The total size of the codebase in version 0.5 is slightly below 4K lines.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The total size of the codebase in version 0.4 is around 3.5K lines.</p>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Recommended_manual_transformations_of_Perl_code"></a>Recommended manual transformations of Perl code</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Recently Perl adopted Python stance of minimizing the number of parenthesis in standard function</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The first and foremost under-parenthesized Perl script (the scripts which uses built-in functions without parenthesis, like recommended by "Modern Perl" are translated with more errors by the current version of Pythonizer than in cases when they are parenthesized. This topic is discussed below in more details and some examples are provided.</p>
<center style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<table border="2" width="90%" bgcolor="#FFFF00">
<tbody>
<tr>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;">
<p align="left"><strong>All problematic new-style postfix if statements and bash-style shortcut and/or statements like <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;"> </tt></strong></p>
<pre style="font-family: Fixedsys; color: #0000ff; font-size: 12pt; margin: 1em 40px;">$debug && print "Something" </pre>
<p align="left"><strong>statements need to be parenthesized</strong></p>
</td>
</tr>
</tbody>
</table>
</center>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Of course, cases are different and a function invocation as statement or as the only part of the assignment statement is pretty safe without parenthesis. But in complex expression your mileage can vary. In cases where Pythonizer complains, adding parenthesizes often allows the correct the translation and go forward.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Also sometime complex expressions are parsed incorrectly by Pythonizer. In such case you can factor then out and simplify in order to get correct translation. Or translate them manually as in most such cases the proper Python equivalent is different from close to "one to one" translation that Pythonizer provides, anyways.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Generally, Perl provide too much syntax rope and some programmers manage to hang themselves with it: the syntax variety allowed is just an overkill and stimulate adoption of "perverted" constructs which detract from, not add to the clarity of the code. </p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The most typical example of this kind of "syntactic perversions" is the excessive use of postfix if constructs. I would understand using them in loop to specify exist condition like</p>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<pre style="font-family: Fixedsys; color: #0000ff; font-size: 12pt; margin: 1em 40px;">last if (substr($line,0,3) eq 'EOF');</pre>
</blockquote>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">but not like</p>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<pre style="font-family: Fixedsys; color: #0000ff; font-size: 12pt; margin: 1em 40px;">$x++ if $i<$limit;</pre>
</blockquote>
<p><span style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">or</span></p>
<pre style="font-family: Fixedsys; color: #0000ff; font-size: medium; margin: 1em 40px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">print SQL "SELECT column 1 FROM $var" if (defined $var);</pre>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">in the first case writing</p>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<pre style="font-family: Fixedsys; color: #0000ff; font-size: 12pt; margin: 1em 40px;">if $i < $limit { $x++; }</pre>
</blockquote>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">is only two symbols longer but is much clearer and modifiable. Pythonizer recognizes single statements with postfix if or other conditional modifiers, and instead of single statement a comma separate list can be provided making them, essentially, a block:</p>
<pre style="font-family: Fixedsys; color: #0000ff; font-size: medium; margin: 1em 40px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">$i=5,$j=10 if( $next iteration);</pre>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">IMHO provides way too much syntax flexibility ;-).You need to transform your such statements to prefix if statements if you want automatic translation. Actually the result looks more readable:</p>
<pre style="font-family: Fixedsys; color: #0000ff; font-size: medium; margin: 1em 40px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">if( $next iteration ){
$i=5;$j=10
}</pre>
<p><span style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Similarly Pythonizer will complain in case of cascading my declarations:</span></p>
<pre style="font-family: Fixedsys; color: #0000ff; font-size: medium; margin: 1em 40px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">my $i=my $j=1</pre>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">But this probably makes some sense so it might be corrected in later versions.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">There are several even more rare form of abusing Perl syntax flexibility but I think those examples are enough.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Here are recommendation from famous book <a style="color: #0000ff;" href="https://en.wikipedia.org/wiki/The_Elements_of_Programming_Style">The Elements of Programming Style</a> that any decent programmer should strive to adhere:</p>
<ol style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<li>
<p style="word-spacing: 0px; text-indent: 0px;">Write clearly — don't be too clever.</p>
</li>
<li>
<p style="word-spacing: 0px; text-indent: 0px;">Say what you mean, simply and directly.</p>
</li>
<li>
<p style="word-spacing: 0px; text-indent: 0px;">Use library functions whenever feasible.</p>
</li>
<li>
<p style="word-spacing: 0px; text-indent: 0px;">Avoid too many temporary variables.</p>
</li>
<li>
<p style="word-spacing: 0px; text-indent: 0px;">Write clearly — don't sacrifice clarity for efficiency.</p>
</li>
<li>
<p style="word-spacing: 0px; text-indent: 0px;">Let the machine do the dirty work.</p>
</li>
<li>
<p style="word-spacing: 0px; text-indent: 0px;">Replace repetitive expressions by calls to common functions.</p>
</li>
<li>
<p style="word-spacing: 0px; text-indent: 0px;">Parenthesize to avoid ambiguity.</p>
</li>
<li>
<p style="word-spacing: 0px; text-indent: 0px;">Choose variable names that won't be confused.</p>
</li>
<li>
<p style="word-spacing: 0px; text-indent: 0px;">Avoid unnecessary branches.</p>
</li>
<li>
<p style="word-spacing: 0px; text-indent: 0px;">If a logical expression is hard to understand, try transforming it.</p>
</li>
<li>
<p style="word-spacing: 0px; text-indent: 0px;">... ... ...</p>
</li>
</ol>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Decision_to_remove_round_brackets"></a>Decision to remove opening and closing round brackets<br /> in Perl built-in function opened a can of worms</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Situation with under-parenthesized built-in function, that is mentions above, is more complex and here I think Perl implementers made a blunder opening a can of worms. Many statements written in this fashion are ambiguous.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">So we will have problem with the language itself. Which exists independently of the level of the upper level complexity allowed in Pythonizer and its limitations. </p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">For example:</p>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">It looks like with parenthesis elimination drive Perl developers into the situation similar to Chinese situation with the elimination of sparrows.
<p>Today I encountered the following ambiguous statement written in "de-parenthesized" "Modern Perl":</p>
<pre style="font-family: Fixedsys; color: #0000ff; font-size: 12pt; margin: 1em 40px;">get_config(split /$s/,$_);</pre>
<p><a style="color: #0000ff;" href="https://perlmonks.org/?abspart=1;displaytype=displaycode;part=1;node_id=11122556">[download]</a></p>
<p>Where it is completely unclear if</p>
<ol>
<li>We have two arguments to <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">get_config</tt> and one argument to <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">split</tt> (regular expression <tt>/$s/<tt>, and split is assumed to be operating on $_)</li>
<li>We have two arguments <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">to split (/$s/ </tt>and<tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;"> $_ )</tt> and one argument (expression) to <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">get_config</tt>.</li>
</ol>
<p>It is accepted by interpreter as case (2) which IMHO is correct, but still pretty arbitrary, especially if you write</p>
<pre style="font-family: Fixedsys; color: #0000ff; font-size: 12pt; margin: 1em 40px;">get_config(split /$s/,$i)</pre>
<p>instead.</p>
<pre style="font-family: Fixedsys; color: #0000ff; font-size: 12pt; margin: 1em 40px;"> DB<100> sub get_config{ print scalar(@_), join(' ',@_),"\n"}
DB<101> $s=' ';
DB<102> $_=qq(abba baba);
DB<103> get_config(split /$s/,$_);
2abba baba</pre>
<p>Unless this problem is fixed, this is an argument for sticking to earlier versions of Perl 5 and avoiding "de-parenthesized" "Modern Perl". Looks like "Parenthesis eliminators" essentially harmed the language, while trying to help. That's happens, but this is a rather sad situation.</p>
<p>In any case, versions after 5.26 probably will reach commercial Linuxes in 5 to 10 years time-frame so there is still a time to fix this.</p>
</blockquote>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Other_recommended_transformation_of_Perl_code"></a>Other recommended transformations of Perl code</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">While parenthesizing built-in function in statements which caused problems for Pythonizer is number one recommendation, there are several other.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">In many case you can get more correct translation via Pythonizer by simplifying Perl code. Some transformation can be done via macro generator like M4 some via Perl itself using regular expressions.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Pythonizer expects syntaxically correct Perl code. </p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Excessive syntax flexibility might helps to explains flimsy error reporting by Perl interpreter, when it accepts clearly syntaxically incorrect programs as valid. This situation is worse in the debugger then in interpreter itself.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Version 5.26.3 also refuses to function properly in some cases, probably hitting some internal bugs or corruption on internal data structures, which demonstrated itself that a certain statement is executed incorrectly. But it recovers, if you change your Perl code a little bit. I experienced one such situation with <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">pythonizer</tt>, when it was slightly less then 900 lines. Luckily as I added code the problem disappeared. But I seriously I thought about switching to GOlang at this point. </p>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Debugging_generated_Python_code"></a>Debugging generated Python code</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The Python debugger is still inferior to the Perl debugger, so working with it is both more difficult and more time consuming. </p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The standard invocation is something like</p>
<pre style="font-family: Fixedsys; color: #0000ff; font-size: 12pt; margin: 1em 40px;">python3.8 -m pdb maintest.py</pre>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">You can run the script till the first error with the command 'c' and if you are lucky at this point you have some useful information what is wrong from the diagnostic message produced by Python interpreter. If not, you need to work step by step and determine the context of the error yourself.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">See <a style="color: #0000ff;" href="../Debugging/index.shtml">Python Debugging</a> for some additional information and tips.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Generally to find the first error you can run the generated code with the command c and proceed from this point.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">But the fact that code runs to this point does not mean that the code executed correctly: you need to verify that.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">For some additional ideas see <a style="color: #0000ff;" href="../translating_perl_to_python.shtml">Perl to Python translation</a></p>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<h3 style="font-family: arial; text-align: center;"><a style="color: #0000ff;" name="Known_errors"></a>Known errors</h3>
</blockquote>
<ol style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<li>Pythonizer does not like some statements and standard functions calls with omitted round brackets (especially in complex expressions) and can mark them untranslatable, while translating them correctly if brackets are added.</li>
</ol>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Submission_of_tickets"></a>Submission of tickets</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Tickets can be opened on GitHub.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">The ticket should be reproducible on the most recent uploaded version; non reproducible tickets related to earlier version will be ignored. Information proved should be enough to reproduce the error:</p>
<ul style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<li>If case of internal errors, for example rejection of a valid statement, incorrect translation, or unlimited recursion please provide the current line and the context (say 10 "before" and 10 "after" lines.)</li>
</ul>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">It is recommended that you run pythonizer with the debugging option <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-d 3</tt> to generate additional output relevant fragment (only relevant fragment) can be attaches as a file to the ticket.</p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Samples the cause internal errors also need to be attached as files to save my time. </p>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="History"></a>History</h3>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><strong>Version 0.953 released</strong></p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><strong>Version 0.900 forked from the softpano version.</strong></p>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><strong>Version 0.8 uploaded</strong></p>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<p><strong>Changes since version 0.7</strong></p>
<p>Possibility to generate code for Python 2.7 and option -p were removed.</p>
<p>Option -w added which allows to specify the width of the line in the protocol. The default is 188 -- suitable for Fixsys 11 points font on 24" screen.</p>
<p>More correct translation of array assignments. Some non-obvious bugs in translation were fixed. Now you need to specify PERL5LIB variable pointing it to the directory with modules to run the program. Global variable now are initialized after main sub to undef value to create a global namespace. Previously this was done incorrectly. Simple installer for Python programmers who do not know much Perl added: the problem proved to be useful as a help for understanding Perl scripts by Python programmers.</p>
<p>Significantly more cases of using built-in functions without parenthesis are translated correctly</p>
<p><strong>Changes in pre_pythonizer.pl</strong></p>
<p>Unlike previous versions, the current version by default <em style="font-style: italic; font-weight: bold; color: #ff0000;">does not create</em> <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">main</tt> <em style="font-style: italic; font-weight: bold; color: #ff0000;">subroutine out of statement found on nesting level zero</em>, as it introduces some errors. You need specify option <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-m</tt> to create it.</p>
<p><em style="font-style: italic; font-weight: bold; color: #ff0000;">NOTE:</em> All Python statements on nesting level zero should starts from the beginning of the line which is ugly, but you can enclose them in the dummy <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">if</tt> statement</p>
<pre style="font-family: Fixedsys; color: #0000ff; font-size: 12pt; margin: 1em 40px;">if True: </pre>
<p>to create the artificial nesting level 1</p>
</blockquote>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><strong>Version 0.7 uploaded</strong></p>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<p><strong>Changes since version 0.6.</strong></p>
<p>This version creates of the list of global variables for each subroutine to maintain the same visibility in Python as in Perl and generates <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">global</tt> statement with the list of such variables that is inserted in each Python subroutine definition if pythonizer determined that this subroutine access global variables. The list might be excessive.</p>
</blockquote>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><strong>Version 0.6 uploaded</strong></p>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<p><strong>Changes since version 0.5.</strong></p>
<p>Regular expressions now are translated more correctly. Short cut if like <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">(debug>0) && say $line</tt> are translated in more general way then before. This is the first version that translates the main test (<tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">pre_pythonizer.pl</tt>) without syntax errors. Generated source starts executing in Python interpreter till the first error. List on internal functions created. Translation of backquotes and open statement improved.</p>
</blockquote>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><strong>Version 0.5 uploaded</strong></p>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<p><strong>Changes since version 0.4</strong></p>
<p>Regular expression and tr function translation was improved. Many other changes and error corrections. -r (refactor) option implemented to allow refactoring Perl source via pre-pythonlizer.pl in integrated fashion.</p>
</blockquote>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><strong>Version 0.4 uploaded</strong></p>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<p><strong>Changes since version 0.3</strong></p>
</blockquote>
<ul style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<li>Scanner is improved</li>
<li>f-strings are now generated for double quoted literals</li>
<li>Many errors fixed.</li>
</ul>
<p style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><strong>Version 0.3 uploaded</strong></p>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<p><strong>Changes since version 0.2:</strong></p>
</blockquote>
<ul style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<li>default version of Python used is now version 3.8;</li>
<li>option -p allows to set version 2 id you still need generation for Python 2.7 (more constructs will be untranslatable).</li>
</ul>
<hr style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;" />
<table style="font-family: 'Times New Roman'; letter-spacing: normal; orphans: 2; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;" border="1" width="100%">
<tbody>
<tr>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" colspan="5" rowspan="4" align="center" width="100%"><center><strong>Top Visited</strong></center><iframe src="../topupdates.shtml" width="100%" height="320" data-mce-fragment="1"></iframe></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center" bgcolor="#FFFF00"><strong><a style="color: #0000ff;" href="switchboard.shtml">Switchboard</a></strong></td>
</tr>
<tr>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center" bgcolor="#FFFF00"><strong><a style="color: #0000ff;" href="../index.shtml#Latest">Latest</a></strong></td>
</tr>
<tr>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center" bgcolor="#FFFF00"><strong><a style="color: #0000ff;" href="http://www.google.com/search?q=site:www.softpanorama.org&hl=en&lr=&tbo=1&prmd=ivns&source=lnt&tbs=qdr:y&sa=X&ei=aML0TaHgO4fUgAedxtjzCw&ved=0CAsQpwUoBQ&biw=1256&bih=801&cad=cbv#q=site:www.softpanorama.org&hl=en&lr=&tbo=1&prmd=ivns&source=lnt&tbs=qdr:w&sa=X&ei=csL0TYHsI4LagAeKu7DPCw&ved=0CAwQpwUoAw&fp=fb58e14853731932&biw=1256&bih=801">Past week</a></strong></td>
</tr>
<tr>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center" bgcolor="#FFFF00"><strong><a style="color: #0000ff;" href="http://www.google.com/search?q=site:www.softpanorama.org&hl=en&lr=&tbo=1&prmd=ivns&source=lnt&tbs=qdr:m&sa=X&ei=IMD0TdjLHMXUgQe9t6zfCw&ved=0CA0QpwUoBA">Past month</a></strong></td>
</tr>
</tbody>
</table>
<hr style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;" />
<h2 style="font-family: arial; text-align: center; color: #0000cc; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="NEWS_TOC"></a>NEWS CONTENTS</h2>
<ul style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<li>20220215 : <span style="color: #0000ff;">Version 0.953 uploaded</span></li>
<li>20211106 : <span style="color: #0000ff;">Version 0.9 forked from softpano version</span></li>
<li>20201005 : <a style="color: #0000ff;" href="#n20201005X_version_0_8_uploaded">Version 0.8 uploaded</a> ( <a style="color: #0000ff;" href="https://github.com/softpano/pythonizer" target="_blank" rel="noopener">Version 0.8 uploaded</a>, Oct 05, 2020 )</li>
<li>20200918 : <a style="color: #0000ff;" href="#n20200918X_version_0_7_uploaded">Version 0.7 uploaded</a> ( <a style="color: #0000ff;" href="https://github.com/softpano/pythonizer" target="_blank" rel="noopener">Version 0.7 uploaded</a>, Sep 18, 2020 )</li>
<li>20200908 : <a style="color: #0000ff;" href="#n20200908X_version_0_6_uploaded">Version 0.6 uploaded</a> ( <a style="color: #0000ff;" href="https://github.com/softpano/pythonizer" target="_blank" rel="noopener">Version 0.6 uploaded</a>, Sep 08, 2020 )</li>
<li>20200831 : <a style="color: #0000ff;" href="#n20200831X_version_0_5_uploaded">Version 0.5 uploaded</a> ( <a style="color: #0000ff;" href="https://github.com/softpano/pythonizer" target="_blank" rel="noopener">Version 0.5 uploaded</a>, Aug 31, 2020 )</li>
<li>20200822 : <a style="color: #0000ff;" href="#n20200822X_version_0_4_uploaded">Version 0.4 uploaded</a> ( <a style="color: #0000ff;" href="https://github.com/softpano/pythonizer" target="_blank" rel="noopener">Version 0.4 uploaded</a>, Aug 22, 2020 )</li>
<li>20200817 : <a style="color: #0000ff;" href="#n20200817X_version_0_3_was_uploaded">Version 0.3 was uploaded</a> ( <a style="color: #0000ff;" href="https://github.com/softpano/pythonizer" target="_blank" rel="noopener">Version 0.3 was uploaded</a>, Aug 17, 2020 )</li>
</ul>
<h2 style="font-family: arial; text-align: center; color: #0000cc; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="News"></a>Old News ;-)</h2>
<center style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<table border="0" width="100">
<tbody>
<tr>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#NEWS_TOC"><img src="../Images/up.png" width="16" height="16" border="0" /></a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#NEWS_TOC" name="n20201005X_version_0_8_uploaded"><img src="../Images/home.gif" width="16" height="18" border="0" /></a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#n20200918X_version_0_7_uploaded"><img src="../Images/down.png" width="16" height="16" border="0" /></a></td>
</tr>
</tbody>
</table>
</center>
<h4 style="font-family: Arial; color: #006400; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[Oct 05, 2020] <a style="color: #0000ff;" href="https://github.com/softpano/pythonizer" target="_blank" rel="noopener">Version 0.8 uploaded</a></h4>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<p><strong>Changes since version 0.7</strong></p>
<p>Possibility to generate code for Python 2.7 and option -p were removed.</p>
<p>Option -w added which allows to specify the width of the line in the protocol. The default is 188 -- suitable for Fixsys 11 points font on 24" screen.</p>
<p>More correct translation of array assignments. Some non-obvious bugs in translation were fixed. Now you need to specify <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">PERL5LIB</tt> variable pointing it to the directory with modules to run the program. Global variable now are initialized after main sub to undef value to create a global namespace. Previously this was done incorrectly. Simple installer for Python programmers who do not know much Perl added: the problem proved to be useful as a help for understanding Perl scripts by Python programmers.</p>
<p>Significantly more cases of using built-in functions without parenthesis are translated correctly</p>
<p><strong>Changes in pre_pythonizer.pl</strong></p>
<p>Current version by default <em style="font-style: italic; font-weight: bold; color: #ff0000;">does not create</em> <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">main</tt> <em style="font-style: italic; font-weight: bold; color: #ff0000;">subroutine out of statement found on nesting level zero</em>, as it introduces some errors. You need specify option <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">-m</tt> to create it.</p>
<p><em style="font-style: italic; font-weight: bold; color: #ff0000;">NOTE:</em> All Python statements on nesting level zero should starts from the beginning of the line <em style="font-style: italic; font-weight: bold; color: #ff0000;">which is ugly</em>, but you can enclose them in the dummy <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">if</tt> statement</p>
<pre style="font-family: Fixedsys; color: #0000ff; font-size: 12pt; margin: 1em 40px;">if True: </pre>
<p>to create an artificial nesting level 1</p>
</blockquote>
<center style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<table border="0" width="100">
<tbody>
<tr>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#n20201005X_version_0_8_uploaded"><img src="../Images/up.png" width="16" height="16" border="0" /></a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#NEWS_TOC" name="n20200918X_version_0_7_uploaded"><img src="../Images/home.gif" width="16" height="18" border="0" /></a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#n20200908X_version_0_6_uploaded"><img src="../Images/down.png" width="16" height="16" border="0" /></a></td>
</tr>
</tbody>
</table>
</center>
<h4 style="font-family: Arial; color: #006400; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[Sep 18, 2020] <a style="color: #0000ff;" href="https://github.com/softpano/pythonizer" target="_blank" rel="noopener">Version 0.7 uploaded</a></h4>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<p><strong>Changes since version 0.6</strong></p>
<p>This version creates of the list of global variables for each subroutine to maintain the same visibility in Python as in Perl and generates <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">global</tt> statement with the list of such variables that is inserted in each Python subroutine definition if pythonizer determined that this subroutine access global variables.</p>
<p>So far the specifics of Perl <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">state</tt> variable is ignored and they are assumed to be yet another type of global variables (they generally do not belong to the global namespace as while they have lifetime similar to global variables their namespace is local).</p>
</blockquote>
<center style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<table border="0" width="100">
<tbody>
<tr>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#n20200918X_version_0_7_uploaded"><img src="../Images/up.png" width="16" height="16" border="0" /></a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#NEWS_TOC" name="n20200908X_version_0_6_uploaded"><img src="../Images/home.gif" width="16" height="18" border="0" /></a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#n20200831X_version_0_5_uploaded"><img src="../Images/down.png" width="16" height="16" border="0" /></a></td>
</tr>
</tbody>
</table>
</center>
<h4 style="font-family: Arial; color: #006400; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[Sep 08, 2020] <a style="color: #0000ff;" href="https://github.com/softpano/pythonizer" target="_blank" rel="noopener">Version 0.6 uploaded</a></h4>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<p>Regular expressions now are translated more correctly. Short cut if like <tt style="font-family: Fixedsys; font-size: 12pt; color: #0000ff;">(debug>0) && say $line</tt> are translated in more general way then before. This is the first version that translates the main test (pre_pythonizer.pl) without syntax errors. Generated source starts executing in Python interpreter till the first error. List on internal functions created. Translation of backquotes and open statement improved.</p>
</blockquote>
<center style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<table border="0" width="100">
<tbody>
<tr>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#n20200908X_version_0_6_uploaded"><img src="../Images/up.png" width="16" height="16" border="0" /></a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#NEWS_TOC" name="n20200831X_version_0_5_uploaded"><img src="../Images/home.gif" width="16" height="18" border="0" /></a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#n20200822X_version_0_4_uploaded"><img src="../Images/down.png" width="16" height="16" border="0" /></a></td>
</tr>
</tbody>
</table>
</center>
<h4 style="font-family: Arial; color: #006400; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[Aug 31, 2020] <a style="color: #0000ff;" href="https://github.com/softpano/pythonizer" target="_blank" rel="noopener">Version 0.5 uploaded</a></h4>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<p><strong>Changes since version 0.4</strong></p>
<ul>
<li>Regular expression and tr function translation was improved.</li>
<li>Many other changes and error corrections.</li>
<li>-r (refactor) option implemented to allow refactoring Perl source via pre-pythonlizer.pl in integrated fashion.</li>
</ul>
</blockquote>
<center style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<table border="0" width="100">
<tbody>
<tr>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#n20200831X_version_0_5_uploaded"><img src="../Images/up.png" width="16" height="16" border="0" /></a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#NEWS_TOC" name="n20200822X_version_0_4_uploaded"><img src="../Images/home.gif" width="16" height="18" border="0" /></a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#n20200817X_version_0_3_was_uploaded"><img src="../Images/down.png" width="16" height="16" border="0" /></a></td>
</tr>
</tbody>
</table>
</center>
<h4 style="font-family: Arial; color: #006400; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><strong>[Aug 22, 2020] <a style="color: #0000ff;" href="https://github.com/softpano/pythonizer" target="_blank" rel="noopener">Version 0.4 uploaded</a></strong></h4>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<p><strong>Changes since version 0.3</strong></p>
<ul>
<li>Lexical scanner improved</li>
<li>f-strings are now generated for double quoted literals</li>
<li>Many errors fixed.</li>
</ul>
</blockquote>
<center style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<table border="0" width="100">
<tbody>
<tr>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#n20200822X_version_0_4_uploaded"><img src="../Images/up.png" width="16" height="16" border="0" /></a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#NEWS_TOC" name="n20200817X_version_0_3_was_uploaded"><img src="../Images/home.gif" width="16" height="18" border="0" /></a></td>
<td style="font-family: arial, helvetica, sans-serif; font-size: 10pt;" align="center"><a style="color: #0000ff;" href="#NEWS_TOC"><img src="../Images/down.png" width="16" height="16" border="0" /></a></td>
</tr>
</tbody>
</table>
</center>
<h4 style="font-family: Arial; color: #006400; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[Aug 17, 2020] <a style="color: #0000ff;" href="https://github.com/softpano/pythonizer" target="_blank" rel="noopener">Version 0.3 was uploaded</a></h4>
<blockquote style="font-size: 10pt; font-family: arial; background: #f9f9f9; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<p><strong>Changes since version 0.2:</strong></p>
<ul>
<li>default version of Python used is now version 3.8;</li>
<li>option -p allows to set version 2 id you still need generation for Python 2.7 (more constructs will be untranslatable).</li>
</ul>
</blockquote>
<h2 style="font-family: arial; text-align: center; color: #0000cc; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Recommended_Links"></a>Recommended Links</h2>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Top_articles"></a>Top articles</h3>
<h3 style="font-family: arial; text-align: center; color: #000000; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><a style="color: #0000ff;" name="Sites"></a>Sites</h3>
<ul style="color: #000000; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
<li><a style="color: #0000ff;" href="../Debugging/index.shtml">Python Debugging</a></li>
<li><a style="color: #0000ff;" href="http://www.softpanorama.org/Scripting/Pythonorama/Python_for_perl_programmers/index.shtml" target="_blank" rel="noopener">Python for Perl programmers</a></li>
<li><a style="color: #0000ff;" href="protocol_of_translation_of_pre_pythonizer020.shtml">Full protocol of translation of pre_pythonizer.pl</a></li>
<li><a style="color: #0000ff;" href="http://pleac.sourceforge.net/" target="_blank" rel="noopener">PLEAC - Programming Language Examples Alike Cookbook</a></li>
<li><a style="color: #0000ff;" href="https://wiki.python.org/moin/PyPerlish" target="_blank" rel="noopener">PyPerlish - Python Wiki</a> (it looks like the library itself is no longer available, only docs survived</li>
</ul>
</body>
</html>