http://www.perlmonks.org?node_id=863265


in reply to perl string extract

Please ignore this node.

Something like this?

use strict; use warnings; my $line = 'logfile = filename , abcd=eflk , cxd'; my $file; if ($line =~ /logfile\s*\=\s*(.+?)\s*\,?/){ $file=$1; } print "logfile=$file"; output: ======= logfile=filename
Updated: Misunderstood the question. Added '?' after comma to make it optional.

eyepopslikeamosquito++ Thanks.

Prasad