|
How do I get info about filesystems in Perl? There is a statfs call but no statvfs call, etc.
|
# ¿ Nov 11, 2007 07:08 |
|
|
# ¿ May 1, 2024 09:21 |
|
Triple Tech posted:Two things. One, it sounds like what you're asking for is to output to a file as soon as possible. That is achieved by the following: Why would you ever want to increment this instead of setting it to 1? Unless you are sharing it across threads or something and it is being used in the same manner a semaphore or something weird like that, you should just set it to 1.
|
# ¿ Dec 7, 2007 18:26 |
|
I have read a ton of Perl books and gone through lots of Perl code and have NEVER seen anyone increment it. I think it is bad form and confusing.
|
# ¿ Dec 8, 2007 00:58 |
|
scrabbleship posted:I am writing a quick perl script to find all instances of "size" in a file and then delete that line. The problem is my regular expression also catches other lines where it has "size" but inside another word. For example, I want it to get rid of the line "Size: 4234" but not "Install-Size: 34234". Well this will help a little: if(/(^|\s)size/i) Just see if there is a space in front of size or if it is at the beginning of the line.
|
# ¿ Mar 25, 2008 19:45 |
|
Cheesus posted:What's the best way to interface with a C++ library from Perl? The most efficient way would be to use XS. It not not that easy to use though. A lot of Perl modules use it to interface with C++.
|
# ¿ Jun 25, 2008 21:07 |
|
genericadmin posted:Also... does anyone in this thread do much XS? I've done some in XS. It was like a year and a half ago though.
|
# ¿ Jul 13, 2008 04:09 |
|
Triple Tech posted:Using parenthesis for built-ins is not good practice. In fact, the PBP is to not use parenthesis for built-ins. Where are you getting this??
|
# ¿ Aug 4, 2008 17:59 |
|
Yeah I have never heard of anyone saying you should never use them. You should listen to Randal Schwartz over Damian Conway any day. *shakes fist at Damian Conway*
|
# ¿ Aug 4, 2008 18:18 |
|
Triple Tech posted:Well it's getting rid of unneeded parenthesis. Of course you need them for some things. I just don't like reading this, ever: You should use them where it makes sense to. To say "never use them" is dumb. I personally would write that as: open(FILE, shift) or die "blah"; But to each his own.
|
# ¿ Aug 4, 2008 18:21 |
|
checkeredshawn posted:It's a really long flat text file containing 26 fields of information for each object. Why dont you open the file and read the contents instead of accepting them on the command line?
|
# ¿ Aug 6, 2008 19:20 |
|
Triple Tech posted:What's a compelling reason to use an INIT block versions just some code in main:: when making a module? My coworker says it's easier to tell how code in a module breaks if it's inside an INIT, versus main where it just says module use failed. I told him, you could see the error if you just ran the module as a script. Thoughts? INIT is the first thing to get called after compilation (except BEGIN blocks or 'use' statements, etc). The main reason to use it is to make sure you have certain code executed before anything else. You can think of it as a constructor I guess. I have never heard of it being used to find errors. Maybe he is thinking of eval? *edit* typos Subotai fucked around with this message at 17:34 on Aug 14, 2008 |
# ¿ Aug 14, 2008 17:12 |
|
Triple Tech posted:I've never heard of it being used for anything ever. What's a really good, typical example of someone using an INIT that can't just be in main before the subroutines? It could be considered cleaner I suppose. I dunno, ask your co-worker to explain himself.
|
# ¿ Aug 14, 2008 17:44 |
|
more falafel please posted:I've never been much of a Perl expert, but what's the philosophical reason behind Perl flattening lists? I think it was just a mistake. I am sure you can find Larry Wall talking about it somewhere on the net.
|
# ¿ Aug 27, 2008 03:40 |
|
Triple Tech posted:Could someone please explain what a lexical $_ is used for and how to use it? It is used the same way you would use the global version. It just means that you can now change $_ in a certain scope and not affect the global version.
|
# ¿ Aug 28, 2008 16:44 |
|
Triple Tech posted:Let's say you make a really simple class (it never stays that way does it ). Do you bother implementing getters for private use or do you just access the object's innards directly? That is, should you be allowed to know how you work? Or should the same amount of care and abstraction be taken as if it was publicly consumed? There is no need to try and abstract the internal data members of a class from itself.
|
# ¿ Sep 3, 2008 22:32 |
|
Sartak posted:Your class will get more complicated. Having layers of abstraction will ease that evolution. I for one find it much more of a pain in the rear end to have to write a function to access a data member in a class that I already have access to. Unless you really think you might have to go back and redo how or the information in the class is stored or handled, and it is too much work to actually change the hash in the places you use it, then go ahead and write an accessor function. I believe it mainly will be a waste of time, involve extra code that doesn't need to be there, and make the code harder to debug. He is talking about a simple class in Perl. It shouldn't be something you turn into a monolithic piece of code. He probably shouldn't have any use for accssesor functions internally.
|
# ¿ Sep 3, 2008 22:39 |
|
|
# ¿ May 1, 2024 09:21 |
|
Mithaldu posted:Little performance question: Both are O(1) but the hash will have more overhead since it has to do some extra math to find the hash bucket.
|
# ¿ Sep 5, 2008 22:27 |