Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8654597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:49:40+00:00 2026-06-12T14:49:40+00:00

RT4 allows for a new CustomField consisting of a validated ipv4 or ipv6 address,

  • 0

RT4 allows for a new CustomField consisting of a validated ipv4 or ipv6 address, and also allows for multiple values. This allows me to have an “IP Addresses” custom field that has several addresses for a ticket.

I cannot seem to get a scrip that will accept multiple addresses from an email (or any correspond event for that matter), only one address will be accepted.

The scrip I am using is a custom action that looks like this:

my $Ticket = $self->TicketObj;
my $Transaction = $self->TransactionObj;
my $body = $Transaction->Content();
my $cf = new RT::CustomField($RT::SystemUser);
my $id;
my $msg;
my $queue = 'Testes';

#---IPS
if($body =~ /X-addresses\:(.*)\n/i){
my $iplist = $1;
($id,$msg) = $cf->LoadByNameAndQueue (Name=>'addresses', Queue=>$queue);
($id,$msg) = $Ticket->AddCustomFieldValue (Field => $cf, Value =>$iplist);
}
return(1);

I’m not opposed to being told I’m going about this the wrong way; present practice for my RT install is to have a web form submit requests, currently that request will have an IP address field that is picked up by a similar scrip (in addition to x-fqdn, x-contact, x-OS, and other information being collected) and I was thinking a comma-seperated list of mixed ipv4,ipv6 could be snarfed in one line and, as long as RT’s address parser validated it, we’d be in business.

Any suggestions would be appreciated, except those that direct me to the hideous BestPractical wiki, I have combed through every tumbleweed-ridden page and come up empty.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:49:41+00:00Added an answer on June 12, 2026 at 2:49 pm

    The problem here is that you only perform the regex once, and only get the first match. You sound like you want to loop through and find as many matches as you can. To demonstrate I made some quick perl scripts (I don’t have my RT installation in front of me, so I have left out the RT specific stuff).

    The first works very similarly to yours, grabbing the first match and printing it:

    ~/perl/test$ cat testRegex.pl
    #! /usr/bin/perl
    
    my $body = <<END;
    X-Addresses:1.2.3.4
    X-Addresses:2.3.4.5
    X-Addresses:10.0.0.1
    some other text
    another line of content
    END
    
    if($body =~ /X-addresses\:(.*)\n/i){
            my $iplist = $1;
            print $iplist, "\n";
    }
    

    The output of this script is:

    ~/perl/test$ ./testRegex.pl
    1.2.3.4
    

    The second demonstrates the syntax you want to use:

    ~/perl/test$ cat testRegex2.pl
    #! /usr/bin/perl
    
    my $body = <<END;
    X-Addresses:1.2.3.4
    X-Addresses:2.3.4.5
    X-Addresses:10.0.0.1
    some other text
    another line of content
    END
    
    while ($body =~ /X-addresses\:(.*)\n/gi){
            my $ip = $1;
            print $ip, "\n";
    }
    

    The output for this script is:

    ~/perl/test$ ./testRegex2.pl
    1.2.3.4
    2.3.4.5
    10.0.0.1
    

    Instead of printing the $ip variable, you can pass it in to another function or method, such as AddCustomFieldValue.

    To explain: The regex is changed slightly to use the g (or global) switch, indicating that it will search through the entire string rather than stopping at the first match
    The if is changed to a while – you could probably do this with an if somehow – I just don’t know how. If you did, you would have to get all the matches in one variable – likely an array. After that you would need to iterate through the array anyway running AddCustomFieldValue for each element. My perl is not strong enough to figure it out using an if, but I think it’s a little more readable and neat with a while anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a piece of code below where it echos a salted password: $pass
I'm looking to merge customized code from RT3 into RT4, a Perl application. It
I have written dynamic insert part.When I excute he Insert statement into sqlite browser
Having some trouble figuring out why my ImageView buttons stop working after I change
GENERAL XML OUTLINE: <dasbhoards> <dashboard name=S1> <repository-location derived-from='http://dataviz.win.compete.com/workbooks/OTCSurvey_06_15_11_16_54/RT4?rev=' id='RT4' path='/workbooks/RetailFootwear' revision='' /> <style> </style>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.