Thanks feherke, but I spent most of yesterday looking into it and I got the code down to: -
my $text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco...
Hi,
This is more a challenge then a question really.
I'm wanting to print some long lines out to a terminal, but I don't want the terminal to cut words in half as they wrap to the next line. Essentially I want to be able to split on the last word boundary before, say, 80 characters. I cannot...
Personally, I think one of the most important aspects of a script is readability. If it is easier to read then it is easier to understand and therefore easier to maintain.
The .*? approach is easier/simple to understand and still effective and therefore elegant. Opinions may differ, but that...
I know this has already been answered, but I think there is a more elegant solution.
The problem is that regular expressions are usually greedy; meaning that they match the biggest possible string. This can, however, be changed by adding a ? after quantifier specifiers (?, +, . or {}) to make...
I beg to differ. I tested this before posting and it worked on my system. The whole script was: -
undef $/;
$inFile = do{ local $/; <DATA> };
print "BEFORE: $inFile\n";
$findStart = qr/\"START\"/;
$replaceStart = "replace string";
$inFile =~ s/(?<=$findStart)/\n$replaceStart/g;
print "AFTER...
Try: -
$findStart = qr/\"START\"/;
$replaceStart = "replace string";
$inFile =~ s/(?<=$findStart)/\n$replaceStart/g;
qr// tells perl that you want to use the string in a regexp.
The (?<=$findStart) is a zero-width look behind. It essentially finds "START" and then inserts \n$replaceStart...
I am trying to extract information from a text file and am having problems extracting the matches.
The sample file is: -
zone: zone_name
50:06:0e:80:04:58:1d:04
10:00:00:00:c9:6a:11:02
and the regular expression is: -
( $file =~...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.