All of lore.kernel.org
 help / color / mirror / Atom feed
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


  parent reply	other threads:[~2004-04-19 19:47 UTC|newest]

Thread overview: 36+ 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]
  -- strict thread matches above, loose matches on Subject: below --
2006-11-15  7:22 Perl Adrian
2006-11-15 16:21 ` Perl Lee Revell
2006-11-13 22:56 Perl Lee Revell
2006-11-14 16:28 ` Perl Kim Phillips
2006-11-14 16:39   ` Perl Lee Revell
2006-11-14 16:48     ` Perl Brent Cook
2006-11-14 17:08 ` Perl Wolfgang Grandegger
2006-11-14 17:42   ` Perl Lee Revell
2006-11-14 21:50     ` Perl Wolfgang Denk
2006-11-20  4:21       ` Perl Leonid
2006-11-20  8:34         ` Perl Wolfgang Denk
2006-11-20 14:12           ` Perl Leonid
2006-11-20 15:28             ` Perl Leonid
2006-11-14 18:20   ` Perl Lee Revell
2006-11-15  5:54     ` Perl David H. Lynch Jr.
2006-11-14 21:07 ` Perl Wolfgang Denk
2006-11-23  7:26 ` Perl Matthias Fuchs
2006-11-23 23:00   ` Perl Wolfgang Denk
2006-11-24 11:23     ` Perl Matthias Fuchs
2006-12-01 15:50 ` Perl Clemens Koller
2002-12-04 19:24 Perl Alan Womack
2002-12-04 15:48 Perl Paul Kraus
2002-12-05  6:56 ` Perl ichi

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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.