#!/usr/bin/perl
use Error qw(:try);
use RT::Client::REST;
use RT::Client::REST::Ticket;
#define my parameteres
my $server = 'your server';
my $user = 'your RT user';
my $pass = 'your RT pass';
($argument1, $argument2) = @ARGV;

#Create Object
  my $rt = RT::Client::REST->new(server => $server, timeout => 30,);

#Login using credentials
  try {
    $rt->login(username => $user, password => $pass);
  } catch Exception::Class::Base with {
    die "problem logging in: ", shift->message;
  };

  try {
    my @qTicket = $rt->search(
        rt => $rt,
        type => 'ticket',
        query => "queue = 'Server Issues'",
        query => "Subject = '$ARGV[0]'",
        orderby => '-id',
    );
    for my $id (@qTicket) {
        $ticket = $rt->show(type => 'ticket',id => $id)or die $!;
         $rt->comment(
            ticket_id   => $id,
            message     => "Test",
          );
        print $ticket->{Subject} . ":" . $id . "\n";
    }
  } catch RT::Client::REST::UnauthorizedActionException with {
    print "You are not authorized to view ticket #10\n";
  } catch RT::Client::REST::Exception with {
    # something went wrong.
  };