From: Matt Howard <mhoward@sigins.com>
To: linux-admin@vger.kernel.org
Subject: Re: Perl
Date: Mon, 19 Apr 2004 14:47:01 -0500 [thread overview]
Message-ID: <c61aem$uan$1@sea.gmane.org> (raw)
In-Reply-To: 016b01c417ad$d246e8a0$020aa8c0@Scott
Scott@Charter wrote:
> Can anyone please help me with a short example Perl script that will print
> out all the odd numbers between 1 and 10? I don't know Perl and am trying
> to learn it. I wrote a bash script to do the same thing and wanted to
> compare it.
>
> There must be a Perl expert out there somewhere who can help me?
>
> Thanks-
> Scott
foreach ( 1 .. 10 ) {
print "$_ " if ($_ % 2 == 1);
}
".." is an operator that will return a list that is the range between left
and right. foreach will run the code block for each item of the list,
setting $_ to that item. print ... if does like it sounds, and % is the
modulo operator, in other words, it returns the remainder if the % had been
a /.
I hope this helps you, and I apologize for the unkind responses you have
received from the list here.
If you have any perl questions, you may try http://www.perlmonks.org
--
Matt Howard <mhoward@sigins.com>
Superior Insurance - Technical Services
prev parent reply other threads:[~2004-04-19 19:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-01 5:54 Perl Scott@Charter
2004-04-01 5:29 ` Perl tyler
2004-04-01 6:54 ` Perl Scott@Charter
2004-04-01 7:25 ` Perl Richard Nairn
2004-04-01 8:20 ` Perl Dan Kubilos
2004-04-01 14:51 ` Perl Adam Lang
2004-04-01 18:48 ` Perl Bradley Hook
2004-04-05 2:30 ` Perl Bradley D. Thornton
2004-04-05 5:09 ` Perl Bradley D. Thornton
2004-04-05 6:10 ` Perl Nico Schottelius
2004-04-05 6:39 ` Perl Scotts Charter
2004-04-05 13:03 ` Perl Adam Lang
2004-04-19 19:47 ` Matt Howard [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='c61aem$uan$1@sea.gmane.org' \
--to=mhoward@sigins.com \
--cc=linux-admin@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).