Perl sucks...go Ruby...I did and I am much happier! ----- Original Message ----
From: Michael Alipio <[email protected]> To: Perl Beginners <[email protected]>; John W. Krahn <[email protected]> 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 <[email protected]> wrote: > From: Michael Alipio <[email protected]> > Subject: Re: Turn off $ anchor greedy behavior > To: "Perl Beginners" <[email protected]>, "John W. Krahn" <[email protected]> > 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: > [email protected] > > For additional commands, e-mail: > [email protected] > > http://learn.perl.org/ > > > > > -- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > http://learn.perl.org/ -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/ -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
