OpenLLM-France/wikimedia huggingface dataset:
# Perlwikibot

Perlwikibot is a framework for writing MediaWiki bots written in Perl, a free and open-source cross-platform programming language. MediaWiki::Bot itself provides classes and methods to perform many common tasks. There are currently no ready-to-run scripts like those found in Pywikibot.

## Table of Contents

* Overview
* Contributing
* Installing

## Using

Documentation is best found by the command perldoc MediaWiki::Bot, or from CPAN. There is also some documentation on the Google Code wiki and on the GitHub repository.

## Getting help

First, check the documentation. If your question is not answered there, you can contact the development team in three ways, listed here from most to least preferred:
* Email perlwikibot@googlegroups.com
* Submit an issue
* Join #perlwikipedia on irc.freenode.net
# Perl Programming/User input-output

Input/output, or IO, is an all-encompassing term that describes the way your program interacts with the user. IO comes in two forms, or stream types: the program's stimuli are collectively referred to as input, while the medium that the program uses to communicate back, write logs, play sounds, etc. is known as output. Both types of streams can be redirected either at a lower level than Perl, as is the case when done through the operating system by the shell; or, in Perl itself, as is the case when you reopen the file handles associated with the stream.

## Output

You have already learned how to output with the print statement. A simple reference is provided:
What this print statement is actually doing is printing to STDOUT, which stands for standard output. Standard output is the default destination for all output. If you wish to print anywhere else you must be explicit. We will revisit this later.

## Input

As you may have imagined, it's very hard to write a good program without any type of input; here is an example program to teach you these concepts:
Standard input is usually the keyboard though this can be changed at a lower level than your program. For now we will assume it isn't changed. However, this might not be an assumption you wish to make in production code.

# Unit exercise

* Write a program that prompts the user for a number and then returns the number multiplied by four (or any other number).
# Perl Programming/Websites
## Key Sites

* perl.org - the home of the Perl programming language
* perldoc.perl.org - Perl documentation
* cpan.org - The Comprehensive Perl Archive Network, a huge repository for Perl modules and scripts
* dev.perl.org/perl6 - Perl 6 development site
    The Parrot virtual machine

## Community

* Perl Mongers, Perl User Group Index
* The Perl Monastery, themed Perl based help site

## Other

* perl.com - a Perl blog
* The DMOZ directory, DMOZ Perl index
* Perl Outsourcing Stats
* Perl Tutorial
* Wikipedia:Perl
# Perlwikibot/Installing
## Installation

There are two ways to install MediaWiki::Bot.

### Using CPAN shell (recommended)

If you use the CPAN shell to install MediaWiki::Bot, the entire process is automated:
You might have CPAN configured such that you don't need to become root initially.

### Manual

Otherwise, you can install it manually. First install the dependencies (listed below), then install MediaWiki::Bot. To install this module type the following in the root directory or a checkout from SVN or an unpacked tarball:
You might use other methods to become root instead of sudo.
The test scripts included with MediaWiki::Bot require a working internet connection. If the test suite fails, it might be safe to install the module anyway. When in doubt, email perlwikibotgooglegroups.com with the complete output of the test suite and ask for advice.

### Dependencies

This module requires these other modules and libraries:
* WWW::Mechanize
* HTML::Entities
* URI::Escape
* XML::Simple
* Carp
* Encode
* MediaWiki::API
* Module::Pluggable
* Crypt::SSLeay
* Digest::MD5
# Perlwikibot/Overview
## What is this thing?

Perlwikibot is a bot framework, similar to Pywikibot, except it's written in Perl.

## Does that mean you're trying to make pywikibot obsolete?

Of course not! Pywikibot is a valuable bot framework (the Tawkerbot2 code, as well as most major bots, are written using it), however, if Perl coders are confined to using Python, they can't customize and extend the code to fit their needs. With an open-source framework written in their "native language," they'll be able to better write bots in a language that they are comfortable with, and even customize the framework to fit needs it wasn't originally imagined for.

## How complete is perlwikipedia?

Perlwikibot is almost completely cross-wiki, so you can write bots for virtually any MediaWiki wiki with it. As of version 5.005007, Perlwikibot does not support WikiData-specific queries or edits.

### Editing and querying wikis

* Retrieve the wikitext of articles, sections, and old revisions
* Edit pages
* Retrieve the history of articles
* Revert to old revisions of articles (manually, with undo, or with rollback)
* Retrieve the Recent Changes log
* Retrieve backlinks and transclusions
* Purge page caches
* Retrieve a listing of all pages in a category
* Run linksearches

### Admin functions

* Deleting and undeleting pages
* Blocking and unblocking users
* Protecting and unprotecting pages
* Performing transwiki imports (XML upload is in the works)

## Installation

The latest stable version can be installed from CPAN:
Or download from and install it like you would any other Perl module:

### Development versions

The latest unstable source code can be acquired from the github repo.
Unlike pywikibot, we do not recommend using the unstable source tree for production.

## Who wrote perlwikibot?

perlwikibot is maintained by ST47, Shadow1, Jmax-, Oleg Alexandrov, and Mike.lifeguard.

## Can I help?

Sure! Check out the OpenHatch page for ways to get started, or jump into the list of issues and start hacking!
# Perlwikibot/3.0 release
## Important note

    This release includes breaking changes. These release notes will guide you through the process of updating your calling code.
The 3.0 release marks a major transition. For starters, all methods use the API where possible. This means that return formats have changed in some cases. Likewise, some method calls have changed. Some of these still accept a backward-compatible form; this will be noted where applicable.

## Breaking changes
### All methods
#### Overview

    Nearly all methods now return undef on failure.

#### Rationale

    Separating errors from returned data is important. If you require the error code or error details, they are available in $bot->{'error'}->{'code'} and $bot->{'error'}->{'details'} respectively.

#### Impact

    Any method calls which did not ignore the return value must now check for undef.

#### Example: get_text and get_pages
##### Overview

    These methods now return undef for non-existent pages instead of an error code.

##### Rationale

    per above

##### Impact

    Any special cases you had for handling error codes must now look for undef instead. Calls involving pages which exist are unaffected.

##### Old call
### login
#### Overview

    This method now returns true on success; false on failure.

#### Rationale

    In Perl, non-zero is true and means success. Even the syscall wrappings in Perl follow this convention.

#### Impact

    All calls to login which checked return values must be updated.

#### Old call
### linksearch
#### Overview

    This method now uses keys 'url' and 'title'

#### Rationale

    This reduces confusion in cases where the programmer wishes to use a callback hook to do incremental processing. Without this change, accessing data would have been done with two different sets of keys.

#### Impact

    Any call needs to have the key names updated.

#### Old call
### what_links_here
#### Overview

    This method now uses keys 'title' and 'redirect'. It also returns only links (incl. redirects). Transclusions are handled by list_transclusions.

#### Rationale

    This reduces confusion in cases where the programmer wishes to use a callback hook to do incremental processing. Without this change, accessing data would have been done with two different sets of keys.

#### Impact

    Any call to this method needs to be evaluated as to whether it needs to be replaced with or supplemented by a call to list_transclusions. Also, key names must be updated.
# Perlwikibot/Contributing
## Introduction

Perlwikibot is an open-source project which aims to create a complete framework for rapidly creating and deploying computer programs which can perform common repetitive tasks on MediaWiki wikis. These clients are typically called 'bots' - hence the project name.
You can help fix bugs or add new functionality to the framework. The code is licensed under the GNU General Public License. In short, this means anyone may use the code for any purpose, including commercial use, and including making and distributing modified versions so long as they provide attribution and all derivative versions are also licensed under the GPL.

## Code style

Perl code is hard enough to read already, so try to make an effort to write readable code.

### Comments

Comments should be included wherever the code does something that isn't obvious.

#### good
### Perltidy

Perltidy is a code indenter and formatter. You can use it to help clean up your Perl code. For perlwikibot, use:
You can put this in .perltidyrc, and they'll be used every time you use perltidy. Put the file in your working directory to apply only to that directory, or in your $HOME to use the settings for everything.
Alternatively, set each option as a command line option to perltidy:

## Committing

Mike pushes his git repo to github; to contribute, make a fork, make your changes, and make a new pull request.
# Linear Algebra/Matrix Operations

The prior section shows how matrices represent linear maps. A good strategy, on seeing a new idea, is to explore how it interacts with some already-established ideas. In the first subsection we will ask how the representation of the sum of two maps $f+g$ is related to the representations of the two maps, and how the representation of a scalar product $r\cdot h$ of a map is related to the representation of that map. In later subsections we will see how to represent map composition and map inverse.
# Linear Algebra/OLD/Change of Basis
## Change of Basis

It was shown earlier that a square matrix can represent a linear transformation of a vector space into itself, and that this matrix is dependent on the basis chosen for the vector space. We will now show how to change the basis of a given vector space
Suppose we have some vector space whose basis is given by the set $A=a_{1},a_{2},\ldots ,a_{n}$ and we would like to change it to the set $B=b_{1},b_{2},\ldots ,b_{n}$. The basis B still belongs to vector space aforementioned, so its vectors can be expressed as a linear combination [Eq. 1]
$b_{1}=p_{11}a_{1}+p_{12}a_{2}+\ldots +p_{1n}a_{n}$,
$b_{2}=p_{21}a_{1}+p_{22}a_{2}+\ldots +p_{2n}a_{n}$,
$\ldots$
$b_{n}=p_{n1}a_{1}+p_{n2}a_{2}+\ldots +p_{nn}a_{n}$
Each vector of the set B has a coordinate matrix with respect to the basis we started off with, namely the set designated as A. We represent this as
${\begin{bmatrix}b_{1}\\\end{bmatrix}}_{A}={\begin{bmatrix}p_{11}\\p_{12}\\\vdots \\p_{1n}\\\end{bmatrix}}{\begin{bmatrix}b_{2}\\\end{bmatrix}}_{A}={\begin{bmatrix}p_{21}\\p_{22}\\\vdots \\p_{2n}\\\end{bmatrix}}\cdots {\begin{bmatrix}b_{n}\\\end{bmatrix}}_{A}={\begin{bmatrix}p_{n1}\\p_{n2}\\\vdots \\p_{nn}\\\end{bmatrix}}$
Setting these coordinate matrices as the columns of a matrix P gives us a transition matrix. This transition matrix transforms the original basis A to a new basis B of some vector space. The transition matrix is actually the transpose of [Eq. 1] that we saw earlier
$P={\begin{bmatrix}{\begin{bmatrix}b_{1}\\\end{bmatrix}}_{A}{\begin{bmatrix}b_{2}\\\end{bmatrix}}_{A}\cdots {\begin{bmatrix}b_{n}\\\end{bmatrix}}_{A}\end{bmatrix}}={\begin{bmatrix}p_{11}&\cdots &p_{n1}\\p_{12}&\cdots &p_{n2}\\\vdots &\ddots &\vdots \\p_{1n}&\cdots &p_{nn}\\\end{bmatrix}}$
To summarize, in order to find the transition matrix from some basis F to some basis G, we must compute the coordinate vector for each element of our original basis F with respect to the other basis G. The matrix whose columns are formed by the coordinate vectors is the transition matrix.

## Proof
##### Theorem 1

If P is the transition matrix from the basis A to the basis Z, and β is an element of the vector space, then it follows that
$P{\begin{bmatrix}\beta \\\end{bmatrix}}_{Z}={\begin{bmatrix}\beta \\\end{bmatrix}}_{A}$

#### Proof

$\beta =b_{1}z_{1}+b_{2}z_{2}+\cdots +b_{n}z_{n}$ $~~~=b_{1}(p_{11}a_{1}+\cdots +p_{1n}a_{n})+\cdots +b_{n}(p_{n1}a_{1}+\cdots +p_{nn}a_{n})$
$~=(b_{1}p_{11}+\cdots +b_{n}p_{n1})a_{1}+\cdots +(b_{1}p_{1n}+\cdots +b_{n}p_{nn})a_{n}$
$\therefore$
${\begin{bmatrix}\beta \\\end{bmatrix}}_{A}={\begin{bmatrix}(b_{1}p_{11}+\cdots +b_{n}p_{n1})\\\vdots \\(b_{1}p_{1n}+\cdots +b_{n}p_{nn})\\\end{bmatrix}}$
$={\begin{bmatrix}p_{11}&\cdots &p_{n1}\\\vdots &~&\vdots \\p_{1n}&\cdots &p_{nn}\\\end{bmatrix}}{\begin{bmatrix}b_{1}\\b_{2}\\\vdots \\b_{n}\\\end{bmatrix}}=P{\begin{bmatrix}\beta \\\end{bmatrix}}_{Z}$
$\Box$
# Linear Algebra/Matrix operations

Exercise 2c ka question no.3 edition 2018

## Addition of Matrices

Two matrices can be added together only if they have the same dimensions (the same number of rows and columns). The resultant matrix is simply the matrix whose elements are the sum of the elements in the two matrices that were added together. If a matrix $A$ is added to a matrix $B$ and the resultant matrix is $C$, then $c_{ij}=a_{ij}+b_{ij}$.
${\begin{pmatrix}5&1&7\\3&9&4\\0&-2&6\end{pmatrix}}+{\begin{pmatrix}3&2&4\\7&1&-3\\4&5&6\end{pmatrix}}={\begin{pmatrix}8&3&11\\10&10&1\\4&3&12\end{pmatrix}}$

## Multiplication of Matrices

Two matrices may be multiplied together only if the number of columns in the first matrix is equal to the rows in the second matrix. That is, if the first matrix is $n\times m$, then the second matrix must be $m\times p$. The resulting matrix will have a dimension of $n\times p$, where each element is the sum of the products of the entries in a row of the first matrix with the entries of the corresponding column in the second matrix. If $C=AB$, then $c_{ij}=\sum _{k=1}^{n}a_{ik}b_{kj}$.
Although matrix multiplication is not commutative, it is associative, which means that (AB)C=A(BC). Since matrix multiplication is not commutative, the order of the factors must be specified. AB would be read as "A post-multiplied by B" or "B premultiplied by A." Matrix multiplication obeys the distributive property, so A(B+C)=AB+AC. Also, two nonzero matrices do not necessarily have a nonzero product.
There is no such thing as "Matrix Division". To divide out a matrix, you need first to obtain the inverse of the matrix, and then multiply by the inverse. We discuss inverses below.

## Transpose

To obtain the transpose of a matrix, we swap the rows and the columns of that matrix. If we have a matrix X, the transpose is denoted X$^T$. For example:
    $X={\begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix}}$
    $X^{T}={\begin{bmatrix}1&4&7\\2&5&8\\3&6&9\end{bmatrix}}$

## Determinant

The determinant of a matrix, X is denoted by |X|.

## Inverse Matrix

If the matrix has a non-zero determinant, the matrix is said to be invertable. Inverse matrices follow the given formula:
    $XX^{-1}=X^{-1}X=I$
Where I is the identity matrix.
# Linear Algebra/Notation
## Notation

| $\mathbb {R}$, $\mathbb {R} ^{+}$, $\mathbb {R} ^{n}$ | real numbers, reals greater than $0$, ordered $n$-tuples of reals |
| $\mathbb {N}$ | natural numbers: $\{0,1,2,\ldots \}$ |
| $\mathbb {C}$ | complex numbers |
| $\{\ldots \,{\big |}\,\ldots \}$ | set of . . . such that . . . |
| $(a\,..\,b)$, $[a\,..\,b]$ | interval (open or closed) of reals between $a$ and $b$ |
| $\langle \ldots \rangle$ | sequence; like a set but order matters |
| $V,W,U$ | vector spaces |
| ${\vec {v}},{\vec {w}}$ | vectors |
| ${\vec {0}}$, ${\vec {0}}_{V}$ | zero vector, zero vector of $V$ |
| $B,D$ | bases |
| ${\mathcal {E}}_{n}=\langle {\vec {e}}_{1},\,\ldots ,\,{\vec {e}}_{n}\rangle$ | standard basis for $\mathbb {R} ^{n}$ |
| ${\vec {\beta }},{\vec {\delta }}$ | basis vectors |
| ${\rm {Rep}}_{B}({\vec {v}})$ | matrix representing the vector |
| ${\mathcal {P}}_{n}$ | set of $n$-th degree polynomials |
| ${\mathcal {M}}_{n\!\times \!m}$ | set of $n\!\times \!m$ matrices |
| $[S]$ | span of the set $S$ |
| $M\oplus N$ | direct sum of subspaces |
| $V\cong W$ | isomorphic spaces |
| $h,g$ | homomorphisms, linear maps |
| $H,G$ | matrices |
| $t,s$ | transformations; maps from a space to itself |
| $T,S$ | square matrices |
| ${\rm {Rep}}_{B,D}(h)$ | matrix representing the map $h$ |
| $h_{i,j}$ | matrix entry from row $i$, column $j$ |
| $\left|T\right|$ | determinant of the matrix $T$ |
| ${\mathcal {R}}(h),{\mathcal {N}}(h)$ | rangespace and nullspace of the map $h$ |
| ${\mathcal {R}}_{\infty }(h),{\mathcal {N}}_{\infty }(h)$ | generalized rangespace and nullspace |

### Lower case Greek alphabet

${\begin{array}{ll|ll|ll}{\text{name}}&{\text{character}}&{\text{name}}&{\text{character}}&{\text{name}}&{\text{character}}\\\hline {\text{alpha}}&\alpha &{\text{iota}}&\iota &{\text{rho}}&\rho \\{\text{beta}}&\beta &{\text{kappa}}&\kappa &{\text{sigma}}&\sigma \\{\text{gamma}}&\gamma &{\text{lambda}}&\lambda &{\text{tau}}&\tau \\{\text{delta}}&\delta &{\text{mu}}&\mu &{\text{upsilon}}&\upsilon \\{\text{epsilon}}&\epsilon &{\text{nu}}&\nu &{\text{phi}}&\phi \\{\text{zeta}}&\zeta &{\text{xi}}&\xi &{\text{chi}}&\chi \\{\text{eta}}&\eta &{\text{omicron}}&o&{\text{psi}}&\psi \\{\text{theta}}&\theta &{\text{pi}}&\pi &{\text{omega}}&\omega \end{array}}$
About the Cover. This is Cramer's Rule for the system $x_{1}+2x_{2}=6$, $3x_{1}+x_{2}=8$. The size of the first box is the determinant shown (the absolute value of the size is the area). The size of the second box is $x_{1}$ times that, and equals the size of the final box. Hence, $x_{1}$ is the final determinant divided by the first determinant.
# Linear Algebra/Nilpotence

The goal of this chapter is to show that every square matrix is similar to one that is a sum of two kinds of simple matrices. The prior section focused on the first kind, diagonal matrices. We now consider the other kind.
# Puzzles/Logic puzzles/Hats

Puzzles | Logic puzzles | Hats
3 men are buried in the sand all facing the same way with only their heads above ground. Each man has a hat placed on his head which is either red or blue, but they can't see it. The men know that their hats were selected from a bag containing 3 red hats, and 2 blue hats. The man at the back (who can see the hats of the two men in front of him) is asked what hat he is wearing. He answers: "I don't know". The middle (who can see the hat of the man in front of him) man is asked what hat he is wearing. He also replies: "I don't know". Finally, the man at the front is asked what hat he is wearing. He answers: "I am wearing a red hat".
How did he know?
Solution
# Puzzles/Logic puzzles/Getting out of Prison 2

Puzzles | Logic puzzles | Getting out of Prison 2
You are in a prison and your execution is planned for today. However, you are given one last chance to get out of this situation. You are brought into a room that has two exits and between them stands a guard. One exit leads out of the prison into freedom, while the other one brings you into the room where the execution takes place. You are told that the guard either always tells the truth or always lies, but not which it is that he does. You are allowed to ask only one question.
What question can you ask in order to find out the way to your freedom?
Solution
# Puzzles/Logic puzzles/Hats/Solution

Puzzles | Logic puzzles | Hats | Solution
The first man saw at most 1 blue hat in front of him, for if he saw 2 he would have said "red" (there are only 2 blue hats).
The second man saw a red hat in front of him, for if he saw a blue hat he would have said "red" (the first man saw at most 1 blue hat).
That's how the last man now knows the 2nd man saw a red hat on him.
# Puzzles/Logic puzzles/Infinite Hats

Puzzles | Logic puzzles | Infinite (Many) Hats
An arbitrary number of people are buried in the sand in a line and a hat is placed on their head (as in the previous puzzle Hats). Each hat is either red or blue, and there is no restriction on the total number of either color. Furthermore, each person can see the color of all the hats ahead of them, but are unable to see those behind them or their own. Starting with the back person, who can see all hats but his own, each person must call a hat color and nothing more.
If the whole group agrees on a strategy beforehand, how many people can accurately say the correct color of the hat they are wearing?
What strategy will they use?
Solution
# Puzzles/Logic puzzles/Infinite Hats/Solution

Puzzles | Logic puzzles | Infinite Hats | Solution
All but the last one can tell what colour hat he/she is wearing.
First, they agree on a way for the last person to count the number of hats in front of himself. An excellent way is for him (we'll assume it's a guy) to count the number of red hats. Then, he'll guess the colour of his hat based on that count: He'll say "red" if it's odd or "blue" if it's even.
Then, as each person goes down the row, she (to be fair) looks at the hats in front of her. She knows if there is an even number of red hats *including her own*, and can see how many red hats are in front of her. If there are an even number in front of her, and there are an even number including her own, then hers must be blue! When she answers with the colour of her hat, then the person in front of her will know whether to adjust the current count of red hats, and the puzzle can go on to completion.
Another way to look at the solution is counting in base 2, mod 2. Red hats are 1s and Blue hats are 0s. The last person in the row tells what the sum of everyone's hats in front of him is. He announces "Red" (Total = 1) or "Blue" (Total = 0). Then, the next person sums up the hats in front of her, and gets Total-In-Front-Of-Me. She knows that Total - Total-In-Front-Of-Me (mod 2) = Color-Of-My-Hat, and can announce her hat colour. The person in front of *her* can then figure out NewTotal = Total - Color-Of-Her-Hat (mod 2), and work out what colour his hat is, etc...
# Puzzles/Logic puzzles/Island on Fire

Puzzles | Logic puzzles | Island on Fire
You are on the South of an island (10 miles North to South) covered by dry vegetation. There is a fire which started at the far North of the Island and, because the wind is blowing strongly Southward, is working its way slowly South (1 mile per hour). You have no way to carry/channel water and no means of escaping the island. How can you survive the fire?
Solution