scratchpad
jdporter
<p><i>Last update: [localtime://2012-02-06]</i></p>
<h4>for [davies], regarding proposed tutorial [id://927532]</h4>
<p>Comments on the tutorial itself:</p>
<ol>
<li> All of the material currently in your "introduction" is footnote material. I'd move it into an actual footnote. And write a real introduction explaining what the tutorial is about! Don't just jump straight into code, expecting the reader to deduce what he's learning about. </li>
<li> Make your code look good at standard wrapping widths, e.g. as [Anonymous Monk] would see the node. As it is, the "Comment" comments wrap; it looks really bad. I think I'd put the "Comments" on their own lines, either above or below the associated code line. </li>
<li> Consider giving each comment a meaningful ID (like a variable name?) rather than just a number. But this is minor. </li>
</ol>
<p>If we are going to convert this meditation directly into a tutorial, rather than having you repost:</p>
<ol>
<li> Delete the paragraph at the top, in which you provide context on the origin of the post. It's way too old for anyone to care now. </li>
<li> Delete the last two paragraphs (after your signature). Again - no one cares about the edits you made back then. It would be one thing if we needed to maintain context for any comments on the post... but there aren't any! </li>
</ol>
<p>
All that being said - I'm not sure this is [Tutorials]-quality, in the sense that you're really just showing a very specific technique for accomplishing a very arcane task. I'd say it's a better fit for the [Cool Uses for Perl] section, frankly.
It's certainly very cool; I don't mean to take that away from it at all.
</p>
<p>
As for your other -- <b>RFC Tutorial - Deleting Excel Rows, Columns and Sheets</b> -- It looks really good to me. I'd post it in [Cool Uses for Perl] ASAP! (Or in [Meditations]. If you post it in CUFP, modify the title appropriately.)
</p>
<hr>
<h4>for [Lady_Aleena]</h4>
<code>
my $total_population = $generations{$_};
$total_population += $generations{$_ - 1} if $generations{$_ - 1};
$total_population += $generations{$_ - 2} if $generations{$_ - 2};
</code>
<hr/>
<h4>for [tye]</h4>
store this in a <c>.vbs</c> file, e.g. <c>eject_drives.vbs</c>.
run directly as a command. windows knows how to execute .vbs files.
<code>
dim sh, f, i, v
set sh = CreateObject("Shell.Application")
set f = sh.NameSpace(17) 'My Computer'
for each i in f.Items
' MsgBox i.Name & "=" & i.Type
if (i.Type = "CD Drive") then
for each v in i.Verbs
if (v.Name = "E&ject") then
v.DoIt()
end if
next
end if
next
</code>
<hr/>
<h4>For [Devanchya]:</h4>
<code>
use List::Util qw( shuffle );
use strict;
use warnings;
my @upper = 'A'..'Z';
my @lower = 'a'..'z';
$_ = "What That April With His Shoures Soote
The Drought Of Marche Hath Perced To The Roote
";
$" = '';
eval "y/@upper@lower/@{[shuffle @upper]}@{[shuffle @lower]}/";
print
</code>
<hr/>
This code appears in the <i>Perl Cookbook</i>, 2nd Ed., and was allegedly taken from <i>Mastering Regular Expressions</i>.
<p>
It alleges properly to parse quoted CSV fields with embedded commas and double-quotes, but my test of this utterly fails.
<code>
sub parse_csv1 {
my $text = shift; # record containing comma-separated values
my @fields = ( );
while ($text =~ m{
# Either some non-quote/non-comma text:
( [^"',] + )
# ...or...
|
# ...a double-quoted field: (with "" allowed inside)
" # field's opening quote; don't save this
( now a field is either
(?: [^"] # non-quotes or
|
"" # adjacent quote pairs
) * # any number
)
" # field's closing quote; unsaved
}gx)
{
if (defined $1) {
$field = $1;
} else {
($field = $2) =~ s/""/"/g;
}
push @fields, $field;
}
return @fields;
}
</code>
Test:
<code>
my @f = parse_csv1('first,"second","thi,rd","fou""rth"');
print "$_\n" for @f;
</code>
Output:
<code>
first
second
thi
rd
fou
rth
</code>
WTF?
<p>
<b>Solution:</b>
The problem is on line 15:
<code>
( now a field is either
</code>
Because the <c>/x</c> switch is in effect, the programmer can, and did, embed comments within the regex.
But there is no way for the compiler to check when a <c>#</c> has been accidentally omitted!
</p><p>
Change the line to:
<code>
( # now a field is either
</code>
IIRC, credit for finding this bug goes to [ikegami], and possibly [ambrus] as well. Thanks, guys!
</p>
<hr/>
A couple ideas for styling threads when the<br>
"Lay out threads as <div> instead of <table>" [Display Settings|setting] is enabled:
<code>
/* a basic one: */
div.header { background-color: #EEE; padding: 3px; border-bottom: 1px solid blue; }
ul.replies:before { content: url(http://perlmonks.org/images/bubbles.png) }
ul.replies { list-style-type: none; padding-left: 40px; }
li.reply { border: 1px solid blue; }
/* a fun one: */
div.header { background-color: #DFB; padding: 3px; }
ul.replies:before { content: url(http://perlmonks.org/images/bubbles.png) }
ul.replies { border-left: 2px solid red; padding: 3px; list-style-type: none; padding-left: 20px; }
li.reply { border-top: 2px solid blue; padding: 3px; }
/* both will need something like this: */
div.comment-on { text-align: center; font-size: larger; background-color: #DFB; }
</code>
<hr/>
<code>
<jcw> Jebus, I can't type.
<jcw> Perhaps a typing exercise would help.
*<* zdog has been kicked off channel #perlmonks by jcw (The quick brown fox kicked over the whining dog)
<jcw> Yea, that worked.
*<* Signoff: castaway (Ping timeout)
*<* Signoff: theorbtwo (Ping timeout)
<jcw> 3 for the price of 1!
</code>
<hr/>
<code>
{
package Foo;
use overload '""' => \&as_string;
sub as_string { "Foo!" }
}
$_ = bless {}, 'Foo';
/(.*)/ and print "$1\n";
# does this print "Foo!" or "Foo=HASH(0xdeaded)"?
</code>
<hr/>
<h4>Special Characters in Unicode</h4>
<p>Source: [wp://Mapping of Unicode characters]</p>
<table border=1 cellspacing=0>
<tr><th>Character Name</th><th>Code point (hex)</th><th>Character between two Zeroes</th></tr>
<tr><td>Word Joiner</td><td>&#x2060;</td><td>0⁠0</td></tr>
<tr><td>Zero-width joiner</td><td>&#x200D;</td><td>0‍0</td></tr>
<tr><td>Zero-width non-joiner</td><td>&#x200C;</td><td>0‌0</td></tr>
<tr><td>Zero-width space</td><td>&#x200B;</td><td>0​0</td></tr>
<tr><td>Zero-width no-break space</td><td>&#xFEFF;</td><td>00</td></tr>
<tr><td>Combining Grapheme Joiner</td><td>&#x034F;</td><td>0͏0</td></tr>
<tr><td>Invisible Separator</td><td>&#x2063;</td><td>0⁣0</td></tr>
<tr><td>Invisible Times</td><td>&#x2062;</td><td>0⁢0</td></tr>
<tr><td>Function Application</td><td>&#x2061;</td><td>0⁡0</td></tr>
<tr><td>Space</td><td>&#x0020;</td><td>0 0</td></tr>
<tr><td>En Quad</td><td>&#x2000;</td><td>0 0</td></tr>
<tr><td>Em Quad</td><td>&#x2001;</td><td>0 0</td></tr>
<tr><td>En Space</td><td>&#x2002;</td><td>0 0</td></tr>
<tr><td>Em Space</td><td>&#x2003;</td><td>0 0</td></tr>
<tr><td>Three-Per-Em Space</td><td>&#x2004;</td><td>0 0</td></tr>
<tr><td>Four-Per-Em Space</td><td>&#x2005;</td><td>0 0</td></tr>
<tr><td>Six-Per-Em Space</td><td>&#x2006;</td><td>0 0</td></tr>
<tr><td>Figure Space</td><td>&#x2007;</td><td>0 0</td></tr>
<tr><td>Punctuation Space</td><td>&#x2008;</td><td>0 0</td></tr>
<tr><td>Thin Space</td><td>&#x2009;</td><td>0 0</td></tr>
<tr><td>Hair Space</td><td>&#x200A;</td><td>0 0</td></tr>
<tr><td>Left-to-Right Mark</td><td>&#x200E;</td><td>0‎0</td></tr>
<tr><td>Mathematical Space</td><td>&#x205F;</td><td>0 0</td></tr>
<tr><td>Soft Hyphen</td><td>&#x00AD;</td><td>0­0</td></tr>
<tr><td>Non-breaking Hyphen</td><td>&#x2011;</td><td>0‑0</td></tr>
<tr><td>No-break Space</td><td>&#x00A0;</td><td>0 0</td></tr>
<tr><td>Narrow No-break Space</td><td>&#x202F;</td><td>0 0</td></tr>
<tr><td>Zero-width space</td><td>&#x200B;</td><td>0​0</td></tr>
<tr><td>Line separator</td><td>&#x2028;</td><td>0
0</td></tr>
<tr><td>Paragraph separator</td><td>&#x2029;</td><td>0
0</td></tr>
<tr><td>horizontal tab</td> <td>&#x0009;</td> <td>0	0</td></tr>
<tr><td>linefeed</td> <td>&#x000A;</td> <td>0
0</td></tr>
<tr><td>carriage return</td> <td>&#x000D;</td> <td>0
0</td></tr>
<tr><td>newline</td> <td>&#x0085;</td> <td>0…0</td></tr>
</table>
<hr/>
[http://www.vim.org/|Gvim] commands for using folds to browse Perl
data structures generated by [mod://Data::Dumper], given that
<c>$Data::Dumper::Indent=1;</c>
<code>
:set shiftwidth=2
:set foldcolumn=8 (not important)
:set foldmethod=indent
:1,$foldopen! (to open all folds)
</code>
<hr/>
<h4>for [635441]...</h4>
<code>
use Tk::FileSelect;
use Data::Dumper;
use strict; use warnings;
my $mw = new MainWindow;
my $fs = $mw->FileSelect( -directory => '.' );
$fs->configure(-verify => ['-d'] );
print "$_: ",$fs->Subwidget($_),"\n" for
'dir_entry', # LabEntry
'file_entry', # LabEntry
'dir_list', # ScrlListbox
'file_list', # ScrlListbox
'dialog' # Dialog
;
my %ch;
$ch{$_} = $_ for $fs->children;
delete $ch{$_} for $fs->Subwidget;
my( $fr ) = @ch{ grep /Frame/, keys %ch };
my $b = $fr->Button( -text => "New Dir", -command => \&new_dir, );
$b->pack( -side => 'top', -fill => 'x', -expand => 1, );
my $file = $fs->Show;
die "> $file\n";
sub new_dir
{
$fs->Subwidget('dir_entry')->validate;
# note that this is the current "accepted" directory name from the
# dir entry. It may not be the name of an existing directory!
# but it will NOT have a trailing /* even if displayed.
# it's possible to wangle the direntry into a state where it
# has two slashes before the * and/or letters between
# the / and * for example: /x//* /x/y* /x//y*
# In all cases, the slash (both slashes, if present) up
# through the star are excluded from the value of -directory.
my $dir = $fs->cget('-directory');
print "Make a new dir under $dir !\n";
my $new_dirname = Prompt("Enter new folder name:"); # wave hands
my $new_dir = "$dir/$new_dirname";
mkdir $new_dir;
$fs->Accept_dir($new_dir);
}
</code>
<hr/>
<ul><b>TOC:</b>
<li><a href="#plagiarists">Wall of Shame: Plagiarists In Residence</a></li>
<li><a href="#cbpad">Responses to Questions in the Chatterbox</a></li>
<li><a href="#ends">Odds and Ends</a></li>
<li><a href="#links">Links added from Personal Nodelet</a></li>
</ul>
<hr/><hr/>
<h3>Mysterious Posts</h3>
<h4>Mysterious</h4>
<ul>
<li> [id://948778] </li>
<li> [id://737125] </li>
<li> [id://594377] </li>
<li> [id://479049] </li>
<li> [id://464938] </li>
<li> [id://445554] </li>
<li> [id://422845] </li>
<li> [id://413492] </li>
<li> [id://411213] </li>
<li> [id://385502] </li>
<li> [id://347092] </li>
<li> [id://325076] </li>
<li> [id://287564] </li>
<li> [id://220599] </li>
<li> [id://220153] </li>
<li> [id://219620] </li>
<li> [id://214952] </li>
<li> [id://146140] </li>
<li> [id://145238] </li>
<li> [id://136375] </li>
<li> [id://63620] </li>
<li> [id://7248] </li>
<li> [id://99339] </li>
</ul>
<h4>Mysteriously</h4>
<ul>
<li> [id://682399] </li>
<li> [id://546722] </li>
<li> [id://403957] </li>
<li> [id://535403] </li>
<li> [id://286944] </li>
<li> [id://77832] </li>
<li> [id://59719] </li>
<li> [id://35911] </li>
</ul>
<h4>Mystery</h4>
<ul>
<li> [id://1134400] </li>
<li> [id://1134310] </li>
<li> [id://726694] </li>
<li> [id://713834] </li>
<li> [id://677494] </li>
<li> [id://671697] </li>
<li> [id://651620] </li>
<li> [id://645340] </li>
<li> [id://637299] </li>
<li> [id://529833] </li>
<li> [id://581014] </li>
<li> [id://523792] </li>
<li> [id://521757] </li>
<li> [id://501890] </li>
<li> [id://495783] </li>
<li> [id://484618] </li>
<li> [id://477121] </li>
<li> [id://447714] </li>
<li> [id://431432] </li>
<li> [id://421692] </li>
<li> [id://408556] </li>
<li> [id://316163] </li>
<li> [id://284724] </li>
<li> [id://199438] </li>
<li> [id://187280] </li>
<li> [id://181428] </li>
<li> [id://178936] </li>
<li> [id://173904] </li>
<li> [id://159307] </li>
<li> [id://133876] </li>
<li> [id://117189] </li>
<li> [id://74912] </li>
</ul>
<h4>Mystify</h4>
<ul>
<li> [id://590916] </li>
<li> [id://170918] </li>
</ul>
<hr/><hr/>
<a name="plagiarists"></a>
<h4>Wall of Shame: Plagiarists In Residence</h4>
<p>
The sad, unfortunate fact is that not all of the registered users
of this site are playing with a full deck, scruples-wise.
In particular, two monks — [jesuashok] and [madtoperl] —
have routinely posted material by other authors stolen from other sites;
in each case, proper attribution of authorship was studiously avoided; and in many
cases the plagiarist explicitly claimed the work was original.
</p>
<p>
I'm not trying to single out these folks. They are simply a couple known, currently active plagiarists.
If you discover any other recent or new plagiarisms, please notify [jdporter|me], [liverpole], [planetscape], [chargrill], or [shmem] (the Plagiarism Posse).
</p><p>
Keep in mind that usernames are not important; people can always create new user accounts to hide behind.
Rather, we want to educate any offenders — the people behind the usernames — that plagiarism is not cool and not acceptable.
</p>
<p>
Advice to moderators:
<ul>
<li> <b>Do not</b> approve posts which are known to be plagiarisms.
In the case of posts by known habitual plagiarists such as [madtoperl] and [jesuashok], err on the side of caution. Don't approve until the question has been settled. At this point, we have little reason to believe that [jesuashok] knows <i>anything</i> about how to program in perl, nor that [madtoperl] could write an original poem. For example. </li>
<li> If possible, unapprove any plagiaristic posts which have already been approved. </li>
</ul>
<p>
Advice to monks:
</p>
<ul>
<li> Down-vote plagiaristic posts. It's a shame that these liars have gotten <i>beaucoups</i> [id://5938|XP] for posts that they did not put any original work into, nor (in the case of perl code) even understand. </li>
</ul>
<p>
Relevant PMD: <b>[id://576774]</b>
</p>
<h4>root posts by [jesuashok]:</h4>
<h4>[id://479]:</h4>
<table border=1 cellspacing=0 cellpadding=1>
<tr> <th>post</th> <th>Plagiarized from</th> </tr>
<tr> <td>[id://549655]</td> <td>[http://www.nntp.perl.org/group/perl.perl5.porters/34557|p5p]</td> </tr>
<tr> <td>[id://552769]</td> <td>[doc://close|perldoc:close]</td> </tr>
<tr> <td>[id://575455]</td> <td> </td> </tr>
<tr> <td>[id://574034]</td> <td> </td> </tr>
<tr> <td>[id://573636]</td> <td> </td> </tr>
<tr> <td>[id://571385]</td> <td> </td> </tr>
<tr> <td>[id://571220]</td> <td> </td> </tr>
<tr> <td>[id://566070]</td> <td> </td> </tr>
<tr> <td>[id://564671]</td> <td> </td> </tr>
<tr> <td>[id://559286]</td> <td> </td> </tr>
<tr> <td>[id://558251]</td> <td> </td> </tr>
<tr> <td>[id://556926]</td> <td> </td> </tr>
<tr> <td>[id://555481]</td> <td> </td> </tr>
<tr> <td>[id://554784]</td> <td>[http://search.cpan.org/src/RGARCIA/perl-5.9.4/t/op/pos.t|perl] and [http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1999-10/msg01276.html|p5p]</td> </tr>
<tr> <td>[id://554441]</td> <td>[http://www.nntp.perl.org/group/perl.perl5.porters/85016|p5p]</td> </tr>
<tr> <td>[id://554268]</td> <td> </td> </tr>
<tr> <td>[id://554235]</td> <td> </td> </tr>
<tr> <td>[id://554088]</td> <td> </td> </tr>
<tr> <td>[id://554082]</td> <td> </td> </tr>
<tr> <td>[id://554053]</td> <td>[http://www.nntp.perl.org/group/perl.perl5.porters/53468|p5p]</td> </tr>
<tr> <td>[id://550754]</td> <td> </td> </tr>
<tr> <td>[id://550154]</td> <td> </td> </tr>
<tr> <td>[id://549655]</td> <td> </td> </tr>
<tr> <td>[id://549400]</td> <td> </td> </tr>
<tr> <td>[id://549385]</td> <td> </td> </tr>
<tr> <td>[id://546815]</td> <td> </td> </tr>
<tr> <td>[id://546811]</td> <td> </td> </tr>
<tr> <td>[id://545456]</td> <td> </td> </tr>
<tr> <td>[id://545193]</td> <td> </td> </tr>
<tr> <td>[id://544852]</td> <td>[http://groups.google.com/group/perl.perl5.porters/browse_thread/thread/543e799786b8484e/e158ec3ad20ac77b?lnk=st&q=The+following+subroutine+returns+its+argument+with+any+leading+newlines+removed%3A&rnum=1&hl=en#e158ec3ad20ac77b|P5P]</td> </tr>
<tr> <td>[id://544769]</td> <td>[http://www.nntp.perl.org/group/perl.perl5.porters/105188|p5p]</td> </tr>
<tr> <td>[id://543989]</td> <td>[http://rt.perl.org/rt3//Public/Bug/Display.html?id=38935|rt.perl]</td> </tr>
<tr> <td>[id://543058]</td> <td> </td> </tr>
<tr> <td>[id://542988]</td> <td>[http://www.nntp.perl.org/group/perl.perl5.porters/104479|p5p]</td> </tr>
<tr> <td>[id://542744]</td> <td>[http://groups.google.com/group/comp.lang.perl/msg/b4d75f6fc8af214f|clp]</td> </tr>
<tr> <td>[id://542441]</td> <td>[http://www.nntp.perl.org/group/perl.perl5.porters/;msgid=20060323133046.GA2184%5Bat%5Defn.org?show_headers=1|p5p]</td> </tr>
<tr> <td>[id://542227]</td> <td>[http://www.nntp.perl.org/group/perl.perl5.porters/111114?show_headers=1|p5p]</td> </tr>
<tr> <td>[id://542220]</td> <td>[https://rt.cpan.org/Public/Bug/Display.html?id=20|rt.perl]</td> </tr>
<tr> <td>[id://539380]</td> <td> </td> </tr>
<tr> <td>[id://539378]</td> <td>[http://tek-tips.com/viewthread.cfm?qid=1209361&page=6|tek-tips]</td> </tr>
<tr> <td>[id://531384]</td> <td> </td> </tr>
<tr> <td>[id://526704]</td> <td>[http://groups.google.com/group/perl.beginners/msg/7603859b956a9f5f|perl.beginners]</td> </tr>
<tr> <td>[id://526656]</td> <td> </td> </tr>
<tr> <td>[id://526642]</td> <td>[http://64.233.161.104/search?q=cache:BY0gJ8lAFfkJ:archives.devshed.com/forums/comp-lang-perl-tk-52/function-system-nasty-behaviour-in-cygwin-perl-tk-1684875.html+%23+Code+automatically+generated+by+VPTK_W&hl=en&gl=us&ct=clnk&cd=5&client=firefox-a|clp.tk]</td> </tr>
<tr> <td>[id://524456]</td> <td> </td> </tr>
<tr> <td>[id://524120]</td> <td> </td> </tr>
<tr> <td>[id://524108]</td> <td> </td> </tr>
<tr> <td>[id://522531]</td> <td> </td> </tr>
<tr> <td>[id://522527]</td> <td> </td> </tr>
<tr> <td>[id://521861]</td> <td> </td> </tr>
<tr> <td>[id://520791]</td> <td> </td> </tr>
<tr> <td>[id://519147]</td> <td> </td> </tr>
<tr> <td>[id://517195]</td> <td> </td> </tr>
<tr> <td>[id://517176]</td> <td> </td> </tr>
<tr> <td>[id://516759]</td> <td> </td> </tr>
<tr> <td>[id://515147]</td> <td> </td> </tr>
<tr> <td>[id://513811]</td> <td> </td> </tr>
<tr> <td>[id://513571]</td> <td> </td> </tr>
<tr> <td>[id://512758]</td> <td> </td> </tr>
<tr> <td>[id://509339]</td> <td> </td> </tr>
<tr> <td>[id://509187]</td> <td> </td> </tr>
<tr> <td>[id://507436]</td> <td> </td> </tr>
<tr> <td>[id://507093]</td> <td> </td> </tr>
<tr> <td>[id://506658]</td> <td> </td> </tr>
<tr> <td>[id://506632]</td> <td> </td> </tr>
<tr> <td>[id://506619]</td> <td> </td> </tr>
<tr> <td>[id://505297]</td> <td> </td> </tr>
<tr> <td>[id://504847]</td> <td> </td> </tr>
<tr> <td>[id://504199]</td> <td> </td> </tr>
<tr> <td>[id://504196]</td> <td> </td> </tr>
<tr> <td>[id://503860]</td> <td> </td> </tr>
<tr> <td>[id://503859]</td> <td> </td> </tr>
<tr> <td>[id://503546]</td> <td> </td> </tr>
<tr> <td>[id://413146]</td> <td> </td> </tr>
</table>
<h4>[id://1590]:</h4>
<table border=1 cellspacing=0 cellpadding=1>
<tr> <th>post</th> <th>Plagiarized from</th> </tr>
<tr> <td>[id://575460]</td> <td> </td> </tr>
<tr> <td>[id://573844]</td> <td> </td> </tr>
<tr> <td>[id://571926]</td> <td>[http://samideas.wordpress.com/2006/04/21/120/|web]</td> </tr>
<tr> <td>[id://570717]</td> <td> </td> </tr>
<tr> <td>[id://507304]</td> <td> </td> </tr>
<tr> <td>[id://504207]</td> <td> </td> </tr>
</table>
<!--
<h4>[id://1040]:</h4>
<table border=1 cellspacing=0 cellpadding=1>
<tr> <th>post</th> <th>Plagiarized from</th> </tr>
<tr> <td>[id://565134]</td> <td> </td> </tr>
<tr> <td>[id://547050]</td> <td> </td> </tr>
<tr> <td>[id://504938]</td> <td> </td> </tr>
</table>
<h4>[id://480]:</h4>
<table border=1 cellspacing=0 cellpadding=1>
<tr> <th>post</th> <th>Plagiarized from</th> </tr>
<tr> <td>[id://566341]</td> <td> </td> </tr>
<tr> <td>[id://553586]</td> <td> </td> </tr>
<tr> <td>[id://541826]</td> <td> </td> </tr>
</table>
-->
Some relevant discussion followed [571926], including accusations of plagiarism, followed by protestations of innocence.
<h4>plagiarisms by [madtoperl]:</h4>
<table border=1 cellspacing=0 cellpadding=1>
<tr> <th>post</th> <th>Plagiarized from</th> </tr>
<tr><td>[id://551334]</td><td>[http://groups.google.com/group/comp.lang.perl.tk/msg/d01ce575129a6525|clp.tk]</td></tr>
<tr><td>[id://551569]</td><td>[http://groups.google.com/group/perl.beginners/msg/fea6abed7fa353c7|perl.beginners]</td></tr>
<tr><td>[id://542254]</td><td>Sharon Hopkins (quoted in a reply)</td></tr>
<tr><td>[id://542224]</td><td>Sharon Hopkins (quoted in a reply)</td></tr>
<tr><td>[id://542755]</td><td>[http://hacks.oreilly.com/pub/h/1004|<i>Spidering Hacks</i>]</td></tr>
<tr><td>[id://548914]</td><td>[http://www.incompetech.com/gallimaufry/perl.html|Peter Eckenrod]</td></tr>
<tr><td>[id://545576]</td><td>[http://babyl.dyndns.org/yaph/poems/diaper|Yanick]</td></tr>
</table>
<hr/>
<a name="cbpad"></a>
<h3>Responses to questions in the Chatterbox</h3>
<h4>for [atcroft]:</h4>
<code>
package SNMPfu;
# pass an object which is either a Net::SNMP object
# (as returned by Net::SNMP->session) or an SNMP::Session
# object (as in the SNMP module/dist).
sub wrap
{
my $obj = shift;
bless $obj, __PACKAGE__ . '::' . ref $obj; # rebless
}
package SNMPfu::Net::SNMP; # wrapper for Net::SNMP
use base 'Net::SNMP';
sub get # wraps Net::SNMP::get_request
{
my( $self, $var_id ) = @_;
my $r = $self->get_request( -varbindlist => [$var_id] );
defined $r or die $self->error;
$r->{$var_id}
}
package SNMPfu::SNMP::Session; # wrapper for SNMP::Session
use base 'SNMP::Session';
sub get # wraps SNMP::Session::get
{
my( $self, $var_id ) = @_;
$self->get($var_id) # but I'm not sure this correct. Illustration only.
}
1;
</code>
In user code:
<code>
my $sess = Net::SNMP->session( ... );
# or:
my $sess = SNMP::Session->new( ... );
SNMPfu::wrap( $sess );
my $val = $sess->get('sysDescr.0');
</code>
By reblessing, we divert all method calls on the object into
one of the wrapper classes we've written.
By making those wrapper classes inherit from the original
class of the object, the user can call "native" methods of
the object if she chooses. If we wish to disallow that, just
take out the 'use base' lines.
<hr/>
<h4>For [Intrepid]:</h4>
<code>
my $sh = new Win32::OLE 'Shell.Application' or die;
my $folder = $sh->NameSpace( $directory_path ) or die;
my $item = $folder->ParseName( $unqualified_filename ) or die;
$item->InvokeVerb('Edit');
</code>
<hr/>
<h4>Determine CD-ROMs, for [TheMadHatter]:</h4>
Put the following code in a file named <code>cdrom_drives.js</code><br/>
Execute it with the command
<blockquote>
<code> cscript /nologo cdrom_drives.js </code>
</blockquote>
<code>
/*
* cdrom_drives.js
* by jdporter
*/
var sh = WScript.CreateObject('Shell.Application');
var a = new Array();
var i;
for ( i = 65; i < 75; i++ ) { // test the first 10 drive letters
var p = String.fromCharCode(i,58,92); // letter + colon + backslash
try {
var fi = sh.NameSpace(p).Self; // will throw if bad path
if ( fi.IsFileSystem && fi.Type == 'Compact Disc' ) a.push(p);
}
catch(e) {
}
}
WScript.Echo(a.join("\n"));
</code>
<hr/>
<hr/>
<a name="ends"></a>
<h3>Odds and Ends</h3>
<hr/>
<h4>From [tachyon]:</h4>
<ul>
<li>[CGI Help Guide]<br>
<li>[DMCA - as bad as you think?]<br>
<li>[A real challenge]<br>
<li>[Simple Module Tutorial]<br>
<li>[To sub or not to sub, that is the question?]<br>
<li>[My Life ]<br>
<li>[id://109627|Hacking a project in groups]<br>
<li>[id://84526|How to calculate development time]<br>
</ul>
<hr/>
<h4>[http://www.oscom.org/|Open Source Content Management]</h4>
<hr/>
<h4>[http://theory.cs.uiuc.edu/~jeffe/teaching/373/|Jeff Erickson's CS 373: Combinatorial Algorithms]</h4>
<hr/>
<h4>Get the total reputation of all your nodes.</h4>
<code>
use LWP::Simple;
use XML::Simple;
use strict;
my( $username, $password );
print "Username: "; chomp( $username = <> );
print "Password: "; chomp( $password = <> );
$username && $password or die "Abort.\n";
my $t = XMLin get "http://perlmonks.org/?node_id=32704;op=login;user=$username;passwd=$password;ticker=yes";
my $total;
my $n;
while ( my( $id, $hr ) = each %{ $t->{'NODE'} } )
{
$total += $hr->{'reputation'};
$n++;
}
print "$total rep in $n nodes\n";
</code>
<hr/>
<h4>Get a list of "other users" currently active in the Monastery, and their XP</h4>
<code>
use LWP::Simple;
use strict;
*a = \"http://perlmonks.org/?node_id";
printf qq
m%2d %7d %s\nm,m
leve.="(\d+)"l,m
exp="(\d+)"e,m
foruser="([^"]+)"ffor map get qq
m$a=16046;for_userid=$_m,map m
user_id="(\d+)"ug,get qq
m$a=15851m;
</code>
<hr/>
<h4>What's with all the "buddha" usernames?</h4>
<ul>
<li> [id://7374]
<li> [id://10973]
<li> [id://89228]
<li> [id://124484]
<li> [id://124486]
<li> [id://137493]
<li> [id://185796]
<li> [id://187704]
<li> [id://256639]
<li> [id://351047]
<li> [id://383228]
<li> [id://416115]
<li> [id://424177]
<li> [id://434309]
<li> [id://491158]
<li> [id://499508]
<li> [id://551290]
<li> [id://672645]
<li> [id://724412]
</ul>
<b>Wacky. And then there's</b>
<ul>
<li> [id://115878]
<li> [id://209535]
<li> [id://355289]
<li> [id://382353]
</ul>
<hr/>
<h4>HTML for a form with which someone (such as yourself) can send you a msg</h4>
<p>This snippet can be put anyplace on PerlMonks where HTML forms are allowed, including
your homenode or in your [id://492700|Free Nodelet].</p>
<p>You must replace "<c>jdporter</c>" with your username, and <c>170442</c> with your user id (which is your homenode's node_id).</p>
<code>
<form method="post" action="?" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="node_id" value="170442">
<input type="hidden" name="op" value="message">
<input type="hidden" name="replyto" value="user">
<input type="hidden" name="sendto" value="jdporter">
<input type="text" name="replytotext" size=60 maxlength=255>
<input type="hidden" name="sexisgood" value="submit">
</form>
</code>
<hr/>
<h4>[wp://Business Process Execution Language]</h4>
<h4>[wp://Business Process Modeling Notation]</h4>
<hr/>
<h4>How to using folds in [http://www.vim.org|Vim] to browse [mod://Data::Dumper] output</h4>
<ol> <c>$Data::Dumper::Indent=1</c> is a prerequisite.
<li> <c>:set shiftwidth=2</c> </li>
<li> <c>:set foldcolumn=8</c> (actual value not critical)</li>
<li> <c>:set foldmethod=indent</c> </li>
<li> <c>:1,$foldopen!</c> to open all folds, since they're initially closed.</li>
</ol>
<hr/>
<a name="a9f7r865g897y"></a>
<p>
One of the patterns I see frequently goes like this:
<ul>
<li> you say something that <b>strongly and clearly</b> implies <i>X</i>;</li>
<li> other monk disagrees with you about <i>X</i>; </li>
<li> you claim you never said <i>X</i>. </li>
</ul>
It's weasely, and intellectually dishonest. I don't care so much that <i>you</i> do that (you and I are strangers, after all), but I do care about the fact that it invariably and unnecessarily raises the noise level here by a significant amount. Sometimes I think you do it just for the joy of the fray.
</p><p>
Now, of course, you may -- and I fully expect you to -- say I'm mistaken about any or all of the above. But you have to ask yourself: <i>Why do people so routinely misunderstand me?</i> If you truly believe people aren't understanding your true opinion on something, I'd suggest (1) stating clearly and unambiguously -- and that means (among other things) without sarcasm, since that is so easily missed in this medium; and (2) maintaining your position with as much consistency as possible.
</p>
<hr/>
<a name="links"></a>
<h4>Below is the list of node links collected by clicking "Add to public pad" in my Personal Nodelet:</h4>
<!--nodelet-begin-->
<p class="bookmarks">
[id://17642]
<br />[id://114691]
<br />[id://131994]
<br />[id://138297]
<br />[id://14909]
<br />[id://176623]
<br />[id://176063]
<br />[id://188642]
<br />[id://197927]
<br />[id://205136]
<br />[id://207164]
<br />[id://213052]
<br />[id://213129]
<br />[id://219479]
<br />[id://233481]
<br />[id://23910]
<br />[id://254116]
<br />[id://258492]
<br />[id://273733]
<br />[id://284175]
<br />[id://287149]
<br />[id://490679]
<br />[id://491864]
<br />[id://559080]
<br />[id://6041]
<br />[id://74314]
<br />[id://79018]
<br />[id://86640]
<br />[id://86660]
<br />[id://87097]
<br />[id://87344]
<br />[id://87452]
<br />[id://61675]
<br />[id://561931]
<br />[id://129204]
<br />[id://303506]
<br />[id://523174]
<br />[id://637055]
<br />[id://647818]
<br />[id://885520]
<br />[id://492700]
<br />[id://751522]
<br />[id://16082]<!--INSERTHERE-->
</p>
<!--nodelet-end-->
<p><i>Wow, stuff got inserted above, not below!</i></p>