Well, I don't know Perl, but I do know GSL.
Statemens in your code are in a wrong order.
1) Allocate 6 bins
gsl_histogram* h=gsl_histogram_alloc(6);
2) Set the ranges. 6 bins require 7 points. (you have 6)
double ranges
7={1.,2.,3.,4.,5.,6.,7.};
gsl_histogram_set_ranges(h,ranges,7);
3) And only after initialization one can use the histogram
4) In C one should free the histogram after using it. No idea about Perl.