The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. April 24, 2019, 04:48:09 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Perl Read Directory Example  (Read 1448 times)
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« on: February 15, 2014, 05:21:02 AM »

# READ ALL THE FILE NAMES ENDING IN .txt

@some_array = <mydir/*.txt>;

# NOW YOU CAN PRINT THEM:
foreach $file (@some_array) {
  print "$file\n";
}


MY OUTPUT IS:
mydir/PERL_SNIPPETS.txt
mydir/PHP SNIPPETS.TXT
mydir/physics.txt
mydir/spanish.txt


You can read more about the <EXPR> glob function here http://perldoc.perl.org/functions/glob.html

Bompa
Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!