> Hello list, > > I am trying to write my very own first "useful" program and I am in > need of some help. I do have a lot of ressources (a book by Andrew > Johnson, the yellow book for dummies and lots of hypertexts) but I > cannot seem to get things done the way they're supposed to work. I am > completely new to Perl and programming as well. > > So here's what I want to do: > I want to write a little script that will read the files from a > directory and make html links out of it. The data files look somewhat > like this: > > Datafile: > Linkname\tDescription\tURL\tLanguage > > Here's what I have so far: > #!/usr/bin/perl > use strict; > use diagnostics; > > #read filenames > my @filenames = glob"./data/*"; > print "filenames read...\n"; > #sort files > @filenames = sort @filenames; > print "@filenames\n"; > > #output link for every file > foreach my $filename (@filenames) { > open(FILE, $filename) or die "cannot open $filename!\n"; > while (<FILE>) { > #read every single lines and output HTML > print "$filename\n"; > } > close FILE ; > } > > My questions so far (please don't give me a complete solution, I wanna > work my way into Perl) is, why does the last print "$filename\n"; print > every filename twice? And how can I get rid of the directoy info up to > the last / (./data/perl.txt)? Will that require knowledge of the > mystical RegExp? > How can I get the tab delimited strings in my datafile into an array so > that I can access that array like this: print "<a > href="$hyperlink[3]">"; and so on? >
hello well i would use while (<FILE>) { my @hyperlink = split (/\//,$_,4); but i am only a begener too as for the #read every single lines and output HTML print "$filename\n"; why are you printing $filename ? do you not want the content of the file in which case $_ would do as it would containe the text from the file you just read. sorry about my bad spelling hope this helps Ritchie > I hope this is not too trivial, but I've been trying to nail things > down for the last two days, I am glad I found this diagnostics option > but now I am stuck.. > > Any help is greatly appreciated! > > Stephan - who has never written a programm before. > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]