Hi all,
I'm beginner in Perl. I need to concatenate three values in the date format like,

$fullDate = $ARGV[3] . "/" . $ARGV[4] . "/" . $ARGV[5];

But while concatenating, it is performing division on values. I have tried '.',':','-'. But its not working.
Pls suggest me how to proceed.

Recommended Answers

All 4 Replies

try

$fullDate = join( "/", $ARGV[3], $ARGV[4], $ARGV[5]);

or

$fullDate = join( "/", $ARGV[3..5] );

Hi,
Again its performing division only. Pls suggest me how to proceed.

$fullDate = join( "/", "$ARGV[3]", "$ARGV[4]", "$ARGV[5]");

or

$fullDate = "$ARGV[3]" . "/" . "$ARGV[4]" . "/" . "$ARGV[5]";

you might want to do $ARGV[5] += 1900; before hand, though.

Edit: And really, you're not trying very hard yourself, if you don't even give something this simple a try.

Edit again: And don't forget to do $ARGV[4]++; beforehand as well, since month is, of course, zero based (i.e. Janauary is 0 not 1).

Edit a third time: Of course, the math opertions are only needed if those values are coming from a localtime() or gmtime() call, rather than from user input, or some other source where the values may already be properly adjusted.

plus this question is cross-posted on another perl forum where it has many replies. The OP obviously has no clue, there is no way the code posted would perform division. The forward slashes are strings not operators.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.