in reply to system function not handling string properly

Can you show what $link contains? It seems to work pretty well with echo, the only problem on my system is if $link is one of -n, -e, -E, or their combination (e.g.-eEn), which are interpreted as options to bash's builtin echo.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: system function not handling string properly
by hermes1908 (Novice) on Sep 06, 2013 at 21:21 UTC
    $link does not contain any such characters. If you run the script on the sample sql file I linked to, the result is "www.youtube.com/watch?v=mark"
      Try running a hexdump on the string. It seems it is UTF-16 encoded, there is a zero byte after each character. echo probably takes the null char as the end of string as in C.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        In this case I would be really interested in

        print Dumper($link);

        ;)

Re^2: system function not handling string properly
by Anonymous Monk on Sep 08, 2013 at 09:27 UTC
    Actually, since system is called correctly, the shell won't be invoked and it'll be the real echo(1) which only parses the -n option (AFAIK). Anyway, it's better to use something like printf(1) since it tends not to have surprising behaviour: system('printf', '%s', $link);