home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!reed!romulus!merlyn
- From: merlyn@romulus.reed.edu (Randal L. Schwartz)
- Newsgroups: comp.lang.perl
- Subject: Re: Filename expansion ("~user")
- Message-ID: <MERLYN.92Aug21092257@romulus.reed.edu>
- Date: 21 Aug 92 16:23:01 GMT
- Article-I.D.: romulus.MERLYN.92Aug21092257
- References: <1992Aug20.153727.167@cbnews.cb.att.com>
- Sender: news@reed.edu (USENET News System)
- Distribution: usa
- Organization: Reed College
- Lines: 22
- In-Reply-To: daleske@cbnews.cb.att.com's message of 20 Aug 92 15:37:27 GMT
-
- In article <1992Aug20.153727.167@cbnews.cb.att.com> daleske@cbnews.cb.att.com (John D. Daleske) writes:
- If I set $tst1 to the full pathname it works fine. I'd like to use the common
- facility of ~user to avoid needing to know the full path name. (User home
- directories do get moved around.)
-
- There's nothing in the Unix kernel that understands the tilde hack
- (introduced by the C-shell, and copied to half a dozen other bezerkley
- utilities).
-
- Fetching the home directory is easy enough though:
-
- $file = "~merlyn/.newsrc";
- $file =~ s#^~([a-z0-9]+)(/.*)?$#(getpwnam($1))[7].$2#e;
-
-
- (If you mess with $[, you deserve what you get. :-)
-
- for('a'..'z','A'..'Z'){*XX=$_;$XX=$_;}print"$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $h$a$c$k$e$r,"
- --
- Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
- merlyn@reed.edu (guest account) merlyn@ora.com (better for permanent record)
- cute quote: "Welcome to Portland, Oregon -- home of the California Raisins!"
-