views:

189

answers:

3

I writing programing with Perl and XS. I need to display and do some operations that use a linked list from C. How can I accomplish that?

+2  A: 

Write a C function to serialize the linked list as a string, or better yet write a set of functions: new_list, destroy_list, add_item, remove_item, walk_list (should take a function reference and call it on each item in the list). Then you could say things like:

my $list = $new_list;
add_item $list, 5;
add_item $list, 6;
add_item $list, 7;
walk_list $list, sub { print $_[0] }; #prints 567
destroy_list $list;
Chas. Owens
+4  A: 

I have to say you could have provided a bit more information to make it easier for people to help you.

Anyway. Despite the age, I would suggest you look at the CookBookA and CookBookB examples in Dean Roehrich's CPAN directory. Specifically, in the CookBookB set, you will find an example that does exactly what you ask for: 'ListOfStruct'.

tsee
+1  A: 

perldoc Inline

Ether