one key hash

Eugene Tsyrklevich eugenet at mailcity.com
Fri Feb 25 00:35:54 CST 2000


~sdpm~
see http://www.perl.com/CPAN-local/doc/manual/html/pod/perldata.html#Scalar_values

and

http://www.perl.com/CPAN-local/doc/manual/html/pod/perlre.html
or
man perlre
or
perldoc perlre

for regular expressions discussion.
check out 'mastering regular expression' book for even more info.. it's kinda outdated but still covers a lot of ground



you might also wanna bookmark

http://www.perl.com/CPAN-local/doc/manual/html/pod/



cheers.



On Fri, 25 Feb 2000 12:14:22   C. Abney wrote:
>~sdpm~
>On Thu, 24 Feb 2000, Bob Forgey wrote:
>
>> ... I would probably use
>>         keys(%foo_h)[0]
>> instead of the `each %foo_h', just to be explicit.
>
>I tried that and couldn't get it to work.  Made sense to me too, otherwise.
>It's a bit wordier than mine, but tells you exactly what you want to do.
>I even tried it with a symref... :(
>
>> I presume you're using `tar tvf ...', which is the reason for the map
>> function, instead of a chomp?
>
>Yes, and that it'll also work with (for example) long file listings, or
>ftp->ls(), or...
>
>my root dir test was really messed up, though.  Here's a mod on the 
>script (and in usable form!)
>
>============================================================
>#! /usr/bin/perl
># Takes output from a tarball manifest listing and checks that only one
># toplevel directory/file exists.
># just do a 'tar tvfz bar.tar.gz | onekeyhash.pl'
>
>@flist = map +(split)[-1], <>;
>
># Danger: tar Pczf bar.tar.gz meme proxy /vmlinuz
># this grabs the topmost directory/file name(s) from the tar manifest
>for (@flist) { $foo_h{$1}++ if m|([^/]+)|; $augh++ if m|^/|; };
>
>die "someone's out to get you\n" if ( $augh );
>
>die "more than one topmost directory or file\n" if ( keys (%foo_h) != 1 );
>
>$top = each (%foo_h);
>
>print "topmost directory: $top\n";
>============================================================
>
>Thanks for the tips...
>
>CA



MailCity. Secure Email Anywhere, Anytime!
http://www.mailcity.com
~sdpm~

The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.




More information about the San-Diego-pm mailing list