Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: I need help about MP3::Tag and perl script.

by afoken (Chancellor)
on Mar 31, 2011 at 09:10 UTC ( [id://896589]=note: print w/replies, xml ) Need Help??


in reply to Re: I need help about MP3::Tag and perl script.
in thread I need help about MP3::Tag and perl script.

if(!-w $mp3_file) { # This shouldn't happen but... chmod 0755,$mp3_file; }

Why do you try to make an MP3 file world executable if you can't read it? And why do you make it readable for group and world? Why do you even think about changing the mode of files that are not writeable?

There are usually good reasons for chmod -w somefile and chmod go-rw somefile: I don't want to accidentally modify a file in the first case, and I don't want others to read my files in the second case. Your hardcoded chmod 0755 ignores both. To make things worse, it sets the executable flag, possibly creating a new vulnerability.

I won't start with race conditions between stat (implied in -w) and open, because MP3::Tag has the same problem, so your code does not make it worse in this special case. Generally, one should not try to predict if open fails or succeeds by using stat. It can't work reliably (race condition), and it is not needed. open sets errno a.k.a. $! on error, and errno delivers sufficient information why open failed.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^3: I need help about MP3::Tag and perl script.
by osmy (Initiate) on Mar 31, 2011 at 12:36 UTC
    First of all thank you very much about sharing your experiences with me. But could you please try a simple method cuz I do not understand anything at all I am learning perl now. So If you wrilte down the script again with my needs that I mention before. It wil be awesome and I would learn one thing about perl too. Waiting your support..
      So If you wrilte down the script again with my needs

      I have absolutely no interest in such a project, so I won't write any code for free. Until you make the project interesting for me by stacking a lot of cash on my desk and sign a contract with me, you will have to either search for someone else to write code for you (rent-a-coder ...), or learn Perl.

      For learning Perl, perlmonks is the right place. But you must show substancial effort to learn. Repeating the same question over and over again, and begging for an instant solution is the wrong way.

      Regarding the style of your postings in this thread:

      For me (and perhaps many others around here), postings full of "leet speek", spelling errors, complete lack of formatting, wrong interpunction, written within 10 seconds and without any check for errors indicate lack of interest and lack of respect.

      I'm not saying that all of your postings are that bad, perhaps only a few or just the ones in this thread. But your posting was the straw that broke the camel's back.

      I know from my own experience that it is hard to write in a foreign language. But it is even harder to read such postings. I read and write on perlmonks for fun, in my free time, and I don't get money for that. So, why should I even consider reading a posting that looks more like line noise than english? There are about 100 postings a day, and most of them are easily readable. Reading them can be fun, finding the problem or knowing the right answer is even more fun.

      I have no problems with posting code fragments here or elsewhere, perhaps even a complete program. Sometimes, 10 lines of code are better than 1000 words. But I have a huge problem with being treated as the idiot that does your job or homework for free. So, no code for you. Especially not ready-to-run code.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-16 20:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found