Web Programming Tip –¬†JavaScript

Javascript: Ever wanted to have a “print” button inside your web page so the user doesn’t have to use the print button in the browser?? Well, here is a little code that will give it to. This small piece of Javascript invokes the browser’s print function directly. Cut and Paste this code for use:

<a href="Javascript:window.print();">PRINT</a>

Note: replace the “PRINT” label with other text or an image for the print button.

Perl: Parsing out the filename and/or path from a string can be tricky, but very useful. Check these out!

$filename =~ s/.*///;        - isolates filename
$path =~ s/.*/.*/$1/;        - isolates path

OR to get both:

if($string =~ /.*/.*/){
   $path = $1;
        $filename = $2;}