top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to Auto Generate range of years using perl?

+2 votes

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:


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.