Perl sucks...go Ruby...I did and I am much happier! ----- Original Message ----
From: Michael Alipio <daem0n...@yahoo.com> To: Perl Beginners <beginners@perl.org>; John W. Krahn <jwkr...@shaw.ca> Sent: Tuesday, April 14, 2009 10:06:39 AM Subject: Re: Turn off $ anchor greedy behavior Aha, found it.. The split returned a list and you've just sliced it. giving [-1] means the list will start running through the elements backwards. --- On Tue, 4/14/09, Michael Alipio <daem0n...@yahoo.com> wrote: > From: Michael Alipio <daem0n...@yahoo.com> > Subject: Re: Turn off $ anchor greedy behavior > To: "Perl Beginners" <beginners@perl.org>, "John W. Krahn" <jwkr...@shaw.ca> > Date: Tuesday, April 14, 2009, 10:02 PM > > > > Or use split and return the last field: > > > > $ perl -le' > > my $string = "boy, pig, 123, 123:412adbd, d0g, > > lajdlf134><<_ lkadsf !234,\n"; > > my $value = ( split /,\s+/, $string )[ -1 ]; > > Another mind bogling example... :-) > I thought I would do: > > my @value = ( split /,\s+/, $string ); > print $value[6]; > > How could your example, have printed the last field using [ > -1 ]? > Can I also print say, the 3rd field using this trick? > > > > > > > > print $value; > > ' > > lajdlf134><<_ lkadsf !234 > > > > > > > > > > > > John > > -- Those people who think they know everything are a > great > > annoyance to those of us who do. -- Isaac > Asimov > > > > -- To unsubscribe, e-mail: > beginners-unsubscr...@perl.org > > For additional commands, e-mail: > beginners-h...@perl.org > > http://learn.perl.org/ > > > > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/