every

Perl string character processing - How to process every character in a string

Perl string processing FAQ: How can I process every character in a Perl string?

I recently had to write some Perl code to process every word in a file, and that made me wonder how to process every character in a Perl string. I didn't know how to do this, but I just cracked open my copy of the Perl Cookbook, and found a couple of possible solutions.

How to print every element in a Perl array

Summary: A Perl for loop (foreach loop) example, showing how to loop over each element in a Perl array.

Many times you'll need to print all the elements of a Perl array, or perhaps the elements of the array that match some filtering criteria. I thought I'd share several examples of how to print the elements of a Perl array here.

Initial setup

In each of the methods shown below, assume that we have an array named @pizzas that has been defined like this:

Perl - How to process every file in a directory

A common Perl FAQ is "How do I do (something) for every file in a directory?"

Here's some sample code that will show you how to loop through each file in a directory:

Create an AppleScript list with the every keyword

AppleScript “list” FAQ: How do I do something for every item in an AppleScript list? (or, How do I loop over an AppleScript list?)

Loop over an AppleScript list with the every keyword

I've shown examples of the AppleScript every keyword in other posts, so rather than create anything new, here's a repeat of one of those examples: