in reply to Re^2: Undefined subroutine error while using R within Perl
in thread Undefined subroutine error while using R within Perl

You don't show the call to setup_R but, from the code you've posted, I get the impression that you're expecting those various use statements to occur at that time. They don't! They occur at compile time. See:

Perhaps require would be a better choice. See:

"The reason I have not used strict at the beginning is that it makes my program to have more errors."

Sorry, but that's completely incorrect. strict only reports problems; it doesn't create them.

— Ken