Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Awesome WM config: Lua Source Parse

by space_monk (Chaplain)
on Oct 30, 2012 at 14:19 UTC ( #1001513=note: print w/replies, xml ) Need Help??

in reply to Awesome WM config: Lua Source Parse

Some alternatives - consider a map statement for the inner loop and consider a heredoc for the title. You could probably make the header separator a static too. Something like (not tested):
sub printSettings { my @groups = shift; my $sep = "=" x 60; foreach my $table (@groups) { foreach my $info (@$table) { my $cnt = 1; print <<EOF; $sep $info->[0] $sep EOF print map { sprintf "%5s. %-25s %-5s $info->[1]\n", $cnt +++, $_;} sort keys {$info->[1]}; } } }

Replies are listed 'Best First'.
Re^2: Awesome WM config: Lua Source Parse
by marquezc329 (Scribe) on Oct 30, 2012 at 17:34 UTC
    Thank you space_monk. I had thought of using map, but decided against it. In reading this reply to a previous post of mine Re: Efficiency of map vs. more verbose basic/fundamental code it is suggested that map is better used to create a new list based on modified elements of a previous one, rather than in the printing of a list. I will definitely look into a heredoc for the title, though. I like the way you did that. Thank you again for your suggestions.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001513]
[Corion]: ambrus: Yeah, they wrote articles themselves, but I think the TeX version of the articles was sometimes produced by the secretaries
[ambrus]: Corion: no, these days like half of the times the professors write the articles in TeX (with formatting that's mostly acceptible but not usually good), and the other half of the time it's people who are already co-authors of the article that write it

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2017-09-26 10:49 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (293 votes). Check out past polls.