How to identify a special character in a line while reading a file & then post process it for further computation in systemverilog?

Following is a sample file that I have which has a combination of addresses and data on individual lines,

  1. @0
  2. 1A
  3. 1B
  4. @C
  5. 2D

I would like to understand if I can implement the following steps while reading the above file in systemverilog testbench or if there are alternatives to do this,
A) Identify the lines with @ symbol & then identify the associated address value.
B) Add the address value (Ex: C from @C) to a base address.
C) Run a for() loop until the next address is hit while reading the file and then repeat A, B & C.

I am trying with $readmemh(), but stuck in step-A.

In reply to RMK:

You can use $fscanf to read each line into a string. You can check the first character of the string to see if it is a “@”. Then you can use $sscanf to convert the string from a hexadecimal to a binary representation.