Re: Passing hash ref [ was Re: finding head and tail in data structure

2013-01-11 Thread budi pearl
Hi Jim, On Fri, Jan 11, 2013 at 1:54 PM, Jim Gibson wrote: > OR > > print_path( $id, $routes->{$id} ); > ... > sub print_path > { > ... > while( my ($start, $end) = each %$edges ) { > > This is what i want, thank you! Apparently passing "$routes->{$id}" is my earlier issue. --budi

Re: Passing hash ref [ was Re: finding head and tail in data structure

2013-01-10 Thread Jim Gibson
On Jan 10, 2013, at 7:33 PM, budi pearl wrote: > Hi All, > > I would like to pass hash: %{$routes{"ROUTE-252"}} instead of %routes but > got this error: > > [budi@dev bin]$ ./print_path.pl > Type of arg 1 to each must be hash (not hash element) at > ./print_path.plline 38, near "}) " > Executio

Re: Passing hash ref [ was Re: finding head and tail in data structure

2013-01-10 Thread budi pearl
On Fri, Jan 11, 2013 at 11:05 AM, budi pearl wrote: > Hi Shawn, > > When trying to accessed inside subroutine , i got: > > Type of arg 1 to each must be hash (not hash element) at ./print_path.plline > 41, near "}) " > > Execution of ./print_path.pl aborted due to compilation errors. > > > this

Re: Passing hash ref [ was Re: finding head and tail in data structure

2013-01-10 Thread budi pearl
Hi Shawn, When trying to accessed inside subroutine , i got: Type of arg 1 to each must be hash (not hash element) at ./print_path.plline 41, near "}) " Execution of ./print_path.pl aborted due to compilation errors. this is work: while (my ($start, $end) = each %{$routes{$label}}) { but thi

Re: Passing hash ref [ was Re: finding head and tail in data structure

2013-01-10 Thread Shawn H Corey
On Fri, 11 Jan 2013 10:33:02 +0700 budi pearl wrote: > my $id = "ROUTE-252"; > print Dumper $routes{$id}; > > print_path($id, \%{$routes{$id}}); I think you want: print_path( $id, $routes{$id} ); -- Don't stop where the ink does. Shawn -- To unsubscribe, e-mail: beginners-unsubs

Passing hash ref [ was Re: finding head and tail in data structure

2013-01-10 Thread budi pearl
Hi All, I would like to pass hash: %{$routes{"ROUTE-252"}} instead of %routes but got this error: [budi@dev bin]$ ./print_path.pl Type of arg 1 to each must be hash (not hash element) at ./print_path.plline 38, near "}) " Execution of ./print_path.pl aborted due to compilation errors. #use

Re: finding head and tail in data structure

2013-01-10 Thread budi pearl
Hi Rob, This works and looks much more simpler. Thanks, i love it. --budhi On Fri, Jan 11, 2013 at 1:00 AM, Rob Dixon wrote: > On 10/01/2013 10:01, budi perl wrote: > >> Hi, >> >> I have this following hash: >> >> #!/usr/bin/perl >> # >> use strict; >> use Data::Dumper; >> >> my %MYROUTES = (

Re: finding head and tail in data structure

2013-01-10 Thread Rob Dixon
On 10/01/2013 10:01, budi perl wrote: Hi, I have this following hash: #!/usr/bin/perl # use strict; use Data::Dumper; my %MYROUTES = ( "ROUTE-252" => { # src => dest 427 => "ABEP", "ABEP" => 441, 441 => 427, 427 => 444, 444 => "MGWQ",

Re: finding head and tail in data structure

2013-01-10 Thread budi pearl
On Thu, Jan 10, 2013 at 5:19 PM, David Precious wrote: > On Thu, 10 Jan 2013 17:01:43 +0700 > budi perl wrote: > You can't have the same hash key twice; you've duplicated 427 there. > > Also, you don't need to quote the left side of a fat comma, so you can > just as easily say e.g. ABEP => 441. >

Re: finding head and tail in data structure

2013-01-10 Thread David Precious
On Thu, 10 Jan 2013 17:01:43 +0700 budi perl wrote: > Hi, > > I have this following hash: > > #!/usr/bin/perl > # > use strict; > use Data::Dumper; > > my %MYROUTES = ( > "ROUTE-252" => { > # src => dest >427 => "ABEP", >"ABEP" => 441, >441 => 427, >427

finding head and tail in data structure

2013-01-10 Thread budi perl
Hi, I have this following hash: #!/usr/bin/perl # use strict; use Data::Dumper; my %MYROUTES = ( "ROUTE-252" => { # src => dest 427 => "ABEP", "ABEP" => 441, 441 => 427, 427 => 444, 444 => "MGWQ", "MGWQ" => "CDEF" }, "ROUTE-432" => {