[ic] UserTag problem

Ed LaFrance edl@newmediaems.com
Tue, 14 Nov 2000 09:21:50 -0800


Albert -

I am no Usertag or Perl guru, but as far as I know, the return value can 
only be a scalar (not an array).  Instead of using @outf, substitute $outf, 
then:

if (-d $_) {
         $outf .= $_ . "\t";
         next;
}

...this should put the filenames in a tab-delimited string.  Then just call 
your usertag on a page and take a look, assuming the rest of your code is 
good, you should see a paragraph of filenames.  You can replace the "\t" 
with '<br>' to get an HTML formatted list of filenames directly from your 
usertag; no in-page [perl] needed.

- Ed L.


At 07:52 PM 11/14/00 +0200, you wrote:
>Hello!
>
>I want to write a UserTag but I got something wrong.
>My UserTag looks as follows and wonders to get a directory list of
>another directory:
>
>===============================================
>UserTag dirlist Order name
>UserTag dirlist Routine <<EOR
>sub {
>         my $dn=shift;
>         my @outf;
>
>                 my (@files) = glob("$dn/*");
>                 for(@files) {
>                         if (-d $_) {
>                                 push (@outf, $_);
>                                 next;
>                         }
>                 }
>return @outf;
>}
>EOR
>=================================================
>Then I tried to use it:
>
>[tmp dir]
>         [dirlist name='configdir']
>[/tmp]
>[perl]
>     $return = '';
>     my @list=$Scratch->{d};
>     for(@list) {
>         $return .= "dir = " . $_ ."<BR>";
>     }
>return $return;
>[/perl]
>=================================================
>Well, this returns something like:
>
>dir=6
>
>I discrouraged... 6 is a count of the directories in 'configdir'
>Can anybody helps me to answer where did I get wrong?
>
>--
>
>Albert Marx.
>
>_______________________________________________
>Interchange-users mailing list
>Interchange-users@www.minivend.com
>http://www.minivend.com/mailman/listinfo/interchange-users

 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
New Media E.M.S.               Software Solutions for Business
463 Main St., Suite D          edl@newmediaems.com
Placerville, CA  95667         http://www.newmediaems.com
(530) 622-9421                 (866) 519-4680 Toll-Free
 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>