SPUG: 4 Quick Questions (symlinks, anon. arrays, shell commands...)

Ryan Erwin ryan at erwin.org
Fri Sep 17 13:07:48 CDT 1999

Question 1:
Say i have a hash: %hash
The current key of the hash is $_, accessed by $hash{$_}.
I have values qw(x y z) that I want to push into an anonymous
array in the value of $hash{$_}.  I can't remember how!

Question 2:
Say my file system contains this: ( -> is a symlink )
/bin/file2 -> ../usr/bin/file1
/bin/file3 -> /usr/bin/file1
/bin/file4 -> ../usr/../usr/../usr/bin/../bin/file1
/bin/file5 -> /usr/bin/../../usr/bin/file1
/bin/file6 -> file2

How can I resolve where these links are pointing to?  The only
way that I have figured out is to chdir to the directory that
contains the symlink i'm reading, strip out the path given by
readlink, then chdir to the path.  Then I still don't know how
to get the working directory without using the shell (`pwd`).

Question 3:
Is there a way to find the current working directory from perl
without using pwd in backticks?  ( my $dir = `pwd` )

Question 4:
Is there a way to find out what a file is dynamically linked
with besides using ldd in backticks?  ( my $_ = `ldd $file` )

If you want more of the why i'm doing this, continue reading...
I'm creating a little utility to figure out different files on
my system depend on other files.  The program takes a list of
complete file names on STDIN and checks if they are executable. 
If they are executable, I `ldd some_executable_file` to check
what it depends on.  I want to store the data then I'll figure
out how to manipulate it so that I can output it in the most
logical way for what I'm doing (trying to build a new distro
from scratch...  absalute minimal use of existing binaries) 


Ryan Erwin [ryan at erwin.org]

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address

More information about the spug-list mailing list