perl

Python slow read performance issue

Python slow read performance issue Question: Following an earlier thread I boiled down my problem to it’s bare bones, in migrating from a Perl script to a Python one I found a huge performance issue with slurping files in Python. Running this on Ubuntu Server. NB: this is not a X vs. Y thread I …

Total answers: 1

Behavior of python method in absence of return statement

Behavior of python method in absence of return statement Question: I have a question related to change in program behavior the absence of return statement leads to in a python method. The count method below prints number of digits in a given integer. With the below chunk of code I get the result as 4, …

Total answers: 4

Regular expression for a JIRA identifier

Regular expression for a JIRA identifier Question: I’m trying to extract a JIRA identifier from a line of text. JIRA identifiers are of the form [A-Z]+-[0-9] – I have the following pattern: foreach my $line ( @textBlock ) { my ( $id ) = ( $line =~ /[s|]?([A-Z]+-[0-9]+)[s:|]?/ ); push @jiraIDs, $id if ( defined …

Total answers: 4

Simple file server to serve current directory

Simple file server to serve current directory Question: I’m looking for a dead simple bin that I can launch up in the shell and have it serve the current directory (preferably not ..), with maybe a -p for specifying port. As it should be a development server, it should by default allow connections from localhost …

Total answers: 4

Does python have a "use strict;" and "use warnings;" like in perl?

Does python have a "use strict;" and "use warnings;" like in perl? Question: I am learning perl and python… at the same time, not my by design but it has to be done. Question: In a perl script I use(see below) at the head of my txt. #!/usr/bin/env perl use strict; use warnings; Is there …

Total answers: 6

Extracting data from HTML table

Extracting data from HTML table Question: I am looking for a way to get certain info from HTML in linux shell environment. This is bit that I’m interested in : <table class=”details” border=”0″ cellpadding=”5″ cellspacing=”2″ width=”95%”> <tr valign=”top”> <th>Tests</th> <th>Failures</th> <th>Success Rate</th> <th>Average Time</th> <th>Min Time</th> <th>Max Time</th> </tr> <tr valign=”top” class=”Failure”> <td>103</td> <td>24</td> <td>76.70%</td> …

Total answers: 7

Variable-length lookbehind-assertion alternatives for regular expressions

Variable-length lookbehind-assertion alternatives for regular expressions Question: Is there an implementation of regular expressions in Python/PHP/JavaScript that supports variable-length lookbehind-assertion? /(?<!foo.*)bar/ How can I write a regular expression that has the same meaning, but uses no lookbehind-assertion? Is there a chance that this type of assertion will be implemented some day? Things are much better …

Total answers: 5

Seeking clarification on apparent contradictions regarding weakly typed languages

Seeking clarification on apparent contradictions regarding weakly typed languages Question: I think I understand strong typing, but every time I look for examples for what is weak typing I end up finding examples of programming languages that simply coerce/convert types automatically. For instance, in this article named Typing: Strong vs. Weak, Static vs. Dynamic says …

Total answers: 9

Regexp finding longest common prefix of two strings

Regexp finding longest common prefix of two strings Question: Is there a regexp which would find longest common prefix of two strings? And if this is not solvable by one regexp, what would be the most elegant piece of code or oneliner using regexp (perl, ruby, python, anything). PS: I can do this easily programatically, …

Total answers: 15

Converting to and from Hindu calendar

Converting to and from Hindu calendar Question: How can I convert unix time to Hindu calendar­Wikipedia time and the other way round in php, Perl or Python or Java? I know I can convert to Hebrew and Jewish. But Hindu is not an option. To be more specific, I’m talking about the Hindu lunar calendar. …

Total answers: 5