🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.d
Article #5074

Re: perl question about > in file name

#5074
From: Larry Wall
Date: Mon, 05 Jun 1989 23:37
24 lines
1596 bytes
In article <123@zip.eecs.umich.edu> don@zippy.eecs.umich.edu (Don Winsor) writes:
: Does anyone know if there is any way to make "perl" read from a
: file whose name begins with a ">" character?  This question arose
: from a discussion I was had about whether a perl script could
: replace a C program for some simple operations on arbitrarily
: named files.  At first, I though it could, but then this issue of
: files with names beginnning with characters in the set [<>|+] came
: up.  I know this is a strange and rare situation, but I'd like to
: be able to handle it should it arise.  The "perl" manual says:
: 
:     If the filename begins with <" or nothing, the file
:     is opened for input.  If the filename begins with
:     ">", the file is opened for output.  If the filename
:     begins with ">>", the file is opened for appending.
: 
: This seems to preclude any nice way to access files whose names
: may contain arbitrary characters.  Is there any way around this?

Yes, simply put an explict < on the front of the string.

open(FOO, "<$filename");

Larry Wall
lwall@jpl-devvax.jpl.nasa.gov
Technical Details
Message-ID: <5054@jpl-devvax.JPL.NASA.GOV>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!ames!elroy!jpl-devvax!lwall
References: <123@zip.eecs.umich.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!ames!elroy!jpl-devvax!lwall
From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall)
Newsgroups: comp.sources.d
Subject: Re: perl question about > in file name
Keywords: perl
Message-ID: <5054@jpl-devvax.JPL.NASA.GOV>
Date: 5 Jun 89 23:37:24 GMT
References: <123@zip.eecs.umich.edu>
Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall)
Organization: Jet Propulsion Laboratory, Pasadena, CA.
Lines: 24