Extracting data slice from an array

This is the problem statement I am trying to solve.
I have a packet data stored in an array.
In the packet array, there is a field in the header that can be of variable length.

I am trying to extract this field. I don’t have the code handy now but I use something like this rougly

hdr_len = packet_array[0:7]; 
x_header = {>>{packet_array[`START_X_HDR+:hdr_len];

This gives an error that array range has to be a constant expression.
This is expected as I do understand that LRM enforces this rule.
But I am looking how to resolve this issue.
Any options/directions is highly appreciated.

Thanks,

In reply to verif_learner:

There’s always a for-loop.

In reply to dave_59:

Dave,

Thanks. So, array slicing cannot be done using variable at all?
No exceptions?

In reply to verif_learner:

See 11.4.14.4 Streaming dynamically sized data

In reply to dave_59:

In reply to verif_learner:
See 11.4.14.4 Streaming dynamically sized data

Thanks, Dave. This works for a small example.

I am pasting the code hoping it helps someone:

module mod;
  int arr_1[10] = {1,2,3,4,5,6,7,8,9,10};
  int arr_2[];
  int size = 5;
  
  initial
    begin
      arr_2 = new[size];
      arr_2 = {>>int{arr_1 with [0+:size]}};
      
      $display ("%p %p", arr_1, arr_2);
    end
endmodule