I am writing an interface to Netbackup's bpdbjobs command (by reading from a pipe). I want to tokenize each line into subcomponents, however, it is possible that some fields in the middle could be null at any given iteration: Here is a sample input:
388347 Backup Done 73 hostx-a_fs_u01 incr 000:15:20 hostx 05/09/05 19:40:37 000:56:02
388349 Backup Done 0 dbs050_hosty_hot.full full 9786112 5942 000:37:40 hosty 05/09/05 19:25:17 000:37:43
As you can see the integer fields in the middle can be blank, however, I still want to tokenize this with those fields being empty strings. (if I split using (split / +/, $line) I will not get the behavior I desire.
my( $jid, $jtype, $jstat, $jcode, $jpol, $jsched, $jprog, $jperf, $jstart, $jclnt, $jsdate, $jstime, $jdur) = split(/ +/, $_);
This above statement will assign the job start time ( 000:15:20 for line 1 of the sample above) to the $jprog variable for lines that contain the null values. What I need is for it to assign an empty string in that case.
What approach can I use to achieve this?