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

this code:
if ( !-e $save_file ) { if ( $access eq "Open" ) { ( $http, $trash, $website, $directory, $guid ) = split ( '/', $d +lFile ); $url = $dlFile; } else { ( $http, $trash, $website, $gii, $sharing, $rest, $content, $ite +ms, $guid ) = split ( '/', $dlFile ); my $test = "123456781234567890abcdefghijklmnopqrstuvwxyz"; $url = $dlFile . $test; print "url=$dlFile$test\n"; } }

produces this output:

123456781234567890abcdefghijklmnopqrstuvwxyzest/content/items/7a85ce53fe11466985515207b6d48dde/data?token=

I want it to product this output:

https://outerim.com/gii/sharing/rest/content/items/7a85ce53fe11466985515207b6d48dde/data?token=123456781234567890abcdefghijklmnopqrstuvwxyz

for some reason I can not figure out the $test variable is being appended to the start of the $dlFile variable and not the end.

Any help is greatly appreciated.

Replies are listed 'Best First'.
Re: Concatination Issue
by choroba (Cardinal) on Dec 01, 2016 at 14:25 UTC
    Your $dlFile value ends with a "\r" which is interpreted as "return to the leftmost column without a newline" by your terminal. This happens often when the input has MS-DOS-like line ends (also common on MSWin). Possible fix:
    $dlFile =~ s/\r$//;

    You can use Data::Dumper to verify the suspicion:

    use Data::Dumper; $Data::Dumper::Useqq = 1; print Dumper($dlFile);

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

      Wow, first one out of the chute nails it. Thanks choroba