Source

blogs.perl.org Entries / blogs.perl.org-entries / blogs.perl.org-journal.xhtml

Full commit
   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
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
<?xml version="1.0" encoding="utf-8"?>
<!-- vim: set indentexpr=:   -->
<!DOCTYPE
    html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
<head>
<title>blogs.perl.org Blog</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
div.entry
{
    border: darkgreen solid medium;
    padding: 0.5em;
    margin: 0.5em;
}
</style>
</head>
<body>

<div class="entry" id="text-table-1">

<ul class="info">
<li><b>Date:</b> 21-04-2011</li>
</ul>

<h1>Introduction to blogs.perl.org + Text::Table</h1>

<p>
Hello, Perl bloggers! I decided to start
blogging about a most of my exclusively Perl-related stuff here on
blogs.perl.org, in hope of getting more comments
from active Perlers. (Until now, I've blogged about it
<a href="http://shlomif-tech.livejournal.com/">on
my technical LiveJournal blog</a> and previously on
<a href="http://use.perl.org/~Shlomi+Fish/journal/">use.perl.org Journal</a>.).
You can learn more about me on <a href="http://www.shlomifish.org/">my home
site - www.shlomifish.org</a> .
</p>

<p>
OK, having put that aside - let's move on to the main topic of this post.
</p>

<hr />

<p>
Many months ago I wanted to use the
<a href="http://search.cpan.org/dist/Text-Table/">Text::Table CPAN module</a>
to present a table related to the meta-scan heuristics construction
scheme of <a href="http://fc-solve.berlios.de/">Freecell Solver</a>. Now,
I wanted to present nicely formatted borders, using the
<a href="http://en.wikipedia.org/wiki/Box-drawing_characters">Unicode
box-drawing characters</a> (which some people would recall from DOS).
However, I found it difficult to specify the separators in the
rulers properly based on their indices - they were assumed to be the
same globally. As a result, I've written
<a href="https://rt.cpan.org/Public/Bug/Display.html?id=61610">a patch</a>,
and placed the modifications in
<a href="http://github.com/shlomif/Text-Table">a github repository</a>.
</p>

<p>
The author of Text-Table (ANNO) told me he was working on a new version
of Text-Table, which will contain many improvements. However, I was still
interested in an enhanced version of the old Text-Table codebase with my
patch, and after talking on <a href="irc://irc.freenode.net/#perl">#perl</a>,
ANNO said I could have co-maint
on Text-Table-1.x and continue to improve it. The new Text-Table will be
released under a separate namespace - <tt>Text::Table2</tt> or so.
</p>

<p>
Many thanks go to ANNO for agreeing that I further develop Text::Table.
</p>

<p>
Using my git repository, I did many cleanups, like add
pod.t and pod-coverage.t, tweak the author information, add more strict and
warnings to the file, etc. ANNO 's original licence is
<a href="http://perlbuzz.com/2009/07/help-end-licensing-under-same-terms-as-perl-itself.html">"Same
terms as Perl"</a>, but since it is an iffy licensing, I decided that all
further changes will be under the terms of the Public-Domain/X11L/etc.. People
who send me pull requests on github may wish to add their names to the credits
(in the changes or even in the core module) but must not claim copyrights to
their changes.
</p>

<p>
OK, now for some output of the Unicode table:
</p>

<pre>
┌───────╥─────┬──────┬─────┬────┬──────┐
│ Place ║ 1   │ 2    │ 3   │ 4  │ 5    │
├───────╫─────┼──────┼─────┼────┼──────┤
│ 1     ║ 68  │ 317  │ 15  │ 3  │ 381  │
├───────╫─────┼──────┼─────┼────┼──────┤
│ 2     ║ 171 │ 482  │ 31  │ 14 │ 594  │
├───────╫─────┼──────┼─────┼────┼──────┤
│ 3     ║ 275 │ 867  │ 42  │ 22 │ 1007 │
├───────╫─────┼──────┼─────┼────┼──────┤
│ 4     ║ 458 │ 1442 │ 125 │ 30 │ 1630 │
├───────╫─────┼──────┼─────┼────┼──────┤
│ 5     ║ 640 │ 1715 │ 137 │ 47 │ 1730 │
└───────╨─────┴──────┴─────┴────┴──────┘
</pre>

<p>
Future plans are:
</p>

<ol>

<li>
Convert the remaining test scripts to Test::More.
</li>

<li>
Go over the code and clean it up
</li>

<li>
Add CPAN keywords to the <tt>META.yml</tt>. (Perhaps this will require
defining a Module-Build-based Build.PL file).
</li>

<li>
Add URLs to the <tt>META.ym</tt>l - to the module's homepage, to the github repository,
etc..
</li>

<li>
Possibly implement some future features.
</li>

<li>
Add some more tests.
</li>

</ol>

<p>
Contributions are naturally welcome, just fork the github repository and send
me a pull request. (Or patches are also OK.)
</p>

</div>

<div class="entry" id="entry-to-yapc-europe-2011">

<ul class="info">
<li><b>Date:</b> 20-06-2011</li>
<li class="tags">YAPC</li>
</ul>

<h1>Transferring a Ticket to YAPC::Europe::2011</h1>

<p>
I originally planned to attend
<a href="http://yapceurope.lv/ye2011/">YAPC::Europe::2011</a> in Riga, Latvia
(on 15-17 August, 2011), and so bought an early bird ticket, but will no
longer be able to attend due to personal reasons. As a result, I'm now seaking
to transfer the ticket to someone else, for the right price (which will be
cheaper than what I bought it.).
</p>

<p>
If you are interested, please
<a href="http://www.shlomifish.org/me/contact-me/">contact me</a> and we will
negotiate a price. I hope everybody enjoys the YAPCs.
</p>

</div>

<div class="entry" id="resuming-maintenance-of-xml-libxml">

<ul class="info">
<li><b>Date:</b> 20-06-2011</li>
<li class="tags">XML, libxml, CPAN</li>
</ul>

<h1>Resuming Maintenance of XML-LibXML</h1>

<p>
For a long while, work on the
<a href="http://beta.metacpan.org/release/XML-LibXML">XML-LibXML
CPAN module</a> halted as the existing maintainer was busy.
After <a href="http://code.activestate.com/lists/perl-xml/8885/">a
discussion</a> on the Perl-in-XML mailing list, some people and I were
given co-maintainer status and we resumed its maintenance inside
<a href="https://bitbucket.org/shlomif/perl-xml-libxml">a Bitbucket.org
Mercurial repository</a>.
</p>

<p>
So far what I did, was fix some low-hanging fruit
bugs, apply some patches, as well as start the long process of converting
the test suite, which still uses Test.pm to
<a href="http://beta.metacpan.org/module/Test::More">Test::More</a> . There are
still many bugs lurking there, and some of them are XS bugs that are still
beyond my reach, and I could use some assistance there. But it's a start.
</p>

<p>
If you're interested in helping, the clone the repository, write a patch and
send me a pull request.
</p>

<p>
<b>Text::Table Update:</b> I've written about
<a href="http://blogs.perl.org/users/shlomi_fish/2011/04/introduction-to-blogsperlorg-texttable.html">resuming
the maintenance of Text::Table</a> in April, and it progressed nicely:
the tests were converted to Test::More, a lot of the code was cleaned up,
the build system was converted to Module::Build, and keywords and resource
URLs were defined, and some bugs were solved (along with tests). I'm still
looking into ways to clean up the code, and if anyone has an idea for a cool
feature, then they should drop me a line (or provide a patch).
</p>

</div>

<div class="entry" id="convert-away-from-Test.pm">

<ul class="info">
<li><b>Date:</b> 23-06-2011</li>
<li class="tags">QA, PPI, Perl</li>
</ul>

<h1>PPI-Based Script to Convert Test.pm-based Test Programs to Test::More</h1>

<p>
Some CPAN modules I inherited used the old
<a href="http://search.cpan.org/perldoc?Test">Test.pm</a> for some of their
<tt>t/*.t</tt> scripts instead of the more modern
<a href="http://en.wikipedia.org/wiki/Test::More">Test::More</a>. This
annoys me to no end because Test.pm is very limited. When I worked on
<a href="http://beta.metacpan.org/release/Config-IniFiles">Config-IniFiles</a>,
I did the conversion manually, which was a lot of work. More recently, I
<a href="http://blogs.perl.org/users/shlomi_fish/2011/06/resuming-maintenance-of-xml-libxml.html">started
working on XML-LibXML</a> which has over 40 of those pesky Test.pm scripts, and
I did not have the nerve to do all the manual and menial work.
</p>

<p>
As a result, I ended up spending a few hours studying
<a href="http://beta.metacpan.org/release/PPI">PPI</a> (the Perl Parsing
Interface), and writing
<a href="http://www.shlomifish.org/open-source/projects/Test.pm-Converter/">a
script</a> to automatically convert Test.pm-based scripts to Test::More. The
main issue at hand was that in Test.pm, a single argument <tt>ok()</tt>
tests for the scalar's truth, while a double argument <tt>ok()</tt> tests for
simple equivalence (similarly to Test::More's <tt>is()</tt>). Eventually, I got
the script working, with some limitations (see <a
href="http://www.shlomifish.org/open-source/projects/Test.pm-Converter/">the page</a>).
</p>

<p>
So what was my impression of PPI? It naturally seems more robust than using
regular expressions and hacks to process Perl code, but there were a few quirks.
For example, a PPI
<a href="http://beta.metacpan.org/module/PPI::Structure::List">list</a> contains
an array of its contents, and the commas are part of them, as are the
various other tokens in the sub-expressions. Therefore, divining the count of
the  arguments is pretty hard. I would have expected to get a more <a href="http://en.wikipedia.org/wiki/Abstract_syntax_tree">abstract
syntax tree</a> of the arguments, and since I didn't I had to work around
it with an ugly kludge.
</p>

<p>
Furthermore, after stringifying the document object, the contents of the
<a href="http://en.wikipedia.org/wiki/Here_document">here-documents</a> were
not included in the output from some reason. However, I may have done something
wrong. I also wish the PPI PODs contained more meaningful examples.
</p>

<p>
Nevertheless, my script is mostly working now and I can utilise it to
"test-lift" legacy test programs. You might find it useful too, so it's there
in case you need it, and patches to fix its limitations would be welcome.
</p>

</div>

<div class="entry" id="Inline-C">

<ul class="info">
<li><b>Date:</b> 09-11-2011</li>
<li class="tags">Perl, QA, XS, Inline, C, ctypes, gcc</li>
</ul>

<h1>My Experience with Inline::C</h1>

<p>
I know I didn’t write here for a long time, and I apologise for it, but I have
this entry and another one in mind and I hope they can compensate for it.
</p>

<p>
For my work on <a href="http://fc-solve.shlomifish.org/">Freecell Solver</a>,
I’ve written some code for encoding and decoding game positions into a
compact format, by encoding them as a delta from the position of origin. I
first wrote it in Perl, in order to prototype it, and later
translated it to C (which is the language that Freecell Solver is written in).
I have written some rudimentary unit tests for it, but also wanted to test the
code against a large number of positions, by runnign it over the solutions of
many Freecell deals.
</p>

<p>
The encoding rearranges the order of the card columns and the freecells, so
testing that the output test is correct requires calculating that arrangement.
This was also done by the Perl code. I decided to write a small wrapper for
an encoding+decoding round-trip in C, and use it from a Perl program I was
writing. So far so good.
</p>

<p>
I first looked at <a href="https://gitorious.org/perl-ctypes">the
Perl version of Ctypes</a>, but it failed a large number of its assertions
on my system, so I could not really trust it. Then I looked at
<a href="http://search.cpan.org/perldoc?Inline::C">Inline::C</a>. I could
not understand from its main page, how to return an <tt>SV *</tt> containing
a string from it, but this was covered in the extensive
<a href="http://search.cpan.org/perldoc?Inline::C-Cookbook">Inline::C
cookbook</a> and I wrote this Inline::C function:
</p>

<pre>
extern char * fc_solve_user_INTERNAL_delta_states_enc_and_dec(
    const char * init_state_str_proto,
    const char * derived_state_str_proto
    );

SV* enc_and_dec(char * init_state_s, char * derived_state_s) {
    SV * ret;
    char * s;
    s = fc_solve_user_INTERNAL_delta_states_enc_and_dec(init_state_s, derived_state_s);

    ret = newSVpv(s, 0);
    free(s);
    return ret;
}
</pre>

<p>
I don't need to use “sv_2mortal” there because Inline::C does that for us.
Then I tried to test it. It failed with this error:
</p>

<pre>
perl: symbol lookup error: /home/shlomif/progs/freecell/trunk/fc-solve/source/_Inline/lib/auto/Mega_Test_for_C_delta_states_pl_9385/Mega_Test_for_C_delta_states_pl_9385.so: undefined symbol: fc_solve_user_INTERNAL_delta_states_enc_and_dec
</pre>

<p>
I was familiar with errors like that, but it took me over an hour of playing
with the various Inline::C configuration options, and trying to figure out
why it didn’t link against the relevant Freecell Solver library to realise
what the problem was. It was that the library in question did not export the
symbol, and gcc realised it didn't give the XS extension anything and omitted
it.
</p>

<p>
After fixing this line in my C source:
</p>

<pre>
char * DLLEXPORT fc_solve_user_INTERNAL_delta_states_enc_and_dec(
</pre>

<p>
To this line:
</p>

<pre>
DLLEXPORT char * fc_solve_user_INTERNAL_delta_states_enc_and_dec(
</pre>

<p>
Everything worked properly, and I was able to run the so-called “mega-test”.
</p>

<p>
If you’re having similar problems with Inline::C, you should try to add
<tt>CLEAN_AFTER_BUILD =&gt; 0</tt> to its configuration. It ended up clarifying
a lot for me.
</p>

<p>
Cheers!
</p>

</div>

<div class="entry" id="exec-portability">

<ul class="info">
<li><b>Date:</b> 09-11-2011</li>
<li class="tags">exec, perl, portability, whitespace, windows, unix</li>
</ul>

<h1>exec's portability</h1>

<p>
Pop quiz! What does this perl 5 program prints when executed with no
arguments?
</p>

<pre>
#!/usr/bin/perl

use strict;
use warnings;

if (! @ARGV)
{
    exec($^X, $0, "hello world");
}
else
{
    my $arg = shift(@ARGV);
    print "Got &lt;$arg&gt;\n";
    if (@ARGV)
    {
        print "Other args are &lt;@ARGV&gt;\n";
    }
}
</pre>

<p>
The answer is “it depends.”. On my Linux system it prints
“Got &lt;hello world&gt;”, while on Windows, using Strawberry Perl, it
prints “Got &lt;hello&gt;” and later on that the other args are “world”.
</p>

<p>
I would expect the Linux behaviour were every argument passed to the list
<a href="http://perldoc.perl.org/functions/exec.html">exec</a> arrives as
one argument to <tt>@ARGV</tt> regardless of whitespace as the correct. It
also the behaviour exhibited on both operating systems using
<a href="http://perldoc.perl.org/functions/system.html">system</a>. Is this
a bug?
</p>

<p>
<a href="http://perldoc.perl.org/perlport.html">perlport</a> only has this
to say about whitespace: <q>Whitespace in filenames is tolerated on most
systems, but not all, and even on systems where it might be tolerated, some
utilities might become confused by such whitespace.</q>.
</p>

<p>
I discovered this strange mis-behaviour when working on a commission for
a client who is Windows-based.
</p>

</div>

<div class="entry" id="telaviv_pm_2011_Nov_report">

<ul class="info">
<li><b>Date:</b> 03-12-2011</li>
<li class="tags">Perl, Mongers, Tel Aviv, Israel, meeting, DBI, DBIx-Class, local-lib, perlbrew, cpanminus, CPAN, Firebird, SQL</li>
</ul>

<h1>Report on the Latest Tel Aviv Perl Mongers Meeting</h1>

<p>
I attended the latest
<a href="http://telaviv.pm.org/">Tel Aviv Perl Mongers (TelAviv.pm)</a>
meeting the other
day, and am writing this report in order to encourage more people
to come. We didn't have meetings in September or October due to the Jewish
holidays and some renovations on the site, so it was good to finally have
a meeting.
</p>

<p>
Before the meeting, I had helped publicise it on various online news channels,
and thankfully quite a few people (about 20-30) came. I had a previous
appointment that day at 12:00, and so returned home where I ate, worked on
the computer, and rested before the TelAviv.pm meeting.
</p>

<p>
After I rode the bus, I arrived there a few minutes earlier. I met a fellow
Perl monger on the way. We found the room with some difficulty, as there were
very few signs outside the doors of the various rooms in the building. Several
people
including  <a href="http://szabgab.com/">Gabor</a> were already sitting
in the room.
They were discussing the upcoming Israeli Perl Workshop in February. In any
case, I decided to walk to the nearby
grocery store to buy some refreshments for the meeting, and when I returned
there were more people in the room.
</p>

<p>
Quite a few people arrived relatively late, but the talks started mostly on
schedule. The first talk (by Erez Schatz) was short, and it discussed some
recent tools that
facilitate the Perl programmer’s life: <a href="http://search.cpan.org/dist/local-lib/">local-lib</a>, <a href="http://www.perlbrew.pl/">perlbrew</a>, cpanm
and pm-uninstall. The talk was very fun, and he ended up covering some other
tools in brief in the last slide. I’m still not convinced that I should use
CPAN-Minus instead of my CPANPLUS (especially given
<a href="http://search.cpan.org/dist/CPANPLUS-Dist-Mageia/">CPANPLUS-Dist-Mageia</a>
and friends), but I still like perlbrew and local::lib and pm-uninstall seems
useful.
</p>

<p>
Erez mentioned that on Perl forums there were several very common and hated
questions like “How do I uninstall a perl module?” or “How can I use
CPAN without root?” and that these technologies address these needs precisely.
</p>

<p>
After this talk, Erez gave a longer talk about DBIx-Class, which is an
Object-Relational Mapper (ORM) for Perl. For the demo, he used a company
whose employees are dogs, and the slides featured many pictures of dogs in
suits (some of them pretty scary). There were a few glitches in the
demonstration, but they
were promptly overcome, and the <tt>DBIC_TRACE=1</tt> flag was a big help.
One bug in the code was that instead of updating the employee's department
(by looking it up by name), the department's name was updated (globally). I
any case, it was an enjoyable talk, but the person who sat next to me said
that she didn’t like it because she used to be a DBA, and she was worried about
performance.
</p>

<p>
Erez mentioned that DBIx-Class was the “Elephant in the Room” of Perl ORMs,
which I had concluded was the case as well.
</p>

<p>
After that talk, there was a break, where people got to eat more of the
cookies I bought and to chat. Afterwards, Ido Kanner presented about
<a href="http://www.firebirdsql.org/">Firebird SQL</a>. It was a good talk,
and Ido drew some comparisons between Firebird and SQLite, MySQL and
PostgreSQL. Firebird looks interesting and it also has embedded (like
SQLite) and read-only modes.
</p>

<p>
One problem during the talk was that the projector kept shutting down,
and it took us some trouble to restart it. We hoped this problem would be
resolved in upcoming meetings.
</p>

<p>
After the meeting, some of us (about 10) went to Spaghettim (a pasta/etc.
place) and had dinner. We chatted about Atheism, Cable company tech-support,
GNOME 3 and KDE 4, and lots of other stuff. This time I had a pizza, which
although not too bad, made me realise I will be ordering pasta there from now
on.
</p>

<p>
To sum up, it was a very enjoyable meeting, and I’m looking forward for
more future ones. One thing notable about it is that this time Sawyer did not
deliver a talk, which made him happy because other people volunteered to do
so instead.
</p>

</div>

<div class="entry" id="breaking_the_perl_debugger_for_fun_and_profit">

<ul class="info">
<li><b>Date:</b> 26-12-2011</li>
<li class="tags">perl,debugger,debugging,refactoring,features,sopa,telaviv,mongers</li>
</ul>

<h1>Breaking the Perl Debugger for Fun and Profit</h1>

<p>
Before I cover the main topic of this entry, here are some short news and
action items:
</p>

<ol>
<li>
<p>
If you have not acted against
<a href="https://www.eff.org/deeplinks/2011/12/fight-blacklist-toolkit-anti-sopa-activists">SOPA
- the proposed online blacklist/censorship bill</a>, you should. Follow the
link for information on how to act against it.
</p>
</li>
<li>
<p>
I have announced the
<a href="http://shlomif-tech.livejournal.com/60825.html">next Tel Aviv
Perl Mongers meeting</a> on my technical journal on LiveJournal.com. It will
take place this Wednesday, on 28 December, 2011. More information in the link.
</p>
</li>

<li>
<p>
<a href="http://golf.shinh.org/">Anarchy Golf</a> is a new server for Code Golf,
which are online programming competitions for implementing code as shortly as
possible. It supports Perl 5, Perl 6 and many other languages. There is
<a href="http://golf.shinh.org/p.rb?Starburst">an active challenge</a>, where
the only Perl 5 submission so far is mine, so I could use some competition.
</p>
</li>
</ol>

<p>
Now for the main topic of the post. Recently, three patches were integrated
into the perl-5 core implementing new features in the perl debugger:
</p>

<ol>
<li>
<a href="http://www.nntp.perl.org/group/perl.perl5.porters/2011/04/msg171038.html">Add "b &lt;filename&gt;:&lt;line&gt; &lt;cond&gt;" to perl -d</a> by me.
</li>
<li>
<a href="http://www.nntp.perl.org/group/perl.perl5.porters/2011/08/msg176454.html">Add enable/disable commands for breakpoints in perl -d</a> also by me.
</li>
<li>
<a href="https://rt.perl.org/rt3/Public/Bug/Display.html?id=104168">"Trace to max depth"</a> by Peter Scott.
</li>
</ol>

<p>
When Father Chrysostomos tried to apply the first patch, he noticed its tests
started failing. Apparently, the breakpoint functionality (irrespective of
the patch's added functionality) became broken in bleadperl, due to a change
in the internals, and it wasn't caught by the debugger's existing tests. I
ended up submitting another patch to add a test for some of the existing
breakpoint functionality.
</p>

<p>
The other two patches passed all of their own tests and the existing ones, but
that wasn't the end of the story. A short time afterwards
<a href="https://rt.perl.org/rt3/Public/Bug/Display.html?id=104820">a
regression was reported in the debugger</a>, which was caused by one of the
patches that I introduced. While, I fixed it with a test, it was soon followed
by other reports and fixes. None of these bugs were caught by the test suite
of the perl debugger, which is incredibly incomplete.
</p>

<p>
Another E-mail that caused an active discussion was
<a href="http://www.nntp.perl.org/group/perl.perl5.porters/2011/11/msg179847.html">my
proposal to add strict and warnings to lib/perl5db.pl</a>, in which someone
kept arguing against it, and eventually said he confused it (it being the
defualt command-line debugger front-end) with the debugger's guts, and ended
up also supporting adding "use strict;".
</p>

<p>
I ended up working on adding "strict" to the debugger on a git branch, and
was eventually successful (though I temporarily broken no-strict code on the
debugger evaluated lines, to which I added a test.). RJBS (the current
pumpking) said he'd like to integrate this patch only after perl-5.16.x
is released.
</p>

<p>
The morals of this story is that the perl debugger needs more tests, and
that trying to enhance it can easily break it. I started
<a href="https://github.com/shlomif/perl/tree/perl-d-add-tests-3">a branch
on GitHub</a> where I've been committing more tests to the perl debugger
to enhance its coverage.
</p>

<p>
There's also a Google Code-In task for devising a strategy to do that, and
I've volunteered to mentor it. All this will hopefully result in less breakage
in the future.
</p>

<p>
Happy Holidays, and a Happy New Year.
</p>

</div>

<div class="entry" id="report_on_israeli_perl_workshop_2012">

<ul class="info">
<li><b>Date:</b> 27-03-2012</li>
<li class="tags">perl, workshop, israel, events, 2012</li>
</ul>

<h1>Report on the Israeli Perl Workshop 2012</h1>

<p>
Well, I've got a lot of stuff I’d like to blog about in the various blogs of
mine, and so I’m starting with this report on the
<a href="http://act.perl.org.il/ilpw2012/">Israeli Perl Workshop of 2012</a>,
which had taken place in 28 February, 2012. Moreover, April Fools' Day is
approaching, and I had an idea for a Perl-related April Fools' gag, but after
telling it to RJBS (the current Perl pumpking), he and I agreed that it would
hit too many nerves. (PerlJam on IRC said he liked it, though). Maybe I’ll
publish it on 2 April with a big disclaimer on top, just for kicks.
</p>

<p>
Anyway, here is the report. I had originally posted it to the Perl in Israel
mailing list for review, but did not get any reviews, so it may not be too
letter-perfect, but I guess that’s life.
</p>

<p>This is my report about the
<a href="http://act.perl.org.il/ilpw2012/">Israeli Perl Workshop of 2012</a> . It was
a fun and educational event, and I'm glad I was able to attend it. For better
or for worse, all the talks I attended were in Room 1, but I was still able
to hear the ends of a few talks in Room 2 (because the corresponding talks
in Room 1 ended before them).</p>
<p>I set up an alarm the night before in order to wake up early in time for the
event, and ended up waking up some time before it (and even the alarm time was
much earlier than what I was used to). Then I made some preparations, ate
breakfast, and caught the appropriate bus. After I walked from the bus station
to Shenkar, it took me some time to find the place, because it wasn't the
same entrance as our normal rooms, and the signs were confusing. What I needed
to do was to take the stairs down to the yard, and then go to the organisation
room, but it was hard to find.</p>
<p>There I got my name sticker, the schedule, and some swag from booking.com. I’d
like to thank <a href="http://www.booking.com/">Booking.com</a> for sponsoring the Israeli
Perl Workshop 2012 (as well as having a presence there and giving some swag
and chocolates), and they are looking for software developers with Perl
experience to relocate to Amsterdam, so please consider working for them.</p>
<p>In the yard, I met a few people including
<a href="http://search.cpan.org/~flora/">Florian Ragwitz</a> (a.k.a &quot;FLORA&quot; on CPAN or
&quot;rafl&quot; on IRC - he has many cool modules there, including quite a few XS ones),
who was one of the workshop’s visitors from Germany. Despite being German, his
English accent sounded English to us. Later on we discussed accents in English
and he noted that the accents of some Israelis he met sounded like French to
him (while ours seemed less so). This is strange, because Israelis can
distinguish between a French accent in English and an Israeli Hebrew accent in
English. </p>
<p>Anyway, Florian told me that he is planning on reviewing and pulling my
Test::Aggregate GitHub pull request Real Soon Now™, a fact which has brought
me some relief, because I've tried to contact him on IRC and ask him if he
remembers.</p>
<p>For better or for worse, all the talks that I preferred to hear took place in
room #1 (while sometimes visiting Room #2) to hear the ends of talks. I still
would be happy to hear many of the talks that took place in Room #2 in the
normal Tel Aviv Perl Mongers meetings, or alternatively, those talks in room #1
which lacked enough time to be conveyed satisfactorily.</p>
<p>The first talk in the day was
<a href="http://search.cpan.org/~eilara/">Ran Eilam</a>’s talk about &quot;Syntactic Sugar
causes Cancer of the Semicolon”, which had to be trimmed towards the end,
because
the introduction may have taken too long. The talk was interesting starting
from an example of <code>ptr-&gt;val</code> being sugar in the C programming language
for <code>(*ptr).val</code> and continuing to further examples. Ran raised the issue
of whether syntactic sugar was important or not, which turns out to not be
a straightforward question. He then demonstrated some modules for syntactic
sugar on CPAN.</p>
<p>I hope Ran can give a rerun of it on one of the mongers' meetings with more
time allocated for that.</p>
<p>After that I attended the talk of Stefan Hornburg (“racke”, known as
<a href="http://search.cpan.org/~hornburg/">HORNBURG on CPAN</a>) who was another
visitor from Germany, about
<a href="http://act.perl.org.il/ilpw2012/talk/3955">Template::Flute</a> which is a
designer’s friendly template system. In this template, one uses an HTML file
with standard HTML attributes for designating the fields that needs to be
replaced, and then an XML specification file that specifies how to process
the HTML (and in addition one uses Perl to give it data). As a result the
designers can manipulate the HTML with their own tools, while still
allowing the programmers to populate it with data.</p>
<p>This seems like an interesting and potentially useful tool, but it’s
less expressive than template systems such as Template Toolkit. After the talk,
another attendee whom we talked in private questioned the need for both the
HTML file and the XML specification, but I didn't find a way to avoid it
given the constraints that the HTML will be valid HTML 4/XHTML 1.</p>
<p>The next talk about Time Management in Software Projects was cancelled because
the presenter did not come (due to lack of time management as we joked then).
I was able to catch a glimpse of the end of
<a href="http://corky.net/dotan/">Dotan Dimet</a>’s “Perl and JavaScript:
bioinformatics in a browser window” talk, but I don’t remember a lot of
it except for a small amount of demonstration.</p>
<p>The talk about Zero to CPAN was eventually given by
<a href="http://blogs.perl.org/users/sawyer_x/">Sawyer</a> instead of by
<a href="http://blogs.perl.org/users/erez_schatz/">Erez Schatz</a>. It was a nice one, and I’ve learned about
<a href="http://metacpan.org/release/CPAN-Changes">the CPAN-Changes module</a> there
(after Florian mentioned it, though). Sawyer covered the way to get to a
working CPAN-like distribution from scratch using tools such as
module-starter and explained what every file in the CPAN module hierarchy
does, and demonstrated some test-driven-development. I knew most of it already,
but it was still a fun talk.</p>
<p><a href="http://www.linkedin.com/in/amirfr">Amir Friedman</a>‘s talk about software
configuration management (SCM) came next,
and he discussed some open-source solutions for the various parts of SCM,
which include version control, release management, task management, and
project management. He recommended Gitflow (which we had a talk about
on the Tel Aviv mongers mailing list) for version control and release
management, and a different solution called Jenkins for issue tracking (if
I remember correctly). I then asked what he thought of integrated “all-in-one”
solutions for SCM, and he said that those were pricey and he did not have
any significant experience with them.</p>
<p>The lunch break came next and I overheard a talk between two other people
about teaching English to speakers of non-English languages. One of them
said that he once worked with some Spanish Electrical Engineers and that they
were “completely isolated” from the rest of the world because they didn’t
read the literature in English. Then we discussed whether it was economical
to teach English to hundreds of millions of speakers of Spanish, or whether
we should expect most things to be translated. It was compared to the
“give a man a fish” vs. “teach a man to fish”. We also discussed the fact that
Dutchmen tended to have very good English, and one of the other people
commented that it was true, but that they still tended to prefer using
software with Dutch localisation.</p>
<p>I’ve also talked with Sawyer about his upcoming
<a href="http://act.perl.org.il/ilpw2012/talk/3936">“CGI.pm MUST DIE!” talk</a>. He
said that he needs to become mentally energised for that talk because he
feels strongly about it and wants to convey the energy. He passed an
anecdote from a conference in Europe, in which he had given a talk about
Dancer, and said he was so emotional then that people said “You must
see him” and rushed to see his other talk. Moreover, afterwards, when asked
who were the two best presenters in the conference, they said “[Someone
very famous] and that Dancer guy”.</p>
<p>The anti-CGI.pm presenting was indeed energetic and emotional, but kinda fell
below my expectations due to the yard talk that preceded it. It was still
pretty informative. Dotan Dimet later took the stage for the rebuttal
of “CGI.pm - the only web development framework you’ll ever need” which was
less emotional but still interesting. I was not convinced that CGI.pm’s
HTML generation routines were a good way to do output HTML (I never really
liked them), so I may have been more convinced by Sawyer.</p>
<p><a href="http://www.ynonperek.com/">Ynon Perek</a>’s
<a href="http://act.perl.org.il/ilpw2012/talk/3977">talk</a> about
“Implementing Perl (Moose) Design Patterns” came next, which was interesting,
but again lacked adequate time to cover everything, and I hope will be given
with less time constraints. One anecdote from there was that Ynon said there
where three primary ways for polymorphism in Perl: Inheritance (“is-a”),
Roles/Traits (“does-a”) and Containment/Delegation (“has-a”) and that
he could no longer recommend inheritance (but did not get to explain why not
from what I recall).</p>
<p>In any case, I was surprised at Ynon’s implementation of the Factory
pattern, and don’t remember the implementation given by him.</p>
<p>Next came Tamir Lousky’s
<a href="http://act.perl.org.il/ilpw2012/talk/3953">talk</a> about generating vector
graphics with Perl and SVG. Its slides contained a lot of very nice eye candy.
The introduction
to SVG and generating it was quite rudimentary, and did not cover the full
potential of SVG. The demonstration and explanation of the module for
generating random trees using SVG was interesting.</p>
<p><a href="http://act.perl.org.il/ilpw2012/talk/3959">David Tabachnikov</a>’s next gave an
interesting talk called “Scaling Up”. He
contrasted optimisation (which makes your code run faster with the existing
resources) to vertical scaling (= buying faster computers) to Horizontal
scaling (= buying more hardware). He also noted that there’s some speed
difference between the various SQL databases, but he did not encounter a
situation where it would have made too much difference.</p>
<p>The last feature of the evening were the lightning talks. I recall a talk
by Florian Ragwitz about Google Code-In and Google Summer-of-Code. I also
recall <a href="http://szabgab.com/">Gabor</a>’s talk about surviving in an uncooperative
workplace. He said
that if the workplace does not practise best practices such as using version
control systems or writing automated tests, one can create their own
small island of sanity where they make use of that on their own, and gradually
convince the rest of the organisation that it’s beneficial.</p>
<p>After the lightning talks, some people went to a local restaurant for dinner,
but I decided against it because I was too tired from waking up early. As a
result, I found someone who drove up north to drive me home, and got home.</p>
<p>In the schedule I noticed that one could go to a certain URL at
<a href="http://www.oreilly.com/">O’Reilly</a> and
receive a free E-book of their choice. I used this opportunity to get the book
<a href="http://shop.oreilly.com/product/9780596510046.do">Beautiful Code</a> , which
I have started reading.</p>
<p>The day was exhausting but very fun, and I enjoyed all the talks I attended.
I’d like to thank the organisers of the event and most notably
<a href="http://szabgab.com/">Gabor Szabo</a> and Sawyer X,
<a href="http://www.shenkar.ac.il/">Shenkar college</a> for providing the venue,
<a href="http://www.booking.com/">Booking.com</a> for the sponsorship, O’Reilly for
the free book presents, the foreign guests who came to present and to attend,
and all the other presenters, who volunteered to give talks.</p>
<p>I hope we can repeat this the next year.
</p>

</div>

<div class="entry" id="the_perl_april_fools_that_could_have_been">

<ul class="info">
<li><b>Date:</b> 09-04-2012</li>
<li class="tags">perl, april fools, joke</li>
</ul>

<h1>The Perl April Fools' Gag That Could Have Been</h1>

<p>
On my <a href="http://blogs.perl.org/users/shlomi_fish/2012/03/report-on-the-israeli-perl-workshop-2012.html">last entry</a>,
I told you that I have had an idea for a Perl-related April Fools’ day gag,
and that I would possibly reveal it on 2-April with a big disclaimer
on top, just for kicks. Well, it’s already 9-April, but I guess it is better
late than never, right?
</p>

<p>
OK, here is the big disclaimer: <b>THIS IS A JOKE. IT’S NOT SERIOUS. SO
RELAX - IT IS NOT GOING TO HAPPEN SOON (AND HOPEFULLY WILL NOT EVER
HAPPEN).</b>.
</p>

<p>
OK, now let’s move on to the gag itself:
</p>

<blockquote>
<p>
1 April 2012, Tel Aviv, Israel: the Perl foundation has announced today
that by inspiration from Mozilla Firefox, the perl-porters (formerly known
as perl5-porters) will adopt a schedule of a quarterly major release.
</p>

<p>
“Since version 6 of Perl has been claimed by a malevolent project that
amounted to very little, we will release Perl version 7 next Summer, followed
by Perl 8 in next Fall, and Perl 9 next Winter.” said the designated Perl
pumpking.The Perl foundation commented that it is sure that users will
appreciate the accelerated release schedule, despite the fact that a lot
of backwards’ compatibility will be broken in each release to further
the language’s improvement.
</p>

<p>
Some prominent Perl porters have added that they are looking into ways
to automatically upgrade the Perl version automatically upon new
releases, similar to the approach followed by the Google Chrome browser.
“We are tired of people using outdated versions of Perl, which results in
a maintenance burden for us, to say nothing of the security risk by bugs in
old Perl versions. So we think the best way to mitigate that would be to
simply force people to upgrade.”
</p>

<p>
The Perl porters are hard at work on perl-7.0.0, which will implement the
upcoming Perl 7 specification with many new and exciting features and
incompatibilities.
</p>

</blockquote>

<p>
Well, like I said, after discussing this idea with
<a href="http://rjbs.manxome.org/">RJBS</a> (the current Perl 5 Pumpking),
he and I agreed that it would be too cruel, given that many people
are sensitive about upgrading their versions of Perl 5. Comparisons of how
old the perl that your workplace/client/etc. has deployed on their systems
is a common source of discussion among perl mongers (and someone told me
one of his clients still used perl 4), and many people would have found
such an announcement alarming instead of funny. But I hope you enjoyed reading
it, and hope you're also looking forward to perl-5.16.0, which should be out
soon.
</p>

</div>

<div class="entry" id="perl_begin_news_9_July_2002">

<ul class="info">
<li><b>Date:</b> 09-07-2012</li>
<li class="tags">perl, begin, beginners, perl-begin, learn</li>
</ul>

<h1>What’s new on the Perl Beginners’s Site</h1>

<p>
The last update on the news feed for
<a href="http://perl-begin.org/">The Perl Beginners’s site</a> was almost a
year ago. While the site continued to improve, I neglected writing a new
entry until now, so I hope this one will compensate for that.
</p>

<p>
So without further ado, here is what is new:
</p>

<ol>

<li>
<p>
We now have a page about <a href="http://perl-begin.org/humour/">Perl
Humour</a>, which was restored from a page in the now offline perl.net.au
wiki.
</p>
</li>

<li>
<p>
Also originally from that wiki is the <a
href="http://perl-begin.org/FAQs/freenode-perl/">Freenode’s #perl channel
Frequently Asked Questions (FAQ) List</a>, which is well worth a read.
</p>
</li>

<li>
<p>
Another restored page is
<a href="http://perl-begin.org/topics/cpan/wrappers-for-distributions/">the
list of CPAN Wrappers for Distributions</a>.
</p>
</li>

<li>
<p>
We added <a href="http://perl-begin.org/uses/web-automation/">a page</a>
about web automation in Perl, and <a
href="http://perl-begin.org/topics/files-and-directories/">one about
manipulating files and directories</a>.
</p>
</li>

<li>
<p>
The
<a href="http://perl-begin.org/platforms/windows/">Perl on Windows page</a>
was enhanced with new links to Strawberry Perl and DWIM Perl.
</p>
</li>


<li>
<p>
We have a new page about
<a href="http://perl-begin.org/training/">Perl Training Providers</a>, which
currently only contains a link to <a href="http://perltraining.org/">the Perl
Training Directory</a>.
</p>
</li>

<li>
<p>
<a href="http://perl-begin.org/tutorials/bad-elements/">The “Perl
Elements to Avoid” page</a> contains many new entries.
</p>
</li>

<li>
<p>
<a href="http://perl-begin.org/tutorials/modern-perl/">Our mirror of
the book <i>Modern Perl</i> by chromatic</a> was updated to its latest
edition.
</p>
</li>
</ol>

<p>
We hope you find these additions useful or enlightening.
</p>

</div>

<div class="entry" id="App_Notifier_cpan_distributions">

<ul class="info">
<li><b>Date:</b> 22-07-2012</li>
<li class="tags">perl, cpan, dancer</li>
</ul>

<h1>Announcement: the App-Notifier CPAN Distributions</h1>

<p>
I would like to announce two new CPAN distributions of mine:
<a href="https://metacpan.org/release/App-Notifier-Service">App-Notifier-Service</a>
and
<a href="https://metacpan.org/release/App-Notifier-Client">App-Notifier-Client</a>.
These are derived from a few simplistic scripts I've written in shell and
Perl, to allow me to notify when a task has finished (e.g:
<tt>make ; finish-client</tt>) or a certain time has elapsed (e.g:
<tt>sleep 240 ; finish-client</tt>), and I decided to create something
more serious as CPAN modules.
</p>

<p>
App-Notifier-Service implements an HTTP service (using Dancer), which
listens for requests, and once one arrives, implements a callback, which
notifies the user on the localhost that the event occured. App-Notifier-Client
complements it by implementing a client that connects to the service
and sends the event.
</p>

<p>
Currently documentation may be lacking, and there are almost no automated
tests in the distributions, but it appears to work nicely. To get started,
read the documentation and you may wish to peruse some of these files
from my home directory. First of all, the <tt>.app_notifier.yml</tt> file:
</p>

<pre>
commands:
    default:
        - /home/shlomif/bin/desktop-finish-cue
    cookie:
        - /home/shlomif/bin/desktop-finish-cue
        - "--song"
        - "/home/music/Music/dosd-mp3s/Cookie.mp3"
client:
    targets:
        default:
            url: "http://localhost:6300/"
        lap:
            url: "http://lap.shlomifish.org:6300/"

</pre>

<p>
The <tt>desktop-finish-cue</tt> file:
</p>

<pre>
#!/bin/bash

song="/home/music/Music/dosd-mp3s/Theme - Eurovision.mp2"

param="$1"
shift
if test "$param" = "--song"; then
    arg="$1"
    shift
    song="$arg"
fi

xmessage "Your task has been finished! Go check it out." &amp;
mplayer "$song"
</pre>

<p>
And the <tt>finish-server</tt> script:
</p>

<pre>
#!/bin/bash
cd "$HOME"/progs/perl/alert/http-based/hg/App-Notifier-Service &amp;&amp;
    perl ./bin/app.pl --port=6300
</pre>

<hr />

<p>
Otherwise, if you're in the Tel Aviv or vicinity, you are invited to
<a href="http://mail.perl.org.il/pipermail/perl/2012-July/012671.html">the
next Tel Aviv Perl Mongers meeting on Wednesday, 25 July 2012</a>. Otherwise,
I wish to note that I have written my first Java golf program as part
of <a href="http://golf.shinh.org/p.rb?Alphabet+texture+">Anarchy golf’s
“Alphabet Texture” challenge</a> (Anarchy golf accepts challenges in many
languages). At 167 bytes, it is over 3 times longer than the shortest Perl
entry which is only 50 bytes (my Perl solution is 52 bytes). But it
was fun to write. For your information,
<a href="http://en.wikipedia.org/wiki/Code_golf">code golf</a> is a challenge
in which, participating programmers are challenged to write the shortest
program that achieves a certain objective. I find it fun and addictive.
</p>

</div>

<div class="entry" id="tech_tip_packaging_cpan_distributions_in_mageia">

<ul class="info">
<li><b>Date:</b> 16-08-2012</li>
<li class="tags">perl, cpan, tip, tech, tech tip, mageia, linux</li>
</ul>

<h1>Tech Tip: How to Package and Maintain CPAN Distributions in Mageia</h1>

<p>
<a href="http://www.mageia.org/">Mageia Linux</a> is an RPM-based
Linux distribution, whose repositories contain
<a href="http://jquelin.blogspot.co.il/2012/07/more-than-3000-perl-packages-in-mageia.html">over
3,000 CPAN packages</a>, and part of the reason why it has so many is
because Jerome Quelin and the other maintainers have worked on tools to
facilitate creating Mageia packages for CPAN distributions and maintaining
them.
</p>

<p>
However, I was a little confused about using
<a href="https://metacpan.org/release/App-Magpie">magpie</a>, so I'd like
to share my findings here:
</p>

<ol>

<li>
<p>
In order to import, upload and submit a new CPAN package into Mageia,
along with all of its dependencies, one should not use magpie, but rather
<a href="https://metacpan.org/release/App-CPAN2Pkg">cpan2pkg</a>. Its use
is very simple: make <tt>rpm</tt> and <tt>urpmi</tt> sudoable, and type
<tt>cpan2pkg Package::Name</tt> from the command-line inside an X terminal.
This will start a Tk window where one can monitor the progress of preparing
new RPM packages and it has an entry box to create more packages (which
saves time on re-initialising CPAN.pm or CPANPLUS.pm).
</p>
</li>

<li>
<p>
In order to upgrade a package, one can type
<tt>eval $( magpie co -s perl-[PACKAGE_NAME] )</tt> and then
<tt>magpie update</tt>. magpie requires <a href="https://metacpan.org/release/CPAN-Mini">minicpan</a> to be installed and updated.
</p>
</li>

<li>
<p>
In order to install packages, one can do
<tt>sudo urpmi 'perl(Package::Name)'</tt>. My
<a href="https://metacpan.org/release/Module-Format">Module-Format module</a>
facilitates the translation from other notations for writing modules:
</p>

<pre>
up()
{
    sudo urpmi --auto $(perlmf as_rpm_colon "$@")
}
</pre>
</li>
</ol>

</div>

<div class="entry" id="tpf_debugger_grant_and_new_cpan_distributions">

<ul class="info">
<li><b>Date:</b> 01-09-2012</li>
<li class="tags">perl, foundation, tpf, grant, debugger, cpan, ruby</li>
</ul>

<h1>Grant for Improving the Perl Debugger + New CPAN Distributions</h1>

<p>
First of all, I am glad to announce that the Perl Foundation grant
committee has accepted my
<a href="http://news.perlfoundation.org/2012/08/2012q3-grant-proposal-adding-t.html">grant
proposal for adding tests and refactoring the built-in perl debugger</a>.
Here is <a href="http://news.perlfoundation.org/2012/08/2012q3-grant-proposals---resul.html">the announcement</a> for which grant proposals were
accepted. My grant manager for this grant is
<a href="http://alanhaggai.org/">Alan Haggai Alavi</a>, whom I've been
talking with online and have collaborated on a few projects, so I'm really
happy to work with him again.
</p>

<p>
I have already made some progress with the grant (and this post is part
of it), and sent a log for Alan Haggai to post as a grant update.
</p>

<p>
That put aside, I'd now like to publicise some of the new distributions
I have uploaded to CPAN, as I had some ideas for new ones, and am also
contemplating making enough uploads to have 100 CPAN distributions or more:
</p>

<ol>

<li>
<p>
<a href="https://metacpan.org/release/WWW-LinkChecker-Internal">WWW-LinkChecker-Internal</a>
is a distribution wrapping a script that checks for internal broken links. I
released the first three versions of it in a day, and it uses WWW::Mechanize.
The reason why I wrote it was that the WDG HTML validator reported some broken
links in one of my sites, but not their origins, so I had to trace them in
a different way, and ended up writing that.
</p>
</li>

<li>
<p>
<a href="https://metacpan.org/release/Inline-Ruby">Inline-Ruby</a> is
an Inline:: distribution I adopted that allows to embed Ruby code inside
Perl programs. I applied some fixes for it (some of which were not released
to CPAN yet and some are ugly workarounds), and am planning to maintain it
further down the road.
</p>
</li>

<li>
<p>
<a href="https://metacpan.org/release/Test-TrailingSpace">Test-TrailingSpace</a>
is a <tt>Test::</tt> namespace distribution for verifying that your code
does not contain trailing space. Death to trailing space!
</p>
</li>

</ol>

<p>
A final anecdote is that when working on one of my CPAN modules I found the
<tt>b [filename]:[line_num]</tt> feature that I implemented in the perl
debugger to be of great help, and can be content that I'm eating my own
dogfood.
</p>

<p>
Cheers for now.
</p>

</div>

<div class="entry" id="tech_tip_overriding_eumm_compiler">

<ul class="info">
<li><b>Date:</b> 09-09-2012</li>
<li class="tags">tech, tip, tech tip, perl, eumm, compiler, gcc, clang</li>
</ul>

<h1>Tech Tip: Overriding the C compiler with ExtUtils::MakeMaker</h1>

<p>
In order to override the C compiler with ExtUtils::MakeMaker, one can
do something like:
</p>

<pre>
perl Makefile.PL CC=/usr/bin/clang
</pre>

<p>
Which will make the "CC" variable in the generated makefile be set to
<tt>/usr/bin/clang</tt> instead of the default. Apparently, setting the
<tt>CC</tt> environment variable does not work like it does with CMake.
</p>

<p>
Thanks to <a href="http://www.mail-archive.com/makemaker@perl.org/msg03060.html">Sisyphus for the tip</a>.
</p>

</div>

<div class="entry" id="perl_events_should_be_placed_on_lwn.net">

<ul class="info">
<li><b>Date:</b> 18-10-2012</li>
<li class="tags">lwn, lwn.net, events, perl, conferences, yapc</li>
</ul>

<h1>Please Publish Perl Events on the LWN.net Calendar</h1>

<p>
As I read last week’s
<a href="http://lwn.net/Articles/518564/">LWN.net’s Announcement Page</a>
(LWN.net is a news site for open-source-related news, formerly standing
for “Linux Weekly News”),
I noticed that there were few if any Perl events featured in its upcoming
events calendar. However, these events appear in
<a href="http://perlweekly.com/">the Perl Weekly</a>, and there are many
upcoming Python events featured in LWN.net.
</p>

<p>
So, please, if you are organising a Perl-related event (or any other major
open-source event), make sure you put it on
<a href="http://lwn.net/Calendar/">the LWN.net calendar</a>.
</p>

</div>

<div class="entry" id="three_command_line_utilities">

<ul class="info">
<li><b>Date:</b> 14-11-2012</li>
<li class="tags">cpan, perl, command, line, cli, bash, gnu, parallel, sleep</li>
</ul>

<h1>Three Command-Line Utilities</h1>

<p>
So, November is
<a href="http://en.wikipedia.org/wiki/National_Novel_Writing_Month">NaNoWriMo</a> (“National Novel Writing Month”), and I was hoping to get some serious
writing done (instead of coding), but I kept being distracted with coding
and random writing in various Internet forums. Well, hopefully this blog
post will compensate a little for that.
</p>

<p>
In this post, I’d like to cover three command-line utilities - two of them
new and were written by me, and one of them somewhat older, but also written
in Perl.
</p>

<p>
The first utility is
<a href="http://en.wikipedia.org/wiki/GNU_parallel">GNU Parallel</a>, which
allows one to run several command-line jobs in parallel, using forking and/or
ssh remote logins. I used it to speed up some processing I've been doing on
my computer. For more information and some examples of usage, see
<a href="http://zgp.org/pipermail/linux-elitists/2012-November/013428.html">my
post about it to the linux-elitists mailing list</a>, and also read
<a href="http://zgp.org/pipermail/linux-elitists/2012-November/013429.html">Thomas
Sattler’s response</a> which provides some further insights.
</p>

<p>
The second utility is
<a href="http://www.shlomifish.org/open-source/projects/countdown/">countdown</a>, which is
similar to the UNIX command-line sleep command, but displays the remaining
time on the console. I wrote a prototype for it in Perl 6, only to discover it
consumed far too many resources. The second prototype, as a Perl 5 program
consumed close to zero resources of my computer. Yesterday, I converted it to
a modulino (a Perl application implemented as a module) and uploaded
several versions to the CPAN.
</p>

<p>
The third utility is something I have placed in my
<tt>~/.bashrc</tt> file in order to implement reminders when the shell
starts. The code for it is:
</p>

<pre>
reminder_file="$HOME/.local/share/shlomif/reminder/reminder.txt"
if [ -s "$reminder_file" ] ; then
    perl -Mstrict -Mwarnings -MTerm::ANSIColor -E 'my $x = colored("===", "bold red"); say "$x Reminders $x"'
    cat "$reminder_file"
fi

Cancel_reminder()
{
    rm "$reminder_file"
}
</pre>

<p>
I wrote it because I wasn't prompted in time by Thunderbird+Lightning
due to a strange bug, and because I had to ditch KOrganizer because it
consumed too many resources here. This displays the Reminders whenever you
start a new shell, which happens quite often with me, so it's OK. I use
cron jobs to append stuff into "$reminder_file", and the Perl code displays
a header in colour.
</p>

<p>
That’s it for today.
<a href="https://metacpan.org/release/App-Countdown">App-Countdown</a> is one
step closer for the count-up (pun intended) towards the coveted 100
distributions under “SHLOMIF” on CPAN, so that's another plus.
</p>

</div>

<div class="entry" id="countup100_dec2012">

<ul class="info">
<li><b>Date:</b> 06-12-2012</li>
<li class="tags">cpan, perl, xml, 100, hacktivity, hacktivity log, javascript, llvm</li>
</ul>

<h1>Count-up to 100 CPAN Distributions: Test-XML-Ordered, SDLx-Betweener, and more</h1>

<p>
Well, it's no longer a secret that I’m craving to join the “100 CPAN
Distributions Club” by releasing some code that is hopefully not too useless.
Here I would like to blog about the two new additions to
<a href="http://metacpan.org/author/SHLOMIF">my CPAN page</a> which are
the 83rd and 84th distributions respectively. The story is a bit more
complicated than that.
</p>

<p>
The first upload is
<a href="https://metacpan.org/release/SDLx-Betweener">SDLx-Betweener</a>,
which allows for creating high-performance and smooth animations in SDL
by making use of Perl/XS. Almost all of the coding (and a related
YAPC::Israel talk) was done by
<a href="http://metacpan.org/author/EILARA">Ran Eilam</a>, who is a very
cool guy, a good friend and a former boss of mine, and I've just done
(with his permission) some last-minute cleanups and did the initial upload
to CPAN. So I kinda feel like the frog that sat on top of the elephant
who crossed the river and said “We did it!”.
</p>

<p>
However, I needed SDLx::Betweener
for something I've been intending to work on, and wanted it on CPAN
and packaged in Mageia Linux, so I did that. If you run into any problems
with it, drop me a note or file a bug report, and hopefully I can resolve
these problems (possibly with some help from Ran).
</p>

<p>
The next distribution is original, but its story is more complicated.
It all started when I decided to resume work on Qantor, which aims
to eventually be a modern and saner alternative to TeX/LaTeX and Troff
(although it is still extremely far from that now). I noticed that the parsing
was still done by Regexp::Grammars, and so decided to convert it into
<a href="https://metacpan.org/module/Parser::MGC">Parser::MGC</a>.
Parser::MGC worked eventually and I was impressed from the straightforward
way to do stuff with it, but it was time consuming to get there (like most
other parser generators I tried, only a bit better), and involved writing
some Moose 'around' code to debug the method calls, and also sometimes delving
into the code. Parser::MGC is still not perfect (and some of the code I read
there had gems like
<tt>die $e if $committed or
not eval { $e-&gt;isa( "Parser::MGC::Failure" ) };</tt> which I found hard
to parse, and made me want to drown a kitten), but I think it sucks less
and is more transparent than other parser generators I tried.
</p>

<p>
Anyway, after I got it working, I noticed that the Test::XML::Ordered code
(then still unreleased), generated a some memory problems and I suspected
either XML::LibXML or libxml2 to be the culprit. This involved a long
investigation process with valgrind, gdb, <tt>perl -d</tt> and other tools
which culminated in a very small change and more lines of test code. This
was released in XML::LibXML. After that I received a report that the tests
got stuck, but that turned out to be due to external loading of DTDs and
was easily fixed. There's another
<a href="https://rt.cpan.org/Ticket/Display.html?id=81739">report</a> for
a problem with perl-5.8.8 (ouch!) on Red Hat Enterprise Linux (ouch again!),
but I'm not too motivated to do a lot about it (see
<a href="http://www.shlomifish.org/humour/fortunes/show.cgi?id=hamakor-discs-mozilla-1.1-1">this fortune cookie</a>).
</p>

<p>
Well, after I fixed the problem with XML::LibXML, I decided to release
Test::XML::Ordered. I'm well aware of
<a href="https://metacpan.org/module/Test::XML">Test::XML</a>, but found
it hard to rely on it, because it uses
<a href="https://metacpan.org/module/XML::SemanticDiff">XML::SemanticDiff</a>
(the latter I adopted) and which attempts to rearrange the order of the
nodes when it sees fit (so
<tt>&lt;ul&gt;&lt;li&gt;One&lt;/li&gt;&lt;li&gt;Two&lt;/li&gt;&lt;/ul&gt;</tt>
and
<tt>&lt;ul&gt;&lt;li&gt;Two&lt;/li&gt;&lt;li&gt;One&lt;/li&gt;&lt;/ul&gt;</tt>
may be considered the same), which was not what I want and not what other
people who contacted me about XML::SemanticDiff wanted.
</p>

<p>
After Test::XML::Ordered, I decided it would be a good idea to finally
work on the release of <tt>XML::GrammarBase</tt> which aims to provide
“base classes and roles” for facilitating creating XML validators
and processors. Work on it was pretty straightforward after I had
Test::XML::Ordered available, but required some refactoring the classes
from using <tt>Any::Moose</tt> to using <tt>Moo</tt> per advice of the
people on <tt>#moose</tt>, and I have yet to convert the XSLT role into
a parameterised role.
</p>

<p>
I have some other code I'd like to release on CPAN after all that.
</p>
<hr />

<p>
Another related hacktivity was a set of patches to the core Vim that I've
written to improve support for DocBook 5. Since I wanted to maintain
compatibility with DocBook 4 documents (because DocBook 4 is still popular),
this involved writing a Perl, Bash and Python Amalgam to generate the
Vim code in question with a list of common, DocBook 4-only and DocBook 5-only
tags. You can find it in
<a href="http://bitbucket.org/shlomif/vim-docbook-5-support">its BitBucket
repository</a>. It is very hacky, but it works. Using the Python code
gave me an idea for a missing XML::LibXML feature - DTD introspection - which
I'd like to implement in the future.
</p>

<p>
Well, that's all for now - just wanted to get it out of my system. Enjoy the
holidays, and Cheers!
</p>

<!-- TODO : Python+bash+perl amalgam to generate Vimscript code. -->
</div>

<div class="entry" id="countup100_jan2013">

<ul class="info">
<li><b>Date:</b> 07-01-2013</li>
<li class="tags">cpan, perl, sdlx, xml, 100, hacktivity, hacktivity log</li>
</ul>

<h1>Count-up to 100 CPAN Distributions: Quality *as well as* Quantity</h1>

<p>
Going over the previous count-ups to 100 CPAN distributions in this
blog, I feel I have been carried away: I tried to release a lot
of new distributions to the CPAN, while neglecting all the existing
distributions I have, and not tending to their pending problems and their
lack of <b>software quality</b> in several aspects (See
<a href="http://www.shlomifish.org/philosophy/computers/high-quality-software/rev2/">an
older essay I have written about it</a>).
</p>

<p>
I was reminded of it when
working on a few new or existing distributions using
<a href="http://dzil.org/">Dist-Zilla</a>, I ran into a few places where some
of its plugins or features were underdocumented, and non-exemplified (in
the SYNOPSIS sections or wherever), which consumed many hours of my time, some
times made me need to read or grep the code, and made me frustrated. I sent
the maintainers some pull requests for
better documenting this - and some of them were applied - but still, it would
have been preferable, for them to be properly documented and exemplified
in the first place.
</p>

<p>
While I believe most of my CPAN distributions are in better condition, there
are some aspects that are lacking, and I would like to fix them: more examples
outside the SYNOPSES, and better SYNOPSES; documenting all methods of the
super classes as well as the classes themselves for
<a href="http://metacpan.org/release/XML-LibXML">XML-LibXML</a>; adding
support for DTD introspection and the oft requested
<a href="http://code.activestate.com/lists/perl-xml/8953/">DOM elements
annotations</a> for it; more
<a href="http://cpants.cpanauthors.org/kwalitee.html">kwalitee</a>; etc. and
naturally also better publicity and advertising
(<a href="http://freecode.com/">Freecode.com</a> (formerly known
as Freshmeat.net), Reddit, blogs.perl.org, video screencasts, etc.) because
people should see how cool your code is. I’m
not sure if any of these things would be as blog worthy as new
CPAN distributions, but it will make CPAN a bit better.
</p>

<p>
(Now that I think of it, perhaps a CPAN janitors initiative, which will
submit pull requests and patches for existing distributions to improve
their quality will be a good idea.)
</p>

<p>
Anyway, I am going to split this report into sections:
</p>

<h2>XML-GrammarBase</h2>

<p>
After some work (and misunderstanding of some of the Moo / MooX
documentation, which resulted in some pull requests), I released
<a href="http://www.shlomifish.org/open-source/projects/XML-Grammar/Base/">XML-GrammarBase</a>
which aims provides roles and base classes for easily writing wrappers around
XML schema formats and XML translation languages. So far only RELAXNG and
XSLT are supported. Here is the synopsis from the docs:
</p>

<pre>
package XML::Grammar::MyGrammar::ToOtherStuff;

use MooX 'late';

use XML::GrammarBase::Role::RelaxNG;
use XML::GrammarBase::Role::XSLT;

with ('XML::GrammarBase::Role::RelaxNG');
with XSLT(output_format =&gt; 'html');
with XSLT(output_format =&gt; 'docbook');

has '+module_base' =&gt; (default =&gt; 'XML-Grammar-MyGrammar');
has '+rng_schema_basename' =&gt; (default =&gt; 'my-grammar.rng');

has '+to_html_xslt_transform_basename' =&gt; (default =&gt; 'mygrammar-xml-to-html.xslt');
has '+to_docbook_xslt_transform_basename' =&gt; (default =&gt; 'mygrammar-xml-to-docbook.xslt');

package main;

my $xslt = XML::Grammar::MyGrammar::ToOtherStuff-&gt;new(
    data_dir =&gt; "/path/to/data-dir",
);

# Throws an exception on failure.
my $as_html = $xslt-&gt;perform_xslt_translation(
    {
        output_format =&gt; 'html'
        source =&gt; {file =&gt; $input_filename, },
        output =&gt; "string",
    }
);
</pre>

<p>
perform_xslt_translation supports a myriad of options and formats, and you
get it all for free.
</p>

<p>
I've also been contemplating something like
<code>App::XML::GrammarBase</code>
or <code>XML::GrammarBase::App</code> that will allow for easy registry
of such formats from the command line and for processing them.
</p>

<p>
At first, I believed that Moo was “almost-completely-unlike-Moose”, but
«use MooX 'late';» makes it much more Moose-like and I enjoy it, and it is
now recommended over Any::Moose or maybe even plain Mouse. Mouse is very
fast as well and has a far smaller startup time than Moose, but it does not
interoperate very well with pure-Moose classes, which Moo does
well.
</p>

<h2>HTML-Widgets-NavMenu-ToJSON</h2>

<p>
As I was working on <a href="http://www.shlomifish.org/">my homepage</a>, I
noticed that after I placed all the sub-navigation menus inside the main
navigation menu, it increased the size of the navigation menu considerably,
having it consume over 40,000 bytes. I decided to put only a subset of it
as HTML, and load and populate the rest using an AJAX call to a common
and static .json file. So I needed a way to convert the input of
<a href="https://metacpan.org/release/HTML-Widgets-NavMenu">HTML-Widgets-NavMenu</a>
</p>

<p>
So enter
<a href="https://metacpan.org/module/HTML::Widgets::NavMenu::ToJSON">HTML::Widgets::NavMenu::ToJSON</a>,
which serialises a navigation menu structure as JSON. I also implemented a
persistence layer for it, currently with only one backend - a YAML file,
so the IDs which jqTree require would be, well, persisted. This is a bit of
an <a href="http://www.joelonsoftware.com/articles/fog0000000018.html">architecture
astronautics</a>, but I ended up with something concrete at the end so it's
under control.
</p>

<p>
Here is the synopsis:
</p>

<pre>
use HTML::Widgets::NavMenu::ToJSON;
use HTML::Widgets::NavMenu::ToJSON::Data_Persistence::YAML;

my $persistence =
    HTML::Widgets::NavMenu::ToJSON::Data_Persistence::YAML-&gt;new(
        {
            filename =&gt; &#39;/path/to/persistence_data.yaml&#39;,
        }
    );

my $obj = HTML::Widgets::NavMenu::ToJSON-&gt;new(
    {
        data_persistence_store =&gt; $persistence,
        # The one given as input to HTML::Widgets::NavMenu
        tree_contents =&gt; $tree_contents,
    }
);

use IO::All;

io-&gt;file(&#39;output.json&#39;)-&gt;println(
    $obj-&gt;output_as_json(
        {
            %args
        }
    )
);
</pre>

<p>
It could be made a bit simpler using an abstraction, but I feel it's not
too bad. You can write custom
<a href="http://metacpan.org/module/HTML::Widgets::NavMenu::ToJSON::Data_Persistence">HTML::Widgets::NavMenu::ToJSON::Data_Persistence</a>
child classes by implementing the <code>load()</code>
and <code>save()</code> methods - I did not document the process yet,
but you can base your efforts on
<a href="http://metacpan.org/module/HTML::Widgets::NavMenu::ToJSON::Data_Persistence::YAML">HTML::Widgets::NavMenu::ToJSON::Data_Persistence::YAML</a>.
</p>

<h2>Dist-Zilla-Plugin-TestRun</h2>

<p>
Since I'm used to running <kbd>./Build runtest</kbd> instead of
<kbd>./Build test</kbd> for my distributions, I sought a way of doing the
same using Dist-Zilla. It turned out there wasn't an easy way, and
<a href="http://metacpan.org/release/Dist-Zilla-Plugin-TestRun">Dist-Zilla-Plugin-TestRun</a>
is the best I could do. I hope to write a patch to make the <kbd>test</kbd>
command more configurable.
</p>

<h2>Test-XML-Ordered</h2>

<p>
<a href="http://metacpan.org/module/Test::XML::Ordered">Test::XML::Ordered</a>
makes a non-“semantic” diff of XML files and tells you if they are
equivalent (up to differences of whitespace and namespace prefixes). It grew
out of my frustration with
<a href="http://metacpan.org/module/XML::SemanticDiff">XML::SemanticDiff</a>,
upon which Test::XML is based, and which I maintain. A quick CPAN search
revealed other modules for testing XML in a similar manner, but since I have
already written my code, I decided to release it.
</p>

<p>
One tip is that with the current API, one should use something like:
</p>

<pre>
my @common = (validation =&gt; 0, load_ext_dtd =&gt; 0, no_network =&gt; 1);

is_xml_ordered (
    [ string =&gt; normalize_xml($results_buffer), @common, ],
    [ location =&gt; "./t/data/xhtml-results/$fn_base.xhtml", @common, ],
    "Testing for Good XSLTing of '$fn_base'",
);
</pre>

<p>
In order to test XHTML documents for equivalency.
</p>

<h2>Vered-XML</h2>

<p>
I thought that Vered-XML (currently only available in the
<a href="http://bitbucket.org/shlomif/perl-begin">Perl Beginners’ Site’s
repository</a> was probably the most ad-hoc and tailored to match
XML grammar I have ever created, and was used to convert the markup of
<a href="http://perl-begin.org/tutorials/bad-elements/">the “Perl Elements
to Avoid” page</a> from hacky Website META Language markup to XML, so it
will be easier to translate to different (human) languages and also somewhat
easier to maintain and render. Currently it renders to DocBook/XML, which
allows translation to many other formats.
</p>

<p>
So why did I call it Vered? Since it was so ad-hoc, and I didn't know what
else it would be useful for, I wanted to give it an artsy name, and considered
using a random Hebrew feminine name. Then I thought that “a rose by any other
name would smell as sweer”, and thought of calling it Rose, but translated
to Hebrew it was “Vered”, which is also a Hebrew feminine name. I still have
to tie up some loose ends, but expect XML-Grammar-Vered at a CPAN mirror
near you Real Soon Now™.
</p>

<p>
Vered-XML supports a subset of XHTML, as well as some specialised tags such
as <code>&lt;pdoc /&gt;</code> (perldoc),
<code>&lt;pdoc_f /&gt;</code> (perldoc -f),
<code>&lt;cpan_self_mod /&gt;</code> (CPAN self link to module), etc. and
contains a RELAX NG schema and an xsltproc/libxslt2-compatible
XSLT 1.0 stylesheet. Here is an excerpt from
<a href="http://bitbucket.org/shlomif/perl-begin/src/d183a648b865a223c353b16664e05b6046bd478d/src/tutorials/bad-elements/perl-elements-to-avoid.xml-grammar-vered.xml?at=default">the “Perl Elements to Avoid” source XML</a>:
</p>

<pre>
&lt;item xml:id=&quot;slurp&quot;&gt;
&lt;info&gt;
&lt;title&gt;Slurping a file (i.e: Reading it all into memory)&lt;/title&gt;
&lt;/info&gt;
&lt;p&gt;
One can see several bad ways to read a file into memory in Perl. Among them
are:
&lt;/p&gt;
&lt;code_blk syntax=&quot;perl&quot;&gt;
# Not portable and suffers from possible
# shell code injection.
my $contents = `cat $filename`;
# Wasteful of CPU and memory:
my $contents = join(&quot;&quot;, &amp;lt;$fh&amp;gt;);
# Even more so:
my $contents = &#39;&#39;;
while (my $line = &amp;lt;$fh&amp;gt;)
{
    $contents .= $line;
}
&lt;/code_blk&gt;
&lt;p&gt;
You should avoid them all. Instead the proper way to read an entire file
into a long string is to either use CPAN distributions for that such as
&lt;cpan_self_dist d=&quot;File-Slurp&quot; /&gt; or
&lt;cpan_self_dist d=&quot;IO-All&quot; /&gt;, or alternatively
write down the following function and use it:
&lt;/p&gt;
&lt;code_blk syntax=&quot;perl&quot;&gt;
sub _slurp
{
    my $filename = shift;
    open my $in, &#39;&amp;lt;&#39;, $filename
        or die &quot;Cannot open &#39;$filename&#39; for slurping - $!&quot;;
    local $/;
    my $contents = &amp;lt;$in&amp;gt;;
    close($in);
    return $contents;
}
&lt;/code_blk&gt;
&lt;/item&gt;
</pre>

<p>
I'm not sure if Vered-XML will have much utility outside that use case, but
I think that putting it on CPAN won't hurt much.
</p>

<h2>Improving perlresume.org</h2>

<p>
I filed a few issues and sent some pull requests for
<a href="http://perlresume.org/">perlresume.org</a> for some problems
I ran into, and <a href="http://showmetheco.de/">vti</a> fixed or
applied them promptly. Thanks!
</p>

<h2>Beginners’ Sites</h2>

<p>
I invested more work into <a href="http://perl-begin.org/">the Perl Beginners’
site</a>
and also, after some encouragement from the good people on
<a href="irc://irc.freenode.net/#vim">#vim</a> began work on
<a href="http://vim.begin-site.org/">the Vim Beginners’s site</a>, which
I publicised on <a href="http://shlomif-tech.livejournal.com/65619.html">my
tech blog</a>,
on <a href="http://www.reddit.com/r/vim/comments/15o6v1/announcing_the_vim_beginners_site/">Reddit</a>,
and on some mailing lists. While in the past I used my own
<a href="http://web-cpan.shlomifish.org/latemp/">static site
generator called “Latemp”</a> based on Website Meta Language for sites
like that,
I used Jekyll this time, at least for the first prototype. I did so
in order to evaluate it for use in a different site
(<a href="http://www.linux.org.il/">The
Israeli Linux Portal</a> which is currently implemented using an awkward
custom PHP-based system, that mostly just reads stuff out of XML data
files and outputs a constant static HTML as XSLT.). While at first I was
impressed with Jekyll,
I then realised that it was quite opaque, often required many plugins to
get some basic functionality and that one plugin I looked at lacked examples
and was otherwise under documented.
</p>

<p>
There is <a href="http://iwantmyname.com/blog/2011/02/list-static-website-generators.html">a
list of many more static site generators / offline content-management
systems</a> around (which does not include my own Latemp), and it may be
easier to roll up something on my own based on Template Toolkit or its ttree.
All this just confirms my
(and <a href="http://blogs.perl.org/users/su-shee/">Su-Shee</a>’s) suspicion
that every self-respecting web programmer has written at least one.
</p>

<h2>Freecell Solver for JavaScript - ☺</h2>

<p>
I have been distracted for many hours trying to port Freecell Solver
to JavaScript using the very cool
<a href="https://github.com/kripken/emscripten">Emscripten</a> LLVM bitcode
to JavaScript compiler.
The <a href="http://fc-solve.shlomifish.org/js-fc-solve/text/">mostly
final result</a> could still use some work, and is still under optimised (in
large part due to what appear to be an Emscripten bug) but it's working.
</p>

<p>
The <a href="https://github.com/kripken/emscripten/wiki">Emscripten
wiki</a> contains links to many, much more impressive, demos including
<a href="http://kripken.github.com/meandmyshadow.web/mams.html">a
JavaScript version of the open-source graphical game “Me and My Shadow”</a>.
</p>

<h2>Two Anecdotes from ##programming</h2>

<p>
I enjoy chatting on
<a href="irc://irc.freenode.org/##programming">##programming (on Freenode)</a>
and along with all the rants about how much every popular programming langauge
in existence sucks, and trying to help various students with their often
badly indented and badly formatted homework code, there are often some
insightful discussions by some smart people. I’d like to share two Perl-related
anecdotes from there.
</p>

<p>
The first one was that someone there who has taken studying programming, before
starting to study in university, seriously, and also read the Camel book
and other books and resources about Perl, asked me to look at my code
to see how readable it is. I referred him to the
<a href="https://metacpan.org/source/SHLOMIF/HTML-Widgets-NavMenu-1.0701/lib/HTML/Widgets/NavMenu.pm">source
code</a> of HTML::Widgets::NavMenu, which will being an early code of
mine (and still not fully modernised), was written in a modular manner, and he
said he found it to be well-factored and yet very readable . He noted that he
suspected that Perl would be less believed to “hard to understand” or
“unreadable”, if it sandardised on using my preferred style -
<a href="http://en.wikipedia.org/wiki/Indent_style#Allman_style">Allman
style</a> - instead of its default style with the opening braces on the
same line as the opening clause (e.g: <tt>if ( COND ) {</tt>).
</p>

<p>
The other anecdote was that someone else there, who is working in Visual
Basic and Visual Basic for Applications for a living (for lack of good
alternative for software development job prospects in his homeland), told us
that he found the CPAN documentation to usually be superior than the MSDN
(Microsoft Developers Network) one.
I found it a little strange, because I recall finding the MSDN documentation
to give detailed examples for almost every subroutine and a page of prose and
explanation for each one, and reportedly large parts of it were also
translated into some non-English languages by Microsoft. Then I showed him
the “SYNOPSIS” sections of some of the .pm files in CPAN and he was
even more impressed and said it was useful (because you can copy+paste it and
tweak it), but naturally commented that not all .pm files had those.
</p>

<h2>Conclusion</h2>

<p>
I currently stand at <a href="http://perlresume.org/SHLOMIF">87 CPAN
distributions</a>, some of which a bit lacking, and I still have some in the
pipe. One of them will require quite a lot of cleanup work to do, but it's
not a high priority. I also have to juggle some other endeavours, and also
recently started contracting for an Internet friend as a Drupal developer
(and in the future possibly one for Moodle as well), which may consume even
more of my time (but on the bright side pay a little money). It’s no secret
that I am not a big fan of PHP, but Drupal seems impressive so far, and
hides away a lot of PHP’s ugliness. It took me some time to get acquainted
with it, so I hope now things will be smoother and easier to do. It seems that
there's quite a bit of demand for converting sites into Drupal, setting up new
sites, or maintaining them in Israel (and possibly elsewhere as well) so it
is probably a useful skill to have under my belt.
</p>

<p>
Hope you enjoyed this hacktivity log, and see you next time. Byeeeee!
</p>

</div>

</body>
</html>