in reply to how are ARGV and filename strings represented?

If you just type any word, @ARGV will contain that word unless it appears to be a file name with asterisk, because in that case, you will get a list of file names. I don't know if the shell is responsible for this or if Perl does this, but here is an example:
(owner)~# perl -e ' foreach (@ARGV) { print "\n$_"; } ' hello world *

hello
world
BIN
Desktop
Documents
Downloads
HTML
JSRef
Music
PerlRef
Pictures
Public
SAFE
Scripts
temp
Templates
Videos
(owner)~# 

The above one-liner will list all files in the current directory, because I included one asterisk in the argument line.

EDIT: One piece of advice I would have is try to avoid working with files that have any Unicode characters in the file name. I made a little program that renames all files on my computer to standard ASCII names. I had so much trouble with such filenames until I said, "You know what? I'm done with that. I shall never use Unicode chars in file names ever agian." Why make your life difficult for no reason? Avoid trouble and stop using Unicode chars in file names. It's that simple. It's the truth. Someone had to say it.

  • Comment on Re: how are ARGV and filename strings represented?

Replies are listed 'Best First'.
Re^2: how are ARGV and filename strings represented?
by ikegami (Patriarch) on May 01, 2024 at 18:36 UTC

    That's entirely the shell's doing.

Re^2: how are ARGV and filename strings represented?
by soonix (Chancellor) on May 02, 2024 at 09:25 UTC
    That depends on the shell. If that shell happens to be CMD.EXE or COMMAND.COM (I *think* also Powershell.exe and pwsh.exe), the asterisks you type in arguments have to be handled by Perl, because DOS/Windows has a differenct concept of command lines, probably inherited from CP/M or so.
Re^2: how are ARGV and filename strings represented?
by Anonymous Monk on May 02, 2024 at 09:45 UTC
    This 'advice' is so bad. Someone had to say it.