I’ve installed WP-Syntax, a great plugin for Wordpress that lets you add code snippets to your blog posts without losing all the formatting.
You can use all manner of languages and even include line numbers if you want. Here’s a snippet from one of my math worksheet makers written in Perl:
5 | use List::Util shuffle; # Use the Shuffle module |
166 167 168 169 170 171 | # define and populate the arrays my @girlsnames = ('Erin','Anna','Joanne','Sally', 'Mary'); my @boysnames = ('Adam','Ken','Tom','Paul','David', 'Sam'); @girlsnames = shuffle @girlsnames; # shuffle the girls' array @boysnames = shuffle @boysnames; # shuffle the boys' array |
377 378 | $name1 = pop(@boysnames); # assign last name in array to $name1; $name2 = pop(@girlsnames); # assign last name in array to $name2; |