Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

print array

by Anonymous Monk
on Aug 22, 2012 at 17:11 UTC ( #989100=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

hi monks, its crazy!!, but there is a problem that i cant find, please take a look!

#!/usr/bin/perl use warnings; use strict; my @month=qw(Jan Feb Mar May Apr Jun Jul Aug Sep Oct Nov Dec); Print @month;

Replies are listed 'Best First'.
Re: print array
by CountZero (Bishop) on Aug 22, 2012 at 17:12 UTC
    And your problem is?

    (other than you typed Print rather than print and you switched "Apr" and "May")


    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
Re: print array
by toolic (Bishop) on Aug 22, 2012 at 17:12 UTC
Re: print array
by ww (Archbishop) on Aug 22, 2012 at 19:02 UTC

    ... and, unless you want to print the list of months on a single line, without spaces, you may want to print (or, with a recent Perl, say) thru a for/foreach loop:

    ...(your lines 1 - 4)... for my $month(@month) { say $month; }

      Or on a single line with spaces.

      print "@month\n";

      (The default value for $OUTPUT_FIELD_SEPARATOR is space.)

      If say isn't available you can use 5.010 or just use feature 'say';

      If you just want a quick peek into an array, Data::Dumper is good for that or just print "$_\n" for @month

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://989100]
Approved by toolic
[marto]: Even with shell command recall I find it less time consuming to do such things in a file.
[marto]: I very seldom use one liners for anything which isn't utterly trivial
[Discipulus]: i'm wise enough to never use my oneliners
[Discipulus]: anyway marto, i read th CB logs.. osteopat is what you need

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2017-09-22 08:36 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (260 votes). Check out past polls.