I need some help. I have figured out most of my script but I need to search a string and see if it starts with certain characters and Does not end in another.

[$line1 = "EB*1**96" #should produce true value and blank line]
[if ($line1 =~ /^EB\*/ and $line1 ne /Y$/) {$line1 = "";}]
[print $line1]

Should print blank line or nothing

[$line1 = "EB*1**96*Y" #should produce False ]
[if ($line1 =~ /^EB\*/ and $line1 ne /Y$/) {$line1 = "";}]
[print $line1]

Should print EB*1**96*Y

I need to blank the line if it starts with EB* and the string does not end in Y


Any help would be appreaciated

In biterscripting,

var string text, line1, c12, clast
cat "/path/to/somefile.html" > $text
# Get the first line.
lex -p "1" $text > $line1
# Get first two chars.
chex -p "2]" $line1 > $c12
# Get the last char.
chex -p "l" $line1 > $clast
# Is $c12 "EB" and $clast is NOT "Y" ?
if ($c12=="EB") AND ($clast <> "Y")
do
    # Blank out $line1
    set $line1 = ""
    # Put $line1 back into $text
    lal "1" $line1 $text > null
    # Write file back.
    echo $text > "/path/to/somefile.html"
done
endif

I need some help. I have figured out most of my script but I need to search a string and see if it starts with certain characters and Does not end in another.

[$line1 = "EB*1**96" #should produce true value and blank line]
[if ($line1 =~ /^EB\*/ and $line1 ne /Y$/) {$line1 = "";}]
[print $line1]

Should print blank line or nothing

[$line1 = "EB*1**96*Y" #should produce False ]
[if ($line1 =~ /^EB\*/ and $line1 ne /Y$/) {$line1 = "";}]
[print $line1]

Should print EB*1**96*Y

I need to blank the line if it starts with EB* and the string does not end in Y


Any help would be appreaciated

#!/usr/bin/perl
#
use strict;
use warnings;

my $line1 = "EB*1**96";
my $line2 = "EB*1**96*Y";

#If string starts with EB and ends with any character other than Y
# then delete the string.

$line1 =~ s/^EB.*[^Y]$//;
$line2 =~ s/^EB.*[^Y]$//;

print '$line1 is ' . "$line1 \n";
print '$line2 is ' . "$line2 \n";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.