-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
-
-use strict;
-use warnings;
-
-use CGI;
-use Encode qw(encode);
-
-use Mail::Sendmail;
-use MIME::QuotedPrint;
-use MIME::Base64;
-use C4::Auth;
-use C4::Biblio;
-use C4::Items;
-use C4::Output;
-use C4::VirtualShelves;
-use C4::Members;
-
-my $query = new CGI;
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+
+use CGI qw ( -utf8 );
+use Encode;
+use Carp qw( carp );
+use Try::Tiny qw( catch try );
+
+use C4::Auth qw( get_template_and_user );
+use C4::Biblio qw(
+ GetBiblioData
+ GetFrameworkCode
+ GetMarcAuthors
+ GetMarcBiblio
+ GetMarcISBN
+ GetMarcSubjects
+);
+use C4::Items qw( GetItemsInfo );
+use C4::Output qw( output_html_with_http_headers );
+use Koha::Email;
+use Koha::Patrons;
+use Koha::Virtualshelves;
+
+my $query = CGI->new;
+
+# if virtualshelves is disabled, leave immediately
+if ( ! C4::Context->preference('virtualshelves') ) {
+ print $query->redirect("/cgi-bin/koha/errors/404.pl");
+ exit;
+}