On Tue, 2008-12-09 at 15:35 -0500, David Shere wrote: > Hello. I'm not a new perl programmer, but I feel like one today. I > want to pull the last octet off of an IP address and print it to > standard output. I have this so far: > > @octets = split(/\./, $ipAddress); > print pop(@octets); > > Which works great. I have no other use for @octets, so I should be able > to just pass the results of split() right to pop(): > > print pop(split(/\./, $ipAddress)); > > However, I get the error message > > Type of arg 1 to pop must be array (not split) at ./oct.pl line > 8, near "))" > > I realize I need to make sure the results of split() are an array before > they're passed to pop(). Fine. However, > > print pop(@{split(/\./, $ipAddress)}); > > prints nothing. split() *does* return an array, right? Why can't pop > take it?
print '', (split( /\./, $ipAddress ))[-1]; -- Just my 0.00000002 million dollars worth, Shawn The key to success is being too stupid to realize you can fail. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/