I need to create an array that contains a list of the files in a directory. I know it needs to be a comma separated list, and I tried using join, but couldn't get it to work the way I hoped it would. I used the following code:
When I print $fnames[0], I want to get the first element in the array, but I get the entire array (without commas). Can someone tell me what I'm doing wrong?
Thanks....
Code:
#!/usr/bin/perl
2 @fnames = system ls;
3 @fnames = join (",",$fnames);
4 print $fnames[0];
Thanks....