open PROUT, '/tmp/foo.csv';

my $old = '', $i = 2;
while (<PROUT>)
{
    
    chomp;
    my ( $id, $reg ) = split /,/;
    if ( $reg ne $old )
    {
	printf ( "&field%d_boolean=&field%d_post_p=1",
		 $i-1, $i-1 ) if $old;
	print "\">$old</a> |\n" if $old;
	print "<a href=\"https://adherents.april.org/admin/?action=perform_search&table=actor&start=0&limit=9999&field1_field=country&field1_is=is&field1_operand=is&field1_value=FRA&field1_boolean=and&field2_pre_p=1";
	$i = 2;
    }
    printf ( "&field%d_boolean=or", $i - 1 ) if $i != 2;
    printf ( "&field%d_field=departement&field%d_is=is&field%d_operand=is&field%d_value=%s",
	     $i, $i, $i, $i, $id, $i );
    $i++;
    $old = $reg;
}

printf ( "&field%d_field=departement&field%d_is=is&field%d_operand=is&field%d_value=%s&field%d_boolean=&field%d_post_p=1",
	 $i, $i, $i, $i, $id, $i, $i );
print "\">$old</a>\n" if $old;
