473,383 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

access mode int->string

Hello
I have file acces mode as number for example: 755,
and i want to change it to text for example: -rwx------
Is there any module/function for that ?

Thanx

Jul 19 '05 #1
3 5009
vertigo wrote:
I have file acces mode as number for example: 755,
and i want to change it to text for example: -rwx------
Is there any module/function for that ?


I have no idea. Why don't you write your own function?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Jul 19 '05 #2
vertigo wrote:
Hello
I have file acces mode as number for example: 755,
and i want to change it to text for example: -rwx------
Is there any module/function for that ?


There probably is no module for this, but it's relatively
straightforward to create your own, if you break down the
problem into smaller problems. Take one digit at a time
from left to right and use a bitwise AND to test which
bits make up each number, 4 for r, 2 for w, and 1 for x.
Use the simple string concatenation operator (a period: .
) to build the string up.

If I am not mistaken.

- Jason
Jul 19 '05 #3
vertigo wrote:
I have file acces mode as number for example: 755,
and i want to change it to text for example: -rwx------
Is there any module/function for that ?


1) Post to comp.lang.perl.misc instead of this comp.lang.perl newsgroup.
2) Look at 'find2perl' for hints.

unix% find2perl . -ls >temp.pl
my @rwx = qw(--- --x -w- -wx r-- r-x rw- rwx);
my $perms = $rwx[$mode & 7];
$mode >>= 3;
$perms = $rwx[$mode & 7] . $perms;
$mode >>= 3;
$perms = $rwx[$mode & 7] . $perms;
substr($perms, 2, 1) =~ tr/-x/Ss/ if -u _;
substr($perms, 5, 1) =~ tr/-x/Ss/ if -g _;
substr($perms, 8, 1) =~ tr/-x/Tt/ if -k _;
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ron Adam | last post by:
How do I covert a string hex or oct value to the correct int value? >>> s = oct(500) >>> s # returns a oct string '0764' >>> int(0764) # ok 500 >>> int(s) # this gives the...
3
by: vertigo | last post by:
Hello I have: var1=0 var2="text" var1=var1+2 var3=var2+var1 ??? i want to receive "text2" in var3, but i receive error can not add int to string. How can i do it ?
4
by: Pokerkook | last post by:
Hello, If anybody could help me with this I would greatly appreciate it. Or at least tell me why I get the output of this garbage: 49 49 10 49 52
2
by: js | last post by:
Hello, I have two text boxes accepting ints and displaying their Sum. This code works: string ans; ans = Convert.ToString(Convert.ToInt32(textBoxX.Text) + Convert.ToInt32(textBoxY.Text));...
4
by: Stephen Russell | last post by:
I have been tasked to run through textbox and determine it's numeric equivalent. ALL-13A, FLR-145, ZX-1X MAK-145ZD are all valid data in the textbox. 13, 145, 1, 145 are the values I need to...
7
by: SteveK | last post by:
I'm trying to write a quick migrate tool to convert our old binary flat DB to SQL Server. I thought I would use C# and get started with a managed language. I have found plenty of examples of how...
1
by: dotnetnoob | last post by:
i have a arraylist that store String() array the string array hold value 1 2 4 i want to access the string array that is inside the arraylist one arraylist item at the time i search up and...
2
by: key9 | last post by:
Hi all on reading code I found these function int foo(int char); char foo(char ch_); string foo(string ch);
7
by: MoRpHeOo | last post by:
Hi everybody, ¿can help me?, I'm novice in C#, can tell me what type of variable gives this operation. Dim a As UInteger = 63689
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.