wstarrs has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to join three variables with a string to form new, longer string with "_" in between each part, I have tried the Camel book and am not getting very far, is this the correct (or close to) the correct syntax?
$Launch.'_'.$Expire.'_'.$area.'_'.'description.asp';
In the end I want the final string to read: $Launch_$Expire_$area_description.asp as an asp file name. thanks, Bill

Replies are listed 'Best First'.
Re: Trying to join variables
by Masem (Monsignor) on May 18, 2001 at 23:04 UTC
    That will work (of course, you need to set a variable to equal that, or you get no results), but it might be easier to use the join function:
    $file = join '_', ( $Launch, $Expire, $area, 'description.asp');

    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
      Ok, so after that I am going to have three different possible $file variables and depending on certain conditions i want to return one of the three to be passed into another sub rountine, how can I set it up so that I can pass in the return value from my file sub whatever it is, to another sub and do it all in the main program, Something along these lines:
      #Run File sub routine that returns either file1, file2 or file3 #call next routine and pass in that returned value Next_sub(Whatever the returned value is..);
      I am just looking for a way to do this without calling the next sub routine from the file sub conditional statements, because both the routines need to be as general and reuseable as possible. Thanks
        # assume getFile returns the file1, file2, or file3
        Next_sub(getFile(@args));
Re: Trying to join variables
by runrig (Abbot) on May 18, 2001 at 23:31 UTC
    Just AWTDI: $file = "${Launch}_${Expire}_${area}_description.asp";
      YAWTDI:
      $file = "$Launch\_$Expire\_$area\_description.asp";
         MeowChow                                   
                     s aamecha.s a..a\u$&owag.print
Re: Trying to join variables
by blue_cowdawg (Monsignor) on May 19, 2001 at 00:28 UTC
    my $newstring=join("_",$Launch,$Expire,$area,'description.asp');

    Bad word, but I am assuming you don't really want the dollar signs in the resultant string.

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Peter L. Berghold --- Peter@Berghold.Net
    "Those who fail to learn from history are condemned to repeat it."