FANDOM


Perl Wiki is a place for novice and veteran perl coders to get together and experience Perl in the context of a MediaWiki-enabled community-driven shared environment. This site is about sharing the intricacies of social software in a fun and interesting way.

On the practical side, we extract and report things from other communities such as CPAN and the Perl Community along with other communities like Wikipedia and its metacommunity.

Our goal is to develop, test and market our own code library providing valuable resources (example WikiaPerl) under the GFDL and other free software and content licenses.

gen.pl Edit

This is a simplish script for training a complete newbie.

 #!/usr/bin/perl
 
 # gen.pl - generate a sequence, wrapping each element with open and close tags.
 
 use strict;
 use warnings;
 
 print "\n\t enter open tag:";
 my $opentag = <STDIN>;
 chomp $opentag;
 
 print "\n\t enter close tag:";
 my $closetag = <STDIN>;
 chomp $closetag;
 
 print "\n\t enter lowest:";
 my $lowest = <STDIN>;
 chomp $lowest;
 
 print "\n\t enter highest:";
 my $highest = <STDIN>;
 chomp $highest;
 
 my $filename = 'sequence.txt';
 open my $fh, '>', $filename
     or die "Can't open '$filename' for writing: $!";
 
 for my $count ( $lowest .. $highest ) {
 
     print $fh "$opentag$count$closetag\n"
         or die "Can't write to '$filename': $!";
 }
 close $fh or die "Can't close '$filename' after writing: $!"; 
 
 print <<MSG;
 
 A file: $filename
 has been written to your working directory
 MSG

DQ - Day Queue Edit

We are going to make a script that uses Perl and MediaWiki to help with some daily chores. A typical active Wikia community can make their site more lively by setting up some automated changes using MediaWiki variables and something similar to gen.pl to create a "queue" of pages for each weekday.

MediaWiki has a variable {{CURRENTDAYNAME}} that evaluates today as "Thursday" a unique but human-friendly name for today. You can also use {{CURRENTDAY}} to produce the numeric day of the month ( 1 .. 31 ) and {{CURRENTDOW}} to produce the numeric day of the week ( 0 .. 6 ). The Day Queue is mostly concerned with yesterday today and tomorrow. It doesn't care what month or week we are in - Those are handled with a Week Queue and a Month Queue.

Thursday

 #!/usr/bin/perl

 # gen.pl - list the days of the week, wrapping each DAYNAME with tags.

 use strict;
 use warnings;

 print "\n\t enter open tag:";
 my $opentag = <STDIN>;
 chomp $opentag;

 print "\n\t enter close tag:";
 my $closetag = <STDIN>;
 chomp $closetag;

 my $filename = 'dayqueue.txt';
 open my $fh, '>', $filename
     or die "Can't open '$filename' for writing: $!";

 for my $dayname ( Sunday .. Saturday ) {

     print $fh "$opentag$dayname$closetag\n"
         or die "Can't write to '$filename': $!";
 }
 close $fh or die "Can't close '$filename' after writing: $!"; 

 print <<MSG;

 A file: $filename
 has been written to your working directory
 MSG

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.