User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 456,539 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,158 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 829 | Replies: 4
Reply
Join Date: Sep 2007
Posts: 4
Reputation: padmaja_3 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
padmaja_3 padmaja_3 is offline Offline
Newbie Poster

Problem with concatenation

  #1  
Oct 11th, 2007
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.
--

Thanks,
Padmaja T N.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2006
Posts: 1,517
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 10
Solved Threads: 136
masijade's Avatar
masijade masijade is online now Online
Posting Virtuoso

Re: Problem with concatenation

  #2  
Oct 11th, 2007
try
$fullDate = join( "/", $ARGV[3], $ARGV[4], $ARGV[5]);
or
$fullDate = join( "/", $ARGV[3..5] );
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Sep 2007
Posts: 4
Reputation: padmaja_3 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
padmaja_3 padmaja_3 is offline Offline
Newbie Poster

Re: Problem with concatenation

  #3  
Oct 11th, 2007
Hi,
Again its performing division only. Pls suggest me how to proceed.
--

Thanks,
Padmaja T N.
Reply With Quote  
Join Date: Feb 2006
Posts: 1,517
Reputation: masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light masijade is a glorious beacon of light 
Rep Power: 10
Solved Threads: 136
masijade's Avatar
masijade masijade is online now Online
Posting Virtuoso

Re: Problem with concatenation

  #4  
Oct 11th, 2007
$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.
Last edited by masijade : Oct 11th, 2007 at 5:16 am.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Mar 2006
Posts: 642
Reputation: KevinADC is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 36
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Master Poster

Re: Problem with concatenation

  #5  
Oct 11th, 2007
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Perl Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Perl Forum

All times are GMT -4. The time now is 4:53 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC