Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Printing from three arrays

by BillKSmith (Monsignor)
on Sep 26, 2019 at 22:47 UTC ( [id://11106774]=note: print w/replies, xml ) Need Help??


in reply to Printing from three arrays

You should start every perl program with:
use strict; use warnings;

The purpose is to help you solve you own problems. In this case, you will get several error messages. Some of them will not make any sense to you. Fix the easy ones and try again. You probably have fixed more than you thought. You may have also revealed a few more errors. Keep fixing errors a few at a time until it runs. If you really get stuck, ask for explanation of your remaining errors. Your current script probably will not run correctly even when it does run. You may have to ask for help again. It is much easier for the monks to find a fix you logic errors when they are not masked by other errors.

Another hint is to use meaningful variable names. Note the improvement in this solution.

use strict; use warnings; my @digits = qw(1 2 3); my @letters = qw(a b c d e f g); my @romans = qw(I II III); foreach my $letter (@letters) { foreach my $roman (@romans) { foreach my $digit (@digits) { print "$digit,$letter,$roman\n"; } } }
Bill

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11106774]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-04-23 16:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found