in reply to Changing -> to work within a string

Why not write a function that takes care of the concatenation? All the users have to do is call this function with as many parameters as they want, and it will return the concatenated string.
my $directory = concat($machine->work_dir, "/subdir/", $machine->softw +are_version, "/");
Or is this too difficult for the users to understand?

Replies are listed 'Best First'.
Re: Re: Changing -> to work within a string
by davis (Vicar) on Mar 19, 2003 at 13:36 UTC

    my $directory = concat($machine->work_dir, "/subdir/", $machine->software_version, "/");

    That sounds an awful lot like perl's built in join function, called like so:

    my $directory = join "", $machine->work_dir, "/subdir/", $machine->sof +tware_version, "/";

    cheers
    davis
    It's not easy to juggle a pregnant wife and a troubled child, but somehow I managed to fit in eight hours of TV a day.
      In fact, it is. I suggested writing a function that takes care of this because:

      1. you can alter the function in the future
      2. you can give it a more user-friendly name if wanted

      Regards,
      Marcel