Search code examples
regexperlgentoo

Read a specific word in a file PERL using regex


I have a configuration file name movie.conf and i want to read a specific word in this file. The configuration file looks like this :

#This is a movie setting
#Read only the movie source

ffmpeg -f movie4linux2 -i /folder/movie1 -vcodec libx264 -preset ultrafast -tune zerolatency -s qvga -r 30 -qscale 5 -an -flags low_delay -bsf:v h264_mp4toannexb -maxrate 750k -bufsize 3000k -rfbufsize 300k -f h264

How can i only reads only the /folder/movie1 part by using regex? Can anybody show me how. I know using split can be done. But what if i want to use only regex on this? Any help would be much appreciated.


Solution

  • if (/^ffmpeg.*-i\s+(\S+)/) {
        print $1;
    }