#!/usr/local/bin/perl # Copyright (c) 2002 Michael Scheel. All rights reserved # See license.txt in the GetLocation distribution for details # Version: 0.1? This is just my first stab at perl and Cocoa/ObjC use Foundation; $defPrefFile = NSString->stringWithCString_("/var/db/SystemConfiguration/preferences.xml"); $setKey = NSString->stringWithCString_("CurrentSet"); $nameKeySuffix = NSString->stringWithCString_("UserDefinedName"); $networkDict = NSDictionary->dictionaryWithContentsOfFile_($defPrefFile); $setStr = $networkDict->objectForKey_($setKey); # returns /Sets/0 or something like that as an object (NSString hopefully) # turn that into a perl string $setPath = sprintf ("%s",$setStr->cString()); # split that for the path @setPathList = split("/",$setPath); # ditch the leading shift @setPathList; # add on the last item (append this to path to get the final result below) push (@setPathList, "UserDefinedName"); # walk the path tree down $content = $networkDict; foreach $p (@setPathList) { $content = $content->objectForKey_($p); } # The last item (UserDefinedName) is the string we are after $loc = sprintf ("%s",$content->cString()); print "$loc\n";