RSS .92| RSS 2.0| ATOM 0.3
  • Home
  • About Me
  • My Publications
  • My Work Domain
  • phpResource Feeds

    Fastest Solution to Count Number of Lines Inside a File

    August 23rd, 2006

    Here is another PERL stuff to share.

    Many systems have a wc program to count lines in a file:
    $count = `wc -l < $file`; die "wc failed: $?" if $?; chomp($count); ------------------------------- You could also open the file and read line-by-line until the end, counting lines as you go: open(FILE, "< $file") or die "can't open $file: $!"; $count++ while ;
    # $count now holds the number of lines read

    Here’s the fastest solution, assuming your line terminator really is “\n”:

    $count += tr/\n/\n/ while sysread(FILE, $_, 2 ** 16);

    Enjoy PERL. Enjoy Programming.

    Browser Detection by PERL

    August 23rd, 2006

    I am enjoying PERL a lot. I am seeing everything new in PERL. I want to share interesting and important PERL stuffs through my blog.

    Here is a PERL subroutine that detects whether the browser is Firefox or NOT.

    sub is_firefox {
    my $agent = ”;
    $agent = $ENV{“HTTP_USER_AGENT”} || ”;
    if (length($agent) && $agent =~ m/firefox/si) {
    return 1;
    return 0;

    Enjoy PERL, the scripting pioneer.


    Important Issues in Sending HTML Email

    August 8th, 2006

    If you want your HTML email to put into recipient’s INBOX, you have to follow some rules.
    Following are some important issues for sending HTML email:

    1. Remove unnecessary HTML tags:

    Remove these tags from your mail content:
    – <html>, </html>
    – META Tag
    – HEAD
    – BASE
    – LINK
    – TITLE
    – Comments

    2. Use table for layout

    Because of the very limited support of style sheets in webmail clients, the best and safe way to layout your html e-mail is to use tables.

    3. Use Online Image

    4. Hide Image Toolbar

    5. Use Shortcut URLs:
    URLs of email should be short/small.

    6. Dont Use Anchors

    7. Use Simple Inline Stylesheet

    For example:
    <td style=”font-family: Verdana, Arial, Helvetica, sans-serif; font-size:
    10px;” >Vivamus ut sem. Fusce aliquam nunc vitae purus. </td >

    8. Create your design with a white background color

    Most webmail and e-mail clients use a white background color to display messages.

    <td bgcolor=”#FF0000″>

    9. Use the title attribute instead of alt

    The alt attribute for images doesn’t work in Gecko-based browsers such as Firefox and Mozilla

    10. Use <br /> instead of <p>

    11. Don’t use forms

    12. Don’t use _JavaScript:
    _JavaScript in HTML e-mail is never a good idea because of all the dangerous scripting (for example XSS attacks) that can be executed. For this reason most webmail and e-mail clients disable _JavaScript by removing or ignoring it.

    13. Provide a link for display in the browser

    14. Keep Your Subject Short and Informative

    15. Don’t Use DHTML and Flash

    16. Send your e-mail as multipart/alternative

    If you send a HTML e-mail to people with a webmail or e-mail client who can’t read HTML e-mail, they will only see the HTML code. If you don’t know what your recipients use, send your e-mail as multipart/alternative. This is the HTML version and the plain text version.

    These issues greatly affect the HTML email. Currently I am working on a project where the emails must have to be sent to INBOX. I got success following these issues. I am researching more on that.


    Nurul Islam, Our Brother :: Save Him

    August 3rd, 2006

    Nurul Islam, A fourth year Electrical Enginerring student of Rajshahi University of Engineering & Technology (RUET), is suffering from kidney damage problem. Doctors’ tests said that his both kideneys are damaged. A lot money is needed to save Nurul from this condition. But his family can’t afford that. So people from the different levels of the society are trying to help Nurul. Can’t we help Nurul to get life back to this nice world ? Or should not we try to save Nurul Islam ?

    See the innocent face of Nurul Islam. Our minimal combined contribution can save a thousands of Nurul Islam. Please broaden your hands, let Nurul keep among us.

    Please contribute as much as you can to save our brother Nurul Islam.

    To help Nurul Islam, please send your contribution to:
    Saving account no – 34115593
    Dilkusha Corporate Branch, Dhaka.

    Please forward this content to others.