Perl - get first “word” from input string

后端 未结 2 494
广开言路
广开言路 2021-01-11 15:44

I am trying to write a Perl program that reads in lines from a text file, and, for each line, extract the first \"word\" from the line, and perform a different action based

2条回答
  •  情深已故
    2021-01-11 16:20

    ($start) = $inputline =~ /\A([^:\s]+)/;
    

    This will match anything except whitespace and : at the beginning of the line.
    Or using split:

    ($start) = split /[:\s]+/, $inputline, 2;
    

提交回复
热议问题