[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PERL] perl reverse



ariel wrote:
> 
> Er der nogen der ved hvorfor det her ikke virker som forventet...
>         echo gimdnev|perl -lne 'print reverse'

> mens det her tilsyneladende er hvad der skal til...
>         echo gimdnev|perl -lne 'print "".reverse'

Fordi reverse i den første situation bliver kaldt i en liste kontekst,
mens den i den anden bliver kaldt i en scalar kontekst.

Du kan gøre det eksplicit med:

	echo gimdnev|perl -lne 'print scalar(reverse)'

Fra perlfunc(1)

      reverse LIST
               In list context, returns a list value consisting
               of the elements of LIST in the opposite order.  In
               scalar context, concatenates the elements of LIST
               and returns a string value with all characters in
               the opposite order.

-- 
René Seindal (sslug@sslug)			http://www.seindal.dk/rene/


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 19:52 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *