in reply to Re: how do i do this?
in thread how do i do this?
The special variable for array interpolation is $". It is what you would need to set to change what happens in your print statement.
However, anytime you hear "special variable" you need to realize that they are global, and you should avoid changing their global value. This can be done by localized them inside of an enclosing block. If you don't do this, you will introduce hard-to-track-down bugs in other parts of your program. Here is an example using the tips above....
#!/usr/bin/perl -wT use strict; { local $, = ', '; my @sorted_args = sort @ARGV; print @sorted_args; } print "\nBack to normal: ", @ARGV, "\n"; { local $" = '-'; my @sorted_args = sort @ARGV; print "@sorted_args"; } print "\nBack to normal: @ARGV\n"; =OUTPUT % ./sortedargs.pl c a b a, b, c Back to normal: cab a-b-c Back to normal: c a b
-Blake
|
|---|