in reply to foreach inside print

It looks like you need $_ instead of $file in your example, but try this:

print table( {-width=>"90%", -align=>"center", -style=>"border: ridge +lightgreen +; color: yellow; font-size: 18", -background=>"../data/images/blue.jp +g"}, map { Tr( td( {-align=>'center'}, font( {-size=>5, -color=>'white'}, b +( $_ )) +))); Tr( {-align=>'center'}, td( submit( $_ ))))); } @files;

Replies are listed 'Best First'.
Re: Re: foreach inside print
by Nik (Initiate) on May 18, 2004 at 12:22 UTC
    Thank you very much!
    I though i was using $_ already but i mistaken used $file,
    Another problem is that i want to get rid of all the paths in front of the filenames. so the user can see only the filename it self. All files are stored inside the array @files like this: Can a substitute operator be applied to an array it slef or it can only be used in single variebles.
    @files = <../data/texts/*.txt>; $file = $files[int(rand(@files))];
    now the filenames is like this:
    ../data/texts/filename1.txt
    ../data/texts/filename2.txt
    ../data/texts/filename3.txt
    ../data/texts/filename4.txt
    ../data/texts/filename5.txt
    and so on
    can i use a s/// operator to get rid of the paths?

      You can do it with a substitution, but that's not really a good idea, and difficult to make portable. Instead, use File::Basename, and the basename or dirname methods.

    A reply falls below the community's threshold of quality. You may see it by logging in.