I am using the MediaWiki API to create a page updating bot. I got through some problems getting my headers accepted thanks to help from bliako in the thread Rest::Client Headers not getting through. But now I still can't get wiki to accept the token it gives me. From some googling I understand you need to get a token, then hand it over along with a login request to link that token to a logged in session. This is all I'm trying here, but when I send the token I just got, I get the error 'WrongToken'

Does anyone see any obvious errors in my code, or know the wiki API well enough to spot my error. The one thing I am not sure about is cookie handling. I have cargo culted that cookie setup from various example found on t'web. Should that cookie setup be sensible, or an I best to clear the cookie file between runs? Or have the cookies nothing to do with what's going on here?

Is there any way to take a block of text that includes different Chapter names, and then sort all of the text so that the Chapter names are in alphabetic order, while keeping the correct text with each Chapter?

Example of the text I'm trying to sort:

Chapter One
There were lots of monkeys here and they ate all the bananas...
lots more text up to hundreds of words.
Chapter Nine
This chapter has probably 1000 words.
Chapter Two
Here is the text in the second chapter...
Chapter Five
Here is the text in the fifth chapter...
every chapter is of differing length, some long some short.

What I would want is to sort these chapters to be in Alphabetical order.. they don't need to be in order numerically. I just want to know if there's a sort function that can arrange each title in order while preserving the text associated with each title. Resulting in something like:

Chapter Five
Here is the text in the fifth chapter... every chapter is of
differing length, some long some short.
Chapter Nine
This chapter has probably 1000 words.
Chapter One
There were lots of monkeys here and they ate all the bananas...
lots more text up to hundreds of words.
Chapter Two
Here is the text in the second chapter...

The uncommented path is the same as the one in my user profile.
The commented path is the one that has worked for years.
This problem started when I build a new server from scratch using a documented procedure. Something I have done quite a few times. Something new has happened during the build. I don't know what that was and I don't know how to solve this problem.

I've written a little keyboard to UART script as a first step to something more complex. The following code will let me send data from a PuTTY terminal over the serial connection, display it (STDOUT), and send a period back over the UART. In other words, the UART connection is working.

However, if I uncomment the "my $outchar=<>;" line, everything stops working. I suspect this is because it's blocking. I've also tried replacing the line with a "my $outchar=getc();" line. This works a little better in that the characters coming in over the serial port eventually print, but only if a couple characters are typed on STDIN. This despite the `stty cbreak` instruction.

Recently I've been trying to get a Perl/Tk program (HSW12, an IDE for programming microcontrollers) working with Tcl::pTk::TkHijack. One reason for doing so is letting the program be run on macOS using the native aqua UI instead of XQuartz. (Here's the full story on GitHub.)

One step I've taken is adapting the menubar to use the Tk 8 menu (cf. Mastering Perl/Tk - "12.2 Menubars and Pulldown Menus") rather than by packing Menubuttons. That way the native menubar at the top of the Mac's screen gets used instead of a menu in a window. However, the layout of the program has been such that the menubar is in its own window. When using the Tk 8 menu on non-Mac aqua, there is now a small amount of extra space (about 30 pixels vertically); and because there are no other widgets in the window, there doesn't appear to be anything to e.g. pack and remove the extra space. (See the bottom of this GitHub comment for a screenshot.)

Any ideas for how to remove this empty space/a way to force "pack" without widgets?

Some things I've already tried: I haven't found a suitable dummy widget that will shrink beyond some minimum size ≫0 (again, roughly 30 pixels). I thought I might set the toplevel's maxheight to the height of the menu, but I haven't found where that can be retrieved (the width and height of the menu is always 1x1 according to $menu->geometry). I'd rather not hardcode a height because the menu's height varies by platform and user theming/customizations.

Of course, one workaround would be to only use the Tk 8 menubar if running on Mac aqua (hiding the now-empty window using withdraw), and use the packed Menubuttons otherwise. One day I might use a module like Tk::IDElayout (compare to dock windows/panels in newer UI toolkits) which can let everything reside in a single toplevel window by default.

I am trying to split the above string and save the result in an array in such a way that each tagged segment is a separate array element. For example, 'C*ID1*Mac*C', 'D*ID1*Spore1 game*D', 'D*ID1*Spore 1*D', and 'D*ID2*Spore 2 game*D' should become four separate array elements.

As part of the shift to working with a plain text editor I would like to employ the 'perltidy' batch file and script to ensure my code is readable and consistent in presentation. However I have encountered a problem in doing so.

I use UTF-8 encoding with a matching BOM for all my Perl sources. Unfortunately when I run 'perltidy' on a file with this layout I recieve the following error:

Perltidy version is 20180220
1: unexpected character decimal 239 (ï) in script
1: unexpected character decimal 187 (») in script
1: unexpected character decimal 191 (¿) in script
1: Giving up after error

If I remove the BOM, but otherwise keep the UTF-8 encoding then 'perltidy' works as expected. Alternately if I set the -UTF8 switch then I get both the error message and the entire source file becomes double-spaced on new lines. Is there any way around this problem?

I am in the process of getting back in to Perl after being away from programming as a whole for quite a while. I thought this might be a good time to learn how to use the built-in debugger. Previously I ran 'EPIC' inside 'Eclipse', but ended up very much disliking that IDE. Therefore this time around I intend to write programmes in a text editor called 'EditPad Pro' and then employ the native Perl debugger as necessary. Unfortunately I have run in to some problems straight out of the gate,

As a test I started with the simplest of all one-line programmes, saved as 'debug_test.pl':

say "Hello";

Next, at the console window I used the command:

perl -d debug_test.pl

This is the output I received from Perl:

Loading DB routines from perl5db.pl version 1.51
Editor support available.
Enter h or 'h h' for help, or 'perldoc perldebug' for more help.
<main::(test.plx:1): print "hello";
Unable to get Terminal Size. The Win32 GetConsoleScreenBufferInfo call+ didn't work. The COLUMNS and LINES environment variables didn't work+.
at C:/StrawberryPERL/perl/vendor/lib/Term/ReadLine/readline.pm line 41+0.
at C:/StrawberryPERL/perl/vendor/lib/Term/ReadKey.pm line 462.
Term::ReadKey::GetTerminalSize(GLOB(0x28025f4)) called at C:/S+trawberryPERL/perl/vendor/lib/Term/ReadLine/readline.pm line 410
readline::get_window_size called at C:/StrawberryPERL/perl/ven+dor/lib/Term/ReadLine/readline.pm line 1114
readline::init called at C:/StrawberryPERL/perl/vendor/lib/Ter+m/ReadLine/readline.pm line 208
require Term/ReadLine/readline.pm called at C:/StrawberryPERL/+perl/vendor/lib/Term/ReadLine/Perl.pm line 63
eval {...} called at C:/StrawberryPERL/perl/vendor/lib/Term/Re+adLine/Perl.pm line 63
Term::ReadLine::Perl::new("Term::ReadLine", "perldb", GLOB(0x2+8b27bc), GLOB(0x28025f4)) called at C:/StrawberryPERL/perl/lib/perl5d+b.pl line 6868
DB::setterm() called at C:/StrawberryPERL/perl/lib/perl5db.pl +line 1849
DB::_DB__read_next_cmd(undef) called at C:/StrawberryPERL/perl+/lib/perl5db.pl line 2786
DB::DB called at test.plx line 1
SetConsoleMode failed, LastError=|6| at C:/StrawberryPERL/perl/vendor/+lib/Term/ReadKey.pm line 346.
at C:/StrawberryPERL/perl/vendor/lib/Term/ReadLine/readline.pm line 1+581.
readline::readline(" DB<1> ") called at C:/StrawberryPERL/per+l/vendor/lib/Term/ReadLine/Perl.pm line 11
Term::ReadLine::Perl::readline(Term::ReadLine::Perl=ARRAY(0x61+1b1c), " DB<1> ") called at C:/StrawberryPERL/perl/lib/perl5db.pl li+ne 7367
DB::readline(" DB<1> ") called at C:/StrawberryPERL/perl/lib/+perl5db.pl line 1858
DB::_DB__read_next_cmd(undef) called at C:/StrawberryPERL/perl+/lib/perl5db.pl line 2786
DB::DB called at test.plx line 1

I am using a fresh install of the newest Strawberry Perl (32Bit), which is release 5.26.2.1. I run this in Windows 7 (64Bit), patched with the latest updates. For what it is worth the same error occurs if I try the 64Bit edition of Strawberry Perl either. Other than this, Perl programmes themselves run without any problem. It is only when I try to execute them under the native debugger that I encounter an issue.

Can any of you chaps suggest a solution for this?

A quick search of the forum came up with a very similar issue reported by 'Ovid' way back in 2007. However that gentleman encountered the error while employing something called 'Prove', which I have never come across before and is certainly not something I am using myself. I think most of the suggestions in that thread related to using 'Prove', so I do not know how to apply them in my own far simpler situation.

UPDATE:

Well... A degree more persistence with the search function, both here and over at Google suggested another approach to sort this out that was not centred on 'Prove'; create an environment variable 'TERM' and set its value to 'dumb' (case sensitive for each I believe). After doing so perl -d debug_test.pl began working like a charm!!! So... I guess that is the fix. Which is good of course, but I have no idea why I couldn't find that result the first half-dozen times I searched for an answer... Weird indeed. Still. The jobs a good'un--problem solved!