top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to Auto Generate range of years using perl?

+2 votes
428 views

I have this simple script to automatically print HTML selection option.

#!/usr/bin/env perl
use strict;
for (reverse(1943 .. 1991)){
  print "$_n";}

I need to print all the years between 18 and 73 without hard coding the range in the for loop as in the above. I am considering the use of localtime to compute the current year as below $yr=(localtime), but I cant think of an easy way to achieved what I want to do.

posted Sep 17, 2013 by Garima Jain

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Check if the following works?

#!/usr/bin/env perl
use strict;
my ($min_yr, $max_yr);$min_yr =(localtime)[5] + 1900 - 18; $max_yr = (localtime)[5] + 1900 - 73;
for (reverse($max_yr .. $min_yr)){
 print "$_n";} 
answer Sep 17, 2013 by Luv Kumar
Similar Questions
+2 votes

I have this series of numbers:

349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,
373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,
425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,
449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,
473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496

there are two ranges in there: 349-396, 425-496. Any hints as to how to write a perl code to represent the series of numbers as a range?

0 votes

As I understand, Perl has excellent report-generation capabilities. By using formats, we can actually visualize how our output will look because the definition of a format in Perl is very similar to what you see on the output. Is there any way we to convert these formats into HTML reports? My goal is to create good looking HTML reports. Please suggest/advice.

+1 vote

I need to access ClearQuest programatically using Perl. I just found ClearQuest OSLC REST API. Client is planning to use ClearQuest web 7.1.1. I read that it comes with OSLC REST API out the box.
Can someone please provide me some examples on how I can access the CQ through Perl using this API.

...