sub new { my ($class) = @_; return bless {}, $class; } sub _get_script_path { my ($class, $script_name) = @_; # Resolve base directory dynamically my $base_dir = abs_path("$FindBin::Bin/.."); # One level up from bin my $script_path = File::Spec->catfile($base_dir, 'bin', $script_name); unless (-x $script_path) { die "Script $script_path does not exist or is not executable.\n"; } return $script_path; } sub download { my ($class, $hyperlink) = @_; die "No hyperlink provided.\n" unless $hyperlink; my $script_path = $class->_get_script_path("call_download.sh"); my $output; eval { $output = capturex("bash", $script_path, $hyperlink); }; if ($@) { die "Error executing $script_path with hyperlink $hyperlink: $@\n"; } return $output; }