Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 25th, 2012, 10:51 PM
lie_soul lie_soul is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 7 lie_soul User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 17 m 17 sec
Reputation Power: 0
(2) Questions regarding the [Hash] and [Reading a directory]

I have two questions.

1) I'm trying to let the user type his "directory path" (perl example.pl /Users/name/file) in order to show the files or directory folder, i also wanted to show if the file or directory can or cannot be read, written, and executed


This the code i came up with.. but i still wanted to know if i can find the way of indicating if the file or directory and if it can or cannot be
read, written, and executed. I also wanted to make sure about what i making is good on other systems ( Linux/Unix/Mac)

Code:
#!/usr/bin/perl -w

use strict;

my $dir = shift || die "Argument missing: Please make sure from your directory name\n";

my $dir = "..";
opendir DIR, $dir;
my @values = readdir(DIR);
closedir DIR;

foreach (@values) { 
  printf "$_ is a file\n" if -f "$dir/$_"; 
  printf "$_ is a dir\n" if -d "$dir/$_"; 
}



2) Question 2, i want to print out elements of hash and i want to use different ways of listing them.. just as each funiction, keys function,
values function and finaly sort keys.. and what i did was the following code and i don't know where is my problem...

$A = user input..
$B = user input..

Code:
#!/usr/bin/perl -w

use strict;

print  "Enter A: ";
$A = <STDIN>;
chomp $A;
print  "Enter B: ";
$B = <STDIN>;
chomp $B;

my %hash = ( 
             'A' => "$A", 
             'B'  => "$B", 
             'Z' => 'Z', 
             'D' => 'D', 
			 'H' => 'H', 
            );
			
print "A:     $hash{ 'A' }\n";
print "B:       $hash{ 'B' }\n";
print "Z:     $hash{ 'Z' }\n";
print "D:    $hash{ 'D' }\n";
print "H:  $hash{ 'H' }\n";



These are the 2 questions that i'm facing problem with...

Thanks

Reply With Quote
  #2  
Old September 26th, 2012, 09:55 AM
FishMonger FishMonger is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2009
Posts: 1,687 FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level)FishMonger User rank is General 3rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 23 h 38 m 29 sec
Reputation Power: 1170
Cross posted on perlguru

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > (2) Questions regarding the [Hash] and [Reading a directory]

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap