CPAN Module Distributions
This code will work fine under UNIX and MacOS, but may result in a corrupted 
image under Windows. The reason is that by default Windows handles files in text 
mode. That means translating all CRLFs into CRs on input and the reverse on output. 
The problem is that since image.jpg is a binary file, it might well have CRLF sequences 
that aren't meant to be line endings. To safely handle binary data, you need to use 
the binmode() function:
open(IMAGE, "image.jpg") or die $!; # open the image file
binmode(IMAGE);                     # the image file is binary data
my $image = join(  ,);       # read the image data into $image
smooth($image);                     # smooth the image
binmode(STDOUT);                    # about to print binary data on STDOUT
print STDOUT $image;                # print out the image to the client
Notice that in this case binmode() is necessary on both IMAGE and STDOUT to avoid 
corrupting text mode translations.
Another place where line endings rear their ugly heads is in network pro 
gramming. Many network protocols state that lines must end in CRLF. The only way to 
be sure that you're ending your lines properly is to explicitly add the line ending bytes:
print SOCK "GET / HTTP/1.1\015\012";
In particular, using \r\n will not work since the setting for \n varies from system 
to system.
File Systems
Nothing varies as much between operating systems as file system usage. Every 
thing is up for grabs the path separator, maximum size of filenames, characters 
allowed in filenames, the number of  root  directories or  volumes,  the way 
network resources are named in the file system, and so on. Listing out all the vari 
ations would only serve to convince you that producing portable code that 
accesses the file system is impossible. Instead I'll just cut to the good news it is 
possible and it's not very hard at all.
Perl comes with a module called File::Spec
23
 that provides functions for 
manipulating filenames and paths. To get a list of available methods, read the
 documentation for the File::Spec::Unix module all the available subclasses 
support the same methods.
23. This module comes with Perl and was written by Kenneth Albanowski, Andy Dougherty, 
Andreas Koenig, Tim Bunce, Charles Bailey, Ilya Zakharevich, Paul Schinder, Shigio 
Yamaguchi, and Barrie Slaymaker.
12
123
3






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

web hosting perl

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved