CARVIEW |
Select Language
HTTP/2 200
cache-control: max-age=43200
server: Combust/Plack (Perl)
vary: Accept-Encoding
content-encoding: gzip
content-length: 1925
content-type: text/html; charset=utf-8
last-modified: Sat, 11 Oct 2025 15:49:47 GMT
traceparent: c25dd16831b3564c890e3858ce2b7df1
strict-transport-security: max-age=15768000
Re: Removing files called minus (was: MAGIC MAGIC MAGIC) - nntp.perl.org
Front page | perl.perl5.porters |
Postings from July 2008
nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About

Re: Removing files called minus (was: MAGIC MAGIC MAGIC)
Thread Previous | Thread NextFrom:
Aaron CraneDate:
July 30, 2008 07:09Subject:
Re: Removing files called minus (was: MAGIC MAGIC MAGIC)Message ID:
20080730140927.GA26857@aaroncrane.co.ukTom Christiansen writes: > For those who don't want <ARGV> to handle special filenames, the > simplest, most straightforward, and least disruptive approach is > for them to map the filenames in @ARGV using code along the lines > shown above. Something like this would be easy enough: > > for (@ARGV) { > s!^(?=\s)!./!; # leading whitespace preserved > s/^/< /; # force open for input > s/\z/\0/; # trailing whitespace preserved & pipes forbidden > } That's not always sufficient for those with such a desire. Suppose you need to report the name of the file being processed to the user. Conveniently enough, Perl gives you the $ARGV variable with which to do that. Except that once you've munged @ARGV to dispell the dweomer, you're no longer reporting the filename supplied by the user. That might be acceptable for onlooking humans, but probably less so for other programs trying to consume your output. I can quite imagine that the trailing \0 in particular might cause problems. That can be worked around, of course: my %real_name; for (@ARGV) { my $orig = $_; # Tom's munging code, verbatim: s!^(?=\s)!./!; # leading whitespace preserved s/^/< /; # force open for input s/\z/\0/; # trailing whitespace preserved & pipes forbidden $real_name{$_} = $orig; } And now you can use $real_name{$ARGV} in place of $ARGV throughout your program. (Which might be tricky if some of the uses are buried down in modules which you can't easily change.) -- Aaron Crane ** https://aaroncrane.co.uk/Thread Previous | Thread Next
- Removing files called minus (was: MAGIC MAGIC MAGIC) by Tom Christiansen
- Re: Removing files called minus (was: MAGIC MAGIC MAGIC) by Aaron Crane
- Re: Removing files called minus (was: MAGIC MAGIC MAGIC) by Zefram
- Re: Removing files called minus (was: MAGIC MAGIC MAGIC) by Tels
- Re: Removing files called minus (was: MAGIC MAGIC MAGIC) by David Nicol
- Re: Removing files called minus by Mark Mielke
- Re: Removing files called minus (was: MAGIC MAGIC MAGIC) by Aristotle Pagaltzis
- RE: Removing files called minus (was: MAGIC MAGIC MAGIC) by Ed Avis
nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About