Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

The .. operator explained

by Cine (Friar)
on Aug 05, 2003 at 17:49 UTC ( #281102=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    for (1 .. 100) {
      # Do something with $_, which will start with the value 1,
      # increasing by one for every loop and stopping with the value 100.
  2. or download this
    for ('a' .. 'z') {
      # $_ will start with the value 'a', then 'b' all the way up to 'z'
      # $_ will start with the value 'aa', then 'ab', then 'ac' up to
      # 'az', then 'ba' and finally 'bb'
  3. or download this
    while(<>) {
      print if 1 .. 5; #Print lines 1 trough 5 including.
  4. or download this
    while(<EMAIL>) {
      my $body = /^$/ .. eof; #First blank line in email is start of body
      print "looking at line ",int$body," in the body\n" if $body;
      print "looking at line ",int$header," in the header\n" if $header;
  5. or download this
    while(<>) {
      my $line = /\S/ ... /^$/;
      print "$line:$_" if $line && $line!~/E0$/;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://281102]
Approved by dragonchild
Front-paged by dragonchild
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2014-12-20 02:43 GMT
Find Nodes?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?

    Results (95 votes), past polls