lau bella [mailto:[EMAIL PROTECTED]] wrote:

> 1. How to list files in a directory in perl ? e.g. in UNIX, use 
> "ls *.txt" command.

Lots of different ways. One approach is:

my $dir = 'your_dir_here'; # ie. 'C:/bob/my files/working'
opendir(WD, "$dir") or warn "Warning: Could not access $dir: Reason $! \n";
my @file_list = grep { /*.txt/ } readdir(WD);

will result in @file_list contains all files that end in .txt

> 2. For a variable = " this is a test files ". 
> How to substitute space at beginning and end of variable, so that the 
> variable become = "this is a test files"

Assuming $string has the string:
$string =~ s/^\s+//; # remove leading whitespace
$string =~ s/\s+$//; # remove trailing whitespace

cheers,
bj

--
Brad Warkentin CAD Manager
Email: [EMAIL PROTECTED] AcceLight Networks
Phone: 613.596.4804 x4388 26 Auriga Drive, ON
Fax: 613.596.2399 K2E 8B7
Get your free @yahoo.com.hk address at Yahoo! Mail.
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to