in reply to Re: case sensitive addition
in thread case sensitive addition

This node was taken out by the NodeReaper on May 17, 2010 at 20:47 UTC

Replies are listed 'Best First'.
Re^3: case sensitive addition
by Limbic~Region (Chancellor) on May 14, 2010 at 23:29 UTC
    Nathan_84,
    I didn't provide any code - only the suggestion that you read the documentation. I probably would not write a perl program to do what you are doing, but if I were to modify your code - it would be something like the following (untested):
    #!/usr/bin/perl use warnings; use strict; print 'Enter a File name: '; chomp (my $file = <STDIN>); print 'Enter a search pattern: '; chomp (my $pattern = <STDIN>); open (my $fh, '<', $file) or die "Unable to open '$file' for reading: +$!"; my $found = 0; while (<$fh>) { if (/\Q$pattern\E/i) { print; $found++; } } print "\nTotal lines matched: $found\n";

    Cheers - L~R

      Hey I just wanted to say thanks for the quick response. Just tried your code and it worked a treat! Thanks again. My next challenge is to display a time and date when the search was carried out. Thanks again sir! :)
      Hi Limbic Region,
      I've been racking my brains out to just to add a simple data and time to script so that user can see when the search was performed.
      I found the script below as a standalone and worked perfectly fine. However trying to integrate it failed miserably!
      ($sec,$min,$hour,$mday,$mon,$year,$wday, $yday,$isdst)=localtime(time); printf "%4d-%02d-%02d %02d:%02d:%02d\n", $year+1900,$mon+1,$mday,$hour,$min,$sec;

      Please could you advise.
      Thanks

        Please, read some docs. Expend some effort on something other than asking questions already answered in those docs.

        Then, show some effort - read the key docs about PM:

        It is gratifying that you do appear to have read one usual element of a message such as this... that is, the admonition to use <code> tags. ++ for that; not so for the rest of your post.