List Info

Thread: Need SORT & SUBSTR help please




Need SORT & SUBSTR help please
user name
2006-11-21 19:36:05
7:25pm, Luinrandir Hernsen wrote:

> Keys = sort {$a cmp $b} substr(Keys,9,);
>
> I want to sort an array starting at the 9th character
> of each string in the array.
> I have a feeling i'm missing a delimiter, maybe????
>

substr returns a string, not a list--so using on a list
(array) isn't going 
to get you anywhere. You want to use it on the $a and $b
variables instead.

Paul


Unsubscribing info is here: h
ttp://help.yahoo.com/help/us/groups/groups-32.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://g
roups.yahoo.com/group/perl-beginner/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http
://groups.yahoo.com/group/perl-beginner/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:perl-beginner-digest@yahoogroups.com 
    mailto:perl-beginner-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    perl-beginner-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 

Need SORT & SUBSTR help please
user name
2006-11-21 19:52:34
On Nov 21, 2006, at 2:36 PM, Paul Archer wrote:

> 7:25pm, Luinrandir Hernsen wrote:
>
>> Keys = sort {$a cmp $b} substr(Keys,9,);
>>
>> I want to sort an array starting at the 9th
character
>> of each string in the array.
>> I have a feeling i'm missing a delimiter, maybe????
>>
>
> substr returns a string, not a list--so using on a list
(array)  
> isn't going
> to get you anywhere. You want to use it on the $a and
$b variables  
> instead.
>
> Paul

sorted = sort { substr($a,8) cmp substr($b,8) } Keys

The characters of a string are indexed from 0, so the 9th
character  
is at index 8.

-Rob

Rob Biedenharn		http://agileconsultingl
lc.com
RobAgileConsultingLLC.com




Unsubscribing info is here: h
ttp://help.yahoo.com/help/us/groups/groups-32.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://g
roups.yahoo.com/group/perl-beginner/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http
://groups.yahoo.com/group/perl-beginner/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:perl-beginner-digest@yahoogroups.com 
    mailto:perl-beginner-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    perl-beginner-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )