Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. wxb2744

    Splitting text into lines

    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...
  2. wxb2744

    Splitting text into lines

    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...
  3. wxb2744

    Help with RegEX Match issue

    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...
  4. wxb2744

    Help with RegEX Match issue

    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...
  5. wxb2744

    regex not working with double quote. very baffled!

    ahhh, got it now =) Warren
  6. wxb2744

    regex not working with double quote. very baffled!

    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...
  7. wxb2744

    regex not working with double quote. very baffled!

    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...
  8. wxb2744

    Cartalk Puzzler: The Palindromic Odometer

    How about this? for ( 99999 .. 999996 ){ print "$_\n" if is_palindrome( $_, 2, 4 ) and is_palindrome( $_ + 1, 1, 5 ) and is_palindrome( $_ + 2, 1, 4 ) and is_palindrome( $_ + 3, 0, 6 ); } sub is_palindrome { ( $number, $start, $len ) = @_; $str = sprintf("%06d", $number ); return...
  9. wxb2744

    Extracting multiple matches

    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 =~...

Part and Inventory Search

Back
Top