Hi, How to detect if there is ( = ) sign in current line? thank you.
$_ = $currentLine;
if (Include =)
{
# do some thing
}
else
{
# do another thing
}
Hi, How to detect if there is ( = ) sign in current line? thank you.
$_ = $currentLine;
if (Include =)
{
# do some thing
}
else
{
# do another thing
}
local $_ = $currentLine;
if (/=/) {
or
if ($currentLine =~ /=/) {
my $currentLine; # presumably this has a value from something earlier
if ($currentLine =~ /=/)
{
# line has an = in it
}
else
{
# it doesn't
}
Read about the =~ operator at perldoc perlop, and regular expressions at perldoc perlre.
The simplest way is to use index:
if ( index( $line, '=' ) > -1 ) {
It's faster than a regex, because it's done on the C-level, without any compiliation. If you're looking in Perl code, you probably don't care if there is an equals sign on a comment line, therefore there's this:
$line =~ m/^[^#]*=/;
If that doesn't suit your needs, then use the first.