Hi John, Please, check my comments below:
On Sun, Jun 10, 2012 at 12:23 PM, John M Rathbun <jmrath...@bellsouth.net>wrote: > Hello and thanks for volunteering your time! > > I'm returning to PERL after about a year and am struggling to remaster > some syntax: > > #!/usr/local/bin/perl > use warnings; > use strict; > use diagnostics; > > # Converts current directory to a list of links > > my @dir; > my $name; > my $i = 0; > > opendir DH, "." or die "\nCouldn't open current directory: $!\n"; > > while ($_ = readdir(DH)) { > next if $_ eq "." or $_ eq ".." or -d $_ or $_ eq "zlinks.pl" or $_ eq > "zout.txt"; > $dir[$i++] = $_; > } > > open FH, "> zout.txt" or die $!; > > If you want to iterate over the array index as shown by your code in the next two steps below: > foreach $i (@dir) { > my @title = split /\./, $dir[$i]; > write like so: foreach $i (0..$#dir){ my @title = split /\./,$dir[$i]; ## this will work now # My opinion: I don't know why you need the array @title like so: my @title = split /\./,$dir[$i]; only to use just the first index of the array as name like so: $name = $title[0]; > > print FH "<P ALIGN=CENTER><A HREF=\"$dir[$i]\" > TARGET=\"_blank\">$name</A></**P>\n"; > } > > > Interestingly, the program executes with the error but only considers the > first file it finds in the directory. If there are N files, it will print N > links, but all using the first file name. > I think you should also see comments posted by John W. in your previous post titled "Argument isn't numeric" Hope this helps -- Tim