Nik has asked for the wisdom of the Perl Monks concerning the following question:
I t seems fine. $file takes either a random value or what the user selected from the drop down menu but then i beleive the it wont open the file....because i had print "@data"; after the close and its empty. Dow you know why? The code seems correct though....files = <../data/texts/*>; foreach (@files) { $_ =~ s/.*[\/\\](.*)/$1/; } print start_form(-action=>"index.pl"); print p( {-align=>'center'}, font( {-size=>5, -color=>'Lime'}, 'Λόγ +ος Ψυχωφελής και Θαυμάσιος => ' ), popup_menu( -name=>'select', -values=> +\@files ), submit('ok')); print end_form(); $file = param("select") or $files[int(rand(@files))]; open(IN, "<../data/texts/$file") or die $!; @data = <IN>; close(IN); $data = join("", @data); $data =~ s/\n/\\n/g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: cant open file correcly
by davido (Cardinal) on May 21, 2004 at 16:11 UTC | |
|