Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Just to expand a bit on the answers given:

#!/usr/bin/perl use strict; use Win32::File; my $hidfnm = 'hideme.txt'; my $getatr = 0; my $getret = &Win32::File::GetAttributes($hidfnm, $getatr); if ($getret) { if ($getatr & HIDDEN) { print "File is hidden. Unhiding\n"; } else { print "File is not hidden. Hiding\n"; } # Toggle the HIDDEN flag my $setatr = ($getatr ^ HIDDEN); my $setret = &Win32::File::SetAttributes($hidfnm, $setatr); } __END__

Results:

D:\PerlMonks>hide1 D:\PerlMonks>echo>hideme.txt This is a test. D:\PerlMonks>dir Volume in drive S is SteveData Volume Serial Number is 78B4-33A0 Directory of D:\PerlMonks 07/09/2016 12:38 AM <DIR> . 07/09/2016 12:38 AM <DIR> .. 07/09/2016 12:38 AM 88 hide1.bat 07/09/2016 12:41 AM 448 hide1.pl 07/09/2016 12:41 AM 17 hideme.txt 3 File(s) 553 bytes 2 Dir(s) 29,695,066,112 bytes free D:\PerlMonks>perl hide1.pl File is not hidden. Hiding D:\PerlMonks>dir Volume in drive S is SteveData Volume Serial Number is 78B4-33A0 Directory of D:\PerlMonks 07/09/2016 12:38 AM <DIR> . 07/09/2016 12:38 AM <DIR> .. 07/09/2016 12:38 AM 88 hide1.bat 07/09/2016 12:41 AM 448 hide1.pl 2 File(s) 536 bytes 2 Dir(s) 29,695,066,112 bytes free D:\PerlMonks>perl hide1.pl File is hidden. Unhiding D:\PerlMonks>dir Volume in drive S is SteveData Volume Serial Number is 78B4-33A0 Directory of D:\PerlMonks 07/09/2016 12:38 AM <DIR> . 07/09/2016 12:38 AM <DIR> .. 07/09/2016 12:38 AM 88 hide1.bat 07/09/2016 12:41 AM 448 hide1.pl 07/09/2016 12:41 AM 17 hideme.txt 3 File(s) 553 bytes 2 Dir(s) 29,695,066,112 bytes free D:\PerlMonks>


In reply to Re: Hidden file attribute in Win32 by marinersk
in thread Hidden file attribute in Win32 by bitman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-23 04:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found