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";
d5e5
Practically a Posting Shark
810 posts since Sep 2009
Reputation Points: 159
Solved Threads: 159