New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement a new var @*ARGFILES listing paths for @*ARGS that are existing files #2666
Comments
|
What does "if the file exist" mean to different users? Does it exist at the time the program starts? Does it exist at the moment it is iterated over by A naive solution: |
|
In my naive view, I see $*ARGFILES reflecting the current file state of CLI @*ARGS when the program starts. That's the only way I've used Perl scripts (P5 or P6) in my years of use since 1993. |
|
I think a better solution is what you suggested, but make it a new dynamic variable: @*ARGFILES. It would be created along with @*ARGS but would just contain the paths of input args that are valid files. I’m renaming and rewording this issue. |
|
@ugexe It simply means valid filehandles. Right now, as Tom has indicated, $*ARGFILES does create a filehandle for non-existing or invalid files, only nothing can be done with it other than capturing the exception when it's used. |
I couldn't find a way to deal with them, as indicated in #96 and rakudo/rakudo#2666. I asked [this question in SO](https://stackoverflow.com/questions/54501546/dealing-with-invalid-filehandles-and-maybe-other-invalid-objects-too), will reopen if there's some answer that does not involve catching the error. Meanwhile, closes #96
|
Feels to me |
|
Yes, then that would satisfy my use case and be a very useful tool, especially if I could iterate it like this: |
|
@JJ It was a rhetorical question. What “valid file handle” means isn’t so clear; backlog the chat channel the last few days to see others with a similar informed opinion and explanation. |
The Problem
Iterating over $*ARGFILES throws an error if the system tries to get a handle on a non-existent file.
Expected Behavior
Ability to iterate over only valid file handles as the name implies.
Actual Behavior
Throws on non-existent files.
Steps to Reproduce
Environment
Debian 9, 64-bit.
$ perl6 -v
This is Rakudo version 2018.06 built on MoarVM version 2018.06
implementing Perl 6.c.
Solution
Create the new dynamic variable simultaneously with the creation of @*ARGS. It should contain the paths of the elements of @*ARGS that are existing, readable files.
The text was updated successfully, but these errors were encountered: