Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Common Beginner Mistakes

by chromatic (Archbishop)
on Dec 15, 2000 at 04:40 UTC ( [id://46769]=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    foreach ($i = 1; $i < 10; $i++) {
        ${"record$i"} = $i * $i;
    }
    
  2. or download this
    for (1 .. 10) {
        push @records, $_ * $_;
    }
    ...
    foreach my $record (@records) {
        print $record, "\n";
    }
    
  3. or download this
    my $var1 = $query->param('var1');
    my $var2 = $query->param('var2');
    my $var3 = $query->param('var3');
    ...
    my $var8 = $query->param('var8');
    my $var9 = $query->param('var9');
    my $var10 = $query->param('var10');
    
  4. or download this
    $report = generate_report($foo);
    open(FILE, ">>report.txt") or die "blah!";
    print FILE "Report number: $i";
    ...
    @report_lines = split(/\n/, $report);
    print FILE $report_lines[0];
    # you see where this is going
    
  5. or download this
    my %vars;
    for (1 .. 10) {
        $vars{"var$_"} = $query->param("var$_");
    }
    
  6. or download this
    # change the form to use multiple selections with the same name
    my @vars = $query->param('var');
    # valid if you have a combobox or checkbox group
    
  7. or download this
    {
        my $num_displayed = 0;
    
    ...
    }
    
    }    # end of enclosing scope for $num_displayed
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 12:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found