Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: My Perl Obfuscator

by jwkrahn (Abbot)
on Jan 12, 2024 at 01:16 UTC ( [id://11156906]=note: print w/replies, xml ) Need Help??


in reply to My Perl Obfuscator

sub ReadTheEntireFile { my $F = defined $_[0] ? $_[0] : ''; $F =~ tr`<>*?\"\|\x00-\x1F``d; # Remove illegal characters. length($F) or return ''; # Missing file name? -e $F and -f $F or return ''; # Make sure file exists. my $SIZE = -s $F; # Get file size. $SIZE or return ''; # Return zero bytes. my $BUF = ''; # Read buffer local *FILE; sysopen(FILE, $F, 0) or return ''; # Open file for read only. my $L = sysread(FILE, $BUF, $SIZE); # Read the entire file close FILE; return $BUF; }

Again, you don't need both file tests to know if a file exists.

$L contains the amount of data returned from the file. You should compare that value to $SIZE to verify that the entire file has been returned.

Naked blocks are fun! -- Randal L. Schwartz, Perl hacker

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11156906]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-05-18 17:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found