In this reference article we’ll explain what strings are, why they’re important, and how they work in JavaScript. We’ll cover all the properties and methods of strings, along with some simple examples.
Blog
Here you’ll find articles about website development, WordPress, and other topics that I’m interested in. I hope you enjoy them and find them useful. Comments and feedback are always welcome!
Data Types in Perl
Like most programming languages, Perl knows about different varieties of data. In this tutorial we’ll explore the most common data types used in Perl:
- Scalars
- Arrays (lists)
- Associative arrays (hashes)
Preventing Multiple Form Submits
Forms on websites are a handy way to get information from your visitors. However it’s easy for a visitor to accidentally send more than one copy of a form by clicking on the form’s “submit” button more than once. The end result can be that identical emails get sent to the Webmaster, or identical records get added to a database.
This handy little tutorial shows how you can use JavaScript in your Web pages to avoid forms being submitted more than once by a visitor.
Controlling Program Flow
Normally when you run a Perl script, the computer moves through each line of your script in turn, executing each line as it goes. However, often you’ll want to alter this flow through the script.
For example, you might want to run different pieces of code depending on whether a visitor has filled out a form correctly or not. Also, you often want to run the same piece of code lots of times – for example, when reading through each line of a file.
Perl features a number of useful ways to alter the path of execution through your script. In this tutorial I’ll show you the most common techniques, and how you can use them.
Fun with Random Numbers
We can use JavaScript to generate random numbers, that is, numbers that are different each time the script is run. This allows us to do all sorts of fun stuff, such as:
- Show a random image or piece of text on the page
- Make a link that links to a random page
- Create games that people can play in their browser
First, let’s look at how we can create a random number in JavaScript.
[Read more…] about Fun with Random Numbers
HTML Links for Beginners
HTML links allow one Web page to link to other related pages. They can use text or images to link to other Web pages or even an email address. If you’re new to Web building and you’re not sure how links work in HTML pages, this tutorial is for you! Read on…
Making Lists Look Nicer with CSS
Standard HTML lists are usually pretty boring – a few indented lines with bullets or numbers down the left side. However, with the power of CSS, you can really get creative with your lists! Read on for details…
Working with Files
Perl’s filesystem functions let you manipulate files and directories on the server from within your CGI scripts. This means that you can:
- store data in files on the server
- allow visitors to upload files to your site
- create message boards and guestbooks
…and all sorts of other useful stuff!
In this tutorial, we’ll show you how to create files and write to them, how to read from them, how to delete them, and how to scan directories (folders) so that you can see what files are on the server.
We’ll also discuss file and directory permissions, and the concept of full paths. At the end of the tutorial you’ll find a useful script to help you work out your full paths (essential for working with files).
This tutorial will also touch on some other Perl concepts such as while loops, lists, and appending strings to variables. It’s quite a long tutorial, but worth sticking with. By the end of it you’ll have learnt a lot of useful concepts, and you’ll be able to write your own CGI scripts to read and write files on your server!
Form Validation with Perl and CGI
In this tutorial we’re going to write a CGI script that checks whether a form has been filled out correctly. Along the way, you’ll also learn about the concepts of reentrant forms and Perl subroutines. Read on!