Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

The Monastery Gates

( #131=superdoc: print w/ replies, xml ) Need Help??

Donations gladly accepted

If you're new here please read PerlMonks FAQ
and Create a new user.

New Questions
Can I re-use modules compiled with a different build of Perl, but with the same version number on the same machine?
4 direct replies — Read more / Contribute
by neuty
on Jan 30, 2015 at 14:47

    My department's production servers (RHEL5) have no access to the Internet or any CPAN repository. Therefore, when we need to use a specific Perl module with our scripts, we download them to our terminals from the CPAN website, scp them over to our dev machines, untar them, and then build them locally. We then distribute them to a shared network file system so that other developers may use them, and so that they are available on the prod machines as well. In this way we build a library of Perl modules that slowly grows over time. Our current set of modules were built using my system Perl, which /usr/bin/perl -V lists as revision 5 version 10 subversion 1.

    However, we're interested in building a separate copy of Perl that we can also upload to the networked file system. This way we are not tied to using each of our machines' system Perl, which can change from machine to machine (and is frequently 5.8.8, which is outdated for a few necessary modules). A sort of "central" Perl that can be standard across each machine.

    Therefore, I needed to build a local copy of Perl in my home directory. I made sure to install the same version as my system Perl, perl-5.10.1. I did this using the following Configure followed by a simple make,make test, make install:

    ./Configure -des -Dprefix=/home/myuser/localperl -Duserelocatableinc

    -Dprefix installed it to the folder localperl in my home directory, while the -Duserelocatableinc flag made it so the @INC would change if the folder was moved (ie., uploaded to the networked file system).

    The issue comes when I try to test it out with one of my scripts that requires a module from our library of manually built Perl modules. I keep getting the following error:

    /home/myuser/localperl/bin/perl: symbol lookup error: .../auto/DBI/ undefined symbol: Perl_Istack_sp_ptr

    Obviously my script uses the shared DBI module but is running into errors. From doing research on the Internet, people have said that I would need to recompile the modules using the new build of Perl.

    However, the two Perls are the same version and were built on the same machine. I have tried to rebuild the local Perl using the Configure settings as close to the machine Perl as possible to try to see if that would work:


    So far this has not stopped the error. My system Perl actually used many more Configure options, but since I was so unfamiliar with them, I didn't throw them into the local Perl build for obvious precautionary reasons.

    First, can someone help me get a better understanding of what is preventing these modules from working with my locally built Perl? It makes sense that modules would not work under different versions of Perl, but it surprises me that it doesn't work with the same version built on the same machine. It also does not make sense to me that a module would lock itself info a specific Perl build like a "license" type scenario, so my intuition is that the module is incompatible with some unseen setting/library that the local Perl is built under.

    Second, is there a way to get my locally built Perl to work with the modules compiled with the system Perl, or will I have to recompile them all and redistribute a fresh set of modules?

    Thank you for any and all help! I have tried Googling the answer, but any issues dealing with this only bring up different Perl versions, which is not the situation I am currently facing.

Using threads to process multiple files
4 direct replies — Read more / Contribute
by anli_
on Jan 30, 2015 at 11:36
    Hey. I'm trying to get the feel for how multithreading works with perl in an effort to try to speed up my scripts. My test case is that I want to parse two relatively large files and place all the lines from each file into separate hashes. Normally I would just go over them one by one with a while loop and populate my hashes that way. Like so.
    open IN, '<', $ARGV[0]; my %hash1; while (<IN>) { next unless ( $_ =~ m/^\@HWI/ ); my ($header) = split(/ /, $_); $hash1{$header} = 1; } close IN; open IN2, '<', $ARGV[1]; my %hash2; while (<IN2>) { next unless ( $_ =~ m/^\@HWI/ ); my ($header) = split(/ /, $_); $hash2{$header} = 1; } close IN;
    Instead I thought I'd try doing both files at once. Like so:
    my @threads = ("1","2"); # Loop through the array: foreach(@threads){ # Tell each thread to perform our 'parseLines()' subroutine. $_ = threads->create(\&parseLines, shift(@ARGV)); } #Tries to join the running threads #Some check implemented to avoid quitting the loop, before everything +is joined my @running = threads->list(threads::running); #Array of running threa +ds my @joinable = threads->list(threads::joinable); #Array of joinable th +reads my @catcher; while (scalar(@running) != 0 || scalar(@joinable) > 0) { #While as lon +g as there are running or joinable threads @running = threads->list(threads::running); #Repopulate running, n +ot sure if needed. foreach(@threads){ if ($_->is_joinable()) { push(@catcher, $_->join()); #Put's parsed file as hash-ref int +o array } } @joinable = threads->list(threads::joinable); @running = threads->list(threads::running); } sub parseLines{ open IN, '<', $_[0]; my %hash; while (<IN>) { next unless ( $_ =~ m/^\@HWI/ ); my ($header) = split(/ /, $_); $hash{$header} = 1; } close IN; return \%hash; }
    While the multithreaded code works, it's about 50% slower than the first one, so nothing is really accomplished there. It seems to me that maybe the problem is that the threads take a long time passing the created hashes back to the main script. So it's shuffling things around in memory, but I'm on really thin ice here I must admit. Any input is appreciated.
SessionID on a windows server
4 direct replies — Read more / Contribute
by mwhiting
on Jan 29, 2015 at 13:51

    Hi - I have a script that runs on both windows and linux servers. On windows, I use perl2exe to compile it, though I don't think that is the source of the problem here.

    The script uses CGI::Session for Session id's for the purposes of keeping a password from one session to the next. With a Linux/unix server, if you are logged in successfully, and later copy and paste the url from your browser (which contains a parameter with the Session id) into an email and send it to another computer, the second computer doesn't recognize the session id as valid for itself and re-prompts for password (as it should do).

    It would be an url similar to this:

    But on a windows server the same action doesn't result in getting prompted for a password. The server will recognize the sessionID and just continue on as normal, even though noone has ever entered a password on this second pc before.

    Any insights as to why this would be?

Performance comparison Apache/FastCGI/Plack vs Apache/FCGI vs Plack standalone vs Apache/mod_perl (was "New version of Mod_perl")
2 direct replies — Read more / Contribute
by adamarc
on Jan 29, 2015 at 11:02
    thank you stonecolddevin & sundialsvc4.
    You inspired me to look at other options, and I decided to load test all of them with a simple script that connects to a MySQL database to select some UTF8 data, and return it.
    I did the test twice. I included a big Perl module (~650KB) in the second test to check if the compilation phase makes sense.
    All of the configurations properly returned the UTF8 text.
    I did the test on an 8-core Intel 3770 with 16GB of RAM (which was not a bottleneck). OS: FreeBSD 10.0.

    I'm curious to hear about what your opinion is of the below results. I find the number of Apache 2.4/FCGI too good to be true, but could not find any errors. Maybe somebody can replicate the test?

    100 concurrent requests with ~10KB script: Requests Correct Requests Error AVG_msec Apache 2.4/FCGI 202510 0 14 Apache 2.4/FastCGI/Plack 25584 0 116 Plack standalone 17012 0 175 Apache 2.2/mod_perl 1828 1128 185 100 concurrent requests with ~650KB script: Requests Correct Requests Error AVG_msec Apache 2.4/FCGI 55697 0 52 Apache 2.4/FastCGI/Plack 13971 0 213 Plack standalone 13042 0 228 Apache 2.5/mod_perl 1689 0 217

    See here the used scripts, and configuration.

    Apache/FCGI script

    Apache/FastCGI/Plack script
    Plack standalone: the same script as Apache/FastCGI/Plack
    The command that I used to run it: perl ./fcgiplack.fcgi &> fcgiplack.log &

    SQL script to create the used database:

    Initial post with title: New version of Mod_perl Dear respected Perl monks,

    I have a mod-perl site that I want to continue using, but my distro doesn't distribute the mod-perl package anymore because there is none available that works with Apache 2.4. It turns out that the loyal mod_perl development team cannot release a compatible version due to a lack of testers.

    Can somebody help by assisting them in submitting a bug report?
Find nonnumeric scalars
5 direct replies — Read more / Contribute
by urbs33
on Jan 29, 2015 at 09:59

    Guys I am working with millions of lines of data that "should" all be in the same format, however I am finding hundreds of lines that are not. A line may have ~10 fields space delimited. Suppose I am splitting the line into scalars that I can work with, and perform math on. Suppose fields 6-8 are supposed to be numeric and available for math. I am getting non-numeric warnings on several of them and just want to write the line out to an "errors" file so that I can resolve the formatting.

    How can I do something to test if scalar 6, 7, or 8 is not numeric (or even empty), write the line to a file and move to the next line. I can handle the "else". I'd prefer to use standard perl as it is very difficult at my company to pull in additional packages.

How can I access object data in a user defined sort cmp function?
6 direct replies — Read more / Contribute
by tkguifan
on Jan 28, 2015 at 09:19
    I want to sort the keys of a hash stored within an object. If I create a user defined cmp function for my sort, it only gets the values $a and $b. Within this cmp function how do I access the $self of the object?
    # object $self={ hash_ref=>{item1=>'value1',item2=>'value2'} } # cmp funtion sub byvalue { #instead of $a<=>$b; #something like $self->{hash_ref}->{$a}<=>$self->{hash_ref}->{$b}; #how do I access $self in this function? } # object's sort function sub sort_hash_ref_keys_by_value { my $self=shift; my @keys=sort byvalue keys(%{$self->{hash_ref}}); }
Get fullpath of file using grep
2 direct replies — Read more / Contribute
by Anonymous Monk
on Jan 28, 2015 at 09:12
    Having the following line I get just the filename. How can I modify it to get all path including the file name?
    my $directory; @files = grep {-f "$directory/$_" && /\.dat$/i} readdir DIR;

    I would like to get: c:\temp\file1.dat

    Right now I just get: file1.dat

use sqlldr with perl
4 direct replies — Read more / Contribute
by gary16
on Jan 28, 2015 at 01:41

    hi,everybody I m from China.And I now have a strange problem.This day I have imported the oracle data with sqlldr. AND I used the system() to call the sqlldr.The data text is encoded by GB2312;The title of the data text also is .When I run the perl script,The perl create a new data text encoded by utf8 and replace the old one.Here is my code.Have anybody figured out what is happened??

    #!/usr/bin/perl -w use strict; use Net::FTP; use Date::Calc qw(:all); use Encode qw(:all); $filename="&#27979;&#35797;&#25991;&#26412;"; if($filename){ system(" sqlldr test1/123456 data=$filename control=importwz.ctl"); + }
Execution Error DBI usr/.lck
1 direct reply — Read more / Contribute
by Anonymous Monk
on Jan 27, 2015 at 12:03
    Hi all, I can connect to my database fine (I think) but can't execute the statements.
    The error I get is
    DBD::DBM::st execute failed: Execution ERROR: Cannot open /Users/action_type.lck: No such file or d +irectory (2) at /usr/local/ActivePerl-5.20/lib/DBI/DBD/ l +ine 1589. . [for Statement "select distinct action_type, description from action_ +type "] at line 11. Cannot execute the statement Execution ERROR: Cannot open /Users/action_type.lck: No such file or d +irectory (2) at /usr/local/ActivePerl-5.20/lib/DBI/DBD/ l +ine 1589.
    #!/usr/bin/perl use strict; use Data::Dumper; use DBI; my $dbh = DBI->connect('DBI:DBM:PRO','username','password') or die "Co +uldn't connect to the database ". DBI->errstr; my $sth_action = $dbh->prepare('select distinct action_type, descripti +on from action_type ') or die 'Cannot prepare the statement'. $dbh->e +rrstr; $sth_action->execute or die 'Cannot execute the statement '. $sth_acti +on->errstr;
    I couldn't figure out what I am doing wrong. Could someone help me please.
Excel how to open existing worksheet
4 direct replies — Read more / Contribute
by AtlasFlame
on Jan 27, 2015 at 06:40

    How to write to existing worksheet?

    use Excel::Writer::XLSX; my $workbook = Excel::Writer::XLSX->new( 'sample.xlsx' ); $worksheet = $workbook->add_worksheet("new"); $worksheet->write(2, 2, 'Name'); $worksheet = $workbook->add_worksheet("old"); $worksheet->write(2, 2, 'Name'); $worksheet = $workbook->add_worksheet("latest"); $worksheet->write(2, 2, 'Name');

    How to open worksheet "new" for write again?

Object accessors with unknown data
5 direct replies — Read more / Contribute
by Amblikai
on Jan 26, 2015 at 05:43

    Hi Monks! I have a quick question with regards to building objects. My search keeps bringing up references to Moose et al, but i don't want to use an external object system. I'm practicing OOP with bog standard perl for my own education!

    With that in mind, i'm writing a program where i'm not going to know the data i have when constructing the object. In the past i've always known the name and type of each attribute so i can construct accessors and methods to check that the attribute data is correct etc.

    Now i'm stuck though! How do you write accessors for unknown attributes?


NDBM problem
1 direct reply — Read more / Contribute
by RuntimeError
on Jan 26, 2015 at 05:26
    Dear Monks,

    I have RedHat 6 and Perl 5.10 shipped with it. Since a recent update NBDM fails: in my case it is an errno 17 (more precise: it is Term::Clui database that is called and fails with the ndbm error). The database was created with the correct rights, etc. and the exact same program worked correctly until the update of the system.
    Do you know which might be the trouble here? Any dependencies I don't know about? I dont have much information for you but any hint is highly appreciated.
    I can disable the database in Term::Clui that is not my real concern.
    I am worried that the whole database mechanism in Perl might be broken...

    PS: I am using version 1.8 of gdbm (the latest version according to yum).
New Meditations
In place editing without reading further
2 direct replies — Read more / Contribute
by trippledubs
on Jan 27, 2015 at 14:22

    In transitioning Solaris Sparc sun4u to newer sun4v architecture we found that, sometimes, the image of the old server would not install onto the new server. The image file contains 20-30 text lines describing the system that was imaged and then the image itself. This file is quite large in some cases, takes a long time to create, and is made during an outage.

    The fix, once the image is already made, is quite janky. You need to append the string 'sun4v' into the the field 'content_architectures=' at the 20th or so. The other part is you do not want to read the rest of the file. Someone came up with this and saved the day. What do you think? Was there a better approach? Is there a way to do this using command line arguments that makes sense?

RFC: automating modular classes
1 direct reply — Read more / Contribute
by Arunbear
on Jan 26, 2015 at 08:44

    Minions is yet another OOP automation module, roughly similar to Moo, but which has the addtional goal of putting Encapsulation centre stage. I wrote it because after reading How Large Does Your Project Have To Be to Justify Using Moose? (especially the comments by tye and JavaFan), I became increasingly disillusioned with the Moo(se) way of OOP (essentially OOP with no Encapsulation).

    Here is a sample that implements the fixed size queue from Re^5: The future of Perl? (that sub-thread also illustrates limitations of the Moo way of OOP)
    package FixedSizeQueue; use Minions interface => [qw( push pop size )], construct_with => { max_items => { assert => { positive_int => sub { $_[0] =~ /^\d+$/ && $_[0 +] > 0 } }, }, }, implementation => 'FixedSizeQueue::Default', ; 1; package FixedSizeQueue::Default; use Minions::Implementation has => { q => { default => sub { [ ] } }, max_size => { init_arg => 'max_items', }, }, ; sub size { my ($self) = @_; scalar @{ $self->{$__q} }; } sub push { my ($self, $val) = @_; log_info($self); push @{ $self->{$__q} }, $val; if ($self->size > $self->{$__max_size}) { $self->pop; } } sub pop { my ($self) = @_; log_info($self); shift @{ $self->{$__q} }; } sub log_info { my ($self) = @_; warn sprintf "[%s] I have %d element(s)\n", scalar(localtime), $se +lf->size; } 1;
    And a sample of usage:
    % reply -I lib 0> use FixedSizeQueue 1> my $q = FixedSizeQueue->new(max_items => 3) $res[0] = bless( { '932db126-' => 'FixedSizeQueue::__Private', '932db126-max_size' => 3, '932db126-q' => [] }, 'FixedSizeQueue::__Minions' ) 2> $q->can $res[1] = [ 'pop', 'push', 'size' ] 3> $q->push($_) for 1 .. 3 [Mon Jan 26 12:01:53 2015] I have 0 element(s) [Mon Jan 26 12:01:53 2015] I have 1 element(s) [Mon Jan 26 12:01:53 2015] I have 2 element(s) $res[2] = '' 4> $q->pop [Mon Jan 26 12:02:09 2015] I have 3 element(s) $res[3] = 1 5> $q $res[4] = bless( { '932db126-' => 'FixedSizeQueue::__Private', '932db126-max_size' => 3, '932db126-q' => [ 2, 3 ] }, 'FixedSizeQueue::__Minions' ) 6> $q->push($_) for 4 .. 6 [Mon Jan 26 12:02:55 2015] I have 2 element(s) [Mon Jan 26 12:02:55 2015] I have 3 element(s) [Mon Jan 26 12:02:55 2015] I have 4 element(s) [Mon Jan 26 12:02:55 2015] I have 3 element(s) [Mon Jan 26 12:02:55 2015] I have 4 element(s) $res[5] = '' 7> $q $res[6] = bless( { '932db126-' => 'FixedSizeQueue::__Private', '932db126-max_size' => 3, '932db126-q' => [ 4, 5, 6 ] }, 'FixedSizeQueue::__Minions' ) 8> $q->log_info() Can't locate object method "log_info" via package "FixedSizeQueue::__M +inions" at reply input line 1. 9>
    Not all Moo features are supported (for this early release I've focused on those I actually use). Important differences from Moo include
    1. Attributes can be safely accessed inside classes without the overhead of a function call
    2. As a consequence of 1., attributes need not be exposed via methods (unless there is a good reason to do so).
    3. No need to clean up animal droppings
    4. Private subroutines via the mechanism shown in Re: OO - best way to have protected methods (packages)
    5. Class methods are "class only", and object methods are "object only"
    6. No compatibility with Moose
    Feedback is much appreciated.
The Boy Scout Rule
9 direct replies — Read more / Contribute
by eyepopslikeamosquito
on Jan 25, 2015 at 04:59

    You've got your typical company started by ex-software salesmen, where everything is Sales Sales Sales and we all exist to drive more sales.

    On the other extreme you have typical software companies built by ex-programmers. These companies are harder to find because in most circumstances they keep quietly to themselves, polishing code in a garret somewhere, which nobody ever finds, and so they fade quietly into oblivion right after the Great Ruby Rewrite, their earth-changing refactoring-code code somehow unappreciated by The People.

    -- The Developer Abstraction Layer by Joel Spolsky

    Though my natural inclination is to be a bit OCD about keeping code clean, I concede that spending too much time and money on refactoring, writing programmer tools, and endlessly polishing code will likely lead to commercial failure. As will the converse, namely neglecting your developers and their code and architectures in favour of sales and marketing. Successful software companies tend to have a healthy balance.

    Refactoring, perhaps the most commercially successful Perl-based company, has caused a bit of controversy over the years with their attitude towards refactoring. To give you a flavour, I present a couple of comments below:

    Booking is destroying my career because I am not allowed to do anything new. I am not allowed to use new technologies. I'm not allowed to "design" anything big. I am not allowed to write tests. I am allowed to copy that 500 line subroutine into another module. If people have done that several times before, maybe it should be refactored instead of duplicated? If you do that, you get in trouble. As one boss says, "we do not pay you to write nice code. We pay you to get job done."

    Management, and the term is quite lose when applied to, sees no gain in refactoring code. By refactoring I'm talking about taking a few weeks to rewrite an existing piece of software. By definition refactoring doesn't bring new functionality so this is why management is reluctant to go down that road. We're quite lenient about code that gets added to the repo, as long as there's a business reason behind it. If a quick hack can be deployed live and increase conversion then it will be accepted. But rest assured that crappy code doesn't last long, specially if other devs have to use it or maintain it.

    -- from Truth about (Blog)

    One of the posts specifically deals with the culture of "get it done and fast" and how they do not encourage refactoring or basic testing. I actually work in a Perl shop where management has the same kind of mentality, and it is slowly killing our efficiency.

    Regarding testing, it's true that we're not very unit testing focused. This is mainly because we've decided to spend most of the time/money/infrastructure that you might usually spend on unit testing on monitoring instead. If you have unit tests you still need monitoring, but in practice if your monitoring is good enough and you have an infrastructure to quickly rollout & rollback systems you can replace much of unit testing with monitoring.

    We're not adverse to refactoring when appropriate. But if you're going to propose rewriting some code here you'll actually have to make a compelling case for it which isn't just "the old code is hairy". Do you actually understand what it does? Maybe it's hairy and complex because it's solving a hairy and complex problem. Are you not aware of where this system fits into the big picture? We've also had code that's looks fantastic, had tests, used lots of best practices that we've had to throw away completely because it was implementing some idea that turned out to be plain stupid.

    -- from What exactly is up with (reddit)

    Opportunistic Refactoring and The Boy Scout Rule

    Some people object to such refactoring as taking time away from working on a valuable feature. But the whole point of refactoring is that it makes the code base easier to work with, thus allowing the team to add value more quickly. If you don't spend time on taking your opportunities to refactor, then the code base gradually degrades and you're faced with slower progress and difficult conversations with sponsors about refactoring iterations.

    There is a genuine danger of going down a rabbit hole here, as you fix one thing you spot another, and another, and before long you're deep in yak hair. Skillful opportunistic refactoring requires good judgement, where you decide when to call it a day. You want to leave the code better than you found it, but it can also wait for another visit to make it the way you'd really like to see it. If you always make things a little better, then repeated applications will make a big impact that's focused on the areas that are frequently visited - which are exactly the areas where clean code is most valuable.

    -- Opportunistic Refactoring (Martin Fowler)

    The Boy Scouts have a rule: "Always leave the campground cleaner than you found it"

    What if we followed a similar rule in our code: "Always check a module in cleaner than when you checked it out"

    -- The Boy Scout Rule (O'Reilly)

    At work, we perform opportunistic refactoring following the Boy Scout rule, trusting the judgement of developers. How do you do it at your workplace?

    Code Reviews

    By way of background, my company went agile about five years ago, at first with great zealotry, nowadays with more maturity and less dogma.

    Before check-in, all code must be reviewed, either continuously via pair programming, or via a lightweight code review (typically over-the-shoulder). We also have a coding standard, though it is not strongly enforced.

    To give a concrete example, during a code review the other day, I persuaded the author to eliminate unnecessary repetition by changing this snippet:

    my $config = <<'GROK'; ADD UDP_LISTENER ( 515 ) ADD UDP_LISTENER ( 616, 657 ) ADD UDP_LISTENER ( 987 ) GROK my @test_cases = ( { desc => "# Test 1", conf => $config, find => [ 'port = 515', 'port = 616', 'port = 657', 'port = 987' + ], }, );
    my $liststr = 'ADD UDP_LISTENER'; my @ports = ( 515, 616, 657, 987 ); my $config = <<"GROK"; $liststr ( $ports[0] ) $liststr ( $ports[1], $ports[2] ) $liststr ( $ports[3] ) GROK my @test_cases = ( { desc => "# Test 1", conf => $config, find => [ map { "port = $_" } @ports ], }, );

    What would you have done?

    I'm sure some other programmers at my company wouldn't have bothered suggesting any changes at all: after all, the code worked as is, it's pretty clear, plus "it's only a test script", so why bother?

    Though I felt the code was more maintainable with duplication eliminated, I had another motivation in this specific case: training. You see, the programmer in question was very new to Perl and, as I found out during the review, had never used map before! Training (and improved teamwork) are important benefits of code reviews.

    Eliminating unnecessary duplication and repetition is a common discussion topic during code review in my experience. (Note: I did not include this example to argue further about what DRY means exactly in Room 12A :). Other common discussion points during code review are:

    • Commenting.
    • Naming.
    • Clarity vs Cleverness.
    • Encapsulation.
    • Interfaces.
    • Error handling.
    • Testability. Is the code testable in isolation?
    • Supportability.
    • Portability.
    • Security.
    • Performance.
    Note that we do not normally discuss code layout because all code is pushed through Perl::Tidy before review.

    I'm interested to learn about your workplace experiences. In particular:

    • Do you have a coding standard? How is it enforced?
    • Do you do pair programming?
    • Do you do code reviews? Are they heavyweight (e.g. Fagan Inspection) or lightweight (e.g. over-the-shoulder)? Mandatory or optional?
    • What are common discussion points during your code reviews?


    To finish, here's another one, derived from Clever vs. Readable.

    Would this statement pass your code review?

    my $value = [ $x => $y ] -> [ $y <= $x ];
    If not, would you suggest changing it to:
    my $value = $x < $y ? $x : $y;
    use List::Util qw(min); my $value = min( $x, $y );
    Or something else?


New Cool Uses for Perl
Alphabetize in Esperanto
1 direct reply — Read more / Contribute
by aplonis
on Jan 30, 2015 at 10:21

    A hobby of mine is translating Jack Vance into Esperanto. And yes, I have permission for this! These I distribute for free in EPub format. In each ebook I like to embed a mini linked-in dictionary to help out beginners.

    I was wanting to re-organize some standalone EPubs into one omnibus EPub. I wanted one end-of-book dictionary instead of six end-of-chapter ones. That meant re-alphabetizing hundreds of anchor links. No big deal to do it in Perl...except that it's Unicode...and Esperanto. Here's how I did it.

New Monk Discussion
CB bug: cutting off text after TAB
1 direct reply — Read more / Contribute
by LanX
on Jan 29, 2015 at 06:34
    Since I'm using a mobile client, I'm regularly struggling with CB messages which only appear shortened in "normal" CB clients but normal in CB60.

    I looked into the HTML source ... could it be that "\t" is translated to an (unbalanced) "<\td>" in the cb sidebar and the rest is chopped?

    For reproduction, posting "test\ttest" produces:

    • <dd>test    test</dd> (i.e. the original input¹) in CB60
    • <span class='content'>test</td></tr> in CB sidebar
    • <span class="content">test</span> in "Chatterbox" nodelet
    • Possible workaround: pre-filtering input with s/\t/ /g
    • Reasoning: The way browsers handle TAB is too random and the CB isn't meant for horizontal formatting anyway
    • Alternative s/\t/ &nbsp; &nbsp;/g (updatet)

    Cheers Rolf

    PS: Je suis Charlie!

    ¹) discussion posts don't seem to preserve tab in inline <c>code</c>, the HTML here will show test &nbsp; &nbsp;test

Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2015-01-31 12:48 GMT
Find Nodes?
    Voting Booth?

    My top resolution in 2015 is:

    Results (258 votes), past polls