|
Kakesu posted:directory mania! For starters, don't make shell calls if there are CPAN modules available to do the same thing. There should definitely be an ActiveState-approved module that creates file paths... Two, the system function accepts arrays! The first argument to the function is the command you want to run and subsequent arguments are arguments to the command, properly and automatically escaped by Perl. So, you should try to write out your system call (which you shouldn't be using) like this: code:
|
# ? Dec 11, 2007 22:31 |
|
|
# ? May 21, 2024 15:09 |
|
Triple Tech posted:For starters, don't make shell calls if there are CPAN modules available to do the same thing. There should definitely be an ActiveState-approved module that creates file paths... Thanks. Right after I posted that, we found another Perl user that explained that we could just use mkdir on its own, without a shell call, and that seems to be working. Still no idea why it stopped working, though. The thing I forgot to mention in my original post is that this script has been running continuously for the past 3 months, but this is the first time it's failed like this. Very strange.
|
# ? Dec 11, 2007 22:42 |
|
Anyone know how to use glob? Here's some code. I have a list of glob-type filenames in @attachments(the test I am running with only contains one, "./smoke_test_*" but it could contain any number of them) Here's the code: code:
code:
code:
|
# ? Dec 17, 2007 20:11 |
|
You should try a one-liner first, likecode:
|
# ? Dec 17, 2007 20:17 |
|
Triple Tech posted:You should try a one-liner first, like Nope, I get code:
|
# ? Dec 17, 2007 20:25 |
|
I'm trying to look up more about it, but off the top of my head, I can't help but think that there's something wrong with your perl. What version are you using? And what OS are you running? You could reimplement the glob concept by just using readdir. Edit: I think older versions of Perl outsource their globbing to the shell. So if there's something wacky about the environment you're running, that might be it.
|
# ? Dec 17, 2007 20:40 |
|
Triple Tech posted:I'm trying to look up more about it, but off the top of my head, I can't help but think that there's something wrong with your perl. What version are you using? And what OS are you running? I am using perl, v5.6.2 built for i686-linux. EDIT: Removing "use File::Glob;" from my script solved the issue with the glob('*.pl') not working, but I still can't glob a string and it doesn't spew any errors. code:
code:
removing the quotes in glob("$glob"); fixed it loving perl ashgromnies fucked around with this message at 21:35 on Dec 17, 2007 |
# ? Dec 17, 2007 20:58 |
|
Are you sure you're in the right directory? Is the one-liner still giving you problems?
|
# ? Dec 17, 2007 21:10 |
|
by the way, this also works: code:
|
# ? Dec 18, 2007 18:54 |
|
heeen posted:by the way, this also works: Of course, a lot of that is redundant! code:
|
# ? Dec 18, 2007 19:15 |
|
When you golf like that, it gives non-Perlers a negative impression of the language... Golf away!!! Edit: Everyone rejoice! Perl 5.10 is out! Here is the delta. Sounds pretty neat to me. Triple Tech fucked around with this message at 15:43 on Dec 19, 2007 |
# ? Dec 18, 2007 19:31 |
|
Triple Tech posted:Edit: Everyone rejoice! Perl 5.10 is out! Here is the delta. Sounds pretty neat to me. All right, a switch statement! Perl's a REAL BOY NOW. No but seriously I'm and and compiling this poo poo ASAP so I can just breathe it in, just inhale it -- Aaaaahhh, smell that Perl 6 fragrance.
|
# ? Dec 20, 2007 09:27 |
|
hey everyone. I have a template file that I want to copy, however the new file name will be supplied by the user. How can I get File::Copy to work with me? here is my code code:
|
# ? Dec 20, 2007 18:23 |
|
I don't understand, is something not working for you? Do you not know how to capture user input? Is it not running?!
|
# ? Dec 20, 2007 18:55 |
|
Triple Tech posted:I don't understand, is something not working for you? Do you not know how to capture user input? Is it not running?! oh I wasnt sure that it would take a file name as input for the copy command! sorry!
|
# ? Dec 20, 2007 18:57 |
|
Twlight posted:oh I wasnt sure that it would take a file name as input for the copy command! sorry! Yes, it takes a filename as the second argument... code:
|
# ? Dec 20, 2007 19:00 |
|
One more question. I'm writing a perl script to edit the named.conf file, however i need to edit 2 places in the file once in the middle of the file and again at the end (not exactly the end but near the end. How can I tell perl where exactly I want to edit based on this file? here is hopefully a better explanation: code:
|
# ? Dec 20, 2007 22:16 |
|
All things in software are possible... If you can promise that everything is split up by lines nicely, you can just loop through each line in the file, analyze where you want to stop, inject your new stuff, and then keep printing. A better, "more right", more complicated way would be to have a script interpret and parse the entire conf file, modify the Perl object that represents it, and then serialize it again... That would be the most flawless way.
|
# ? Dec 20, 2007 22:23 |
|
Triple Tech posted:All things in software are possible... the file follows this convention: code:
|
# ? Dec 20, 2007 22:35 |
|
Twlight posted:I want to inject a return at the second to last }; and add my input so I would dump the contents of the file into an array, then I get lost Right, so you load up the original conf file and you loop through all of the lines. You analyze a line and decide what to do with it. If do nothing, then just tack it back on to a buffer (another scalar). You're essentially reconstructing the file. At some point, your testing mechanism will pass, telling you that you're at that particular point in the file. Before you push the original content back to the scalar buffer, you inject your content by pushing it on first. Then push the original. Now you have a new file represented in Perl-space. Close the file for reading, then reopen it for writing, write out your buffer, and blamo, original file + injection complete.
|
# ? Dec 20, 2007 22:55 |
|
Triple Tech posted:Right, so you load up the original conf file and you loop through all of the lines. You analyze a line and decide what to do with it. If do nothing, then just tack it back on to a buffer (another scalar). You're essentially reconstructing the file. so something like this? code:
|
# ? Dec 20, 2007 23:04 |
|
Aren't your in and out file the same? If so, you would need to open, and then close. If not I guess your way with two filehandles is the same.code:
|
# ? Dec 20, 2007 23:12 |
|
Triple Tech posted:A better, "more right", more complicated way would be to have a script interpret and parse the entire conf file, modify the Perl object that represents it, and then serialize it again... That would be the most flawless way. The Perl way is to have someone else do the heavy lifting for you.
|
# ? Dec 21, 2007 06:33 |
|
wntd posted:The Perl way is to have someone else do the heavy lifting for you. I've only just started using perl, I know thats from CPAN and I know how to install things from CPAN, but I have no idea how this works.
|
# ? Dec 21, 2007 15:44 |
|
Twlight posted:I've only just started using perl, I know thats from CPAN and I know how to install things from CPAN, but I have no idea how this works. What don't you understand exactly? The perldoc is pretty explanatory... You configure various handlers for when the parser finds different things(like the start of a config block, end of a config block, etc.) then tell it to parse a file and it will run the custom callback handlers you created when it needs to.
|
# ? Dec 21, 2007 21:08 |
|
ashgromnies posted:What don't you understand exactly? The perldoc is pretty explanatory... To someone that doesn't know Perl that well or knows it to varying degrees, perldoc isn't some godlike, infallible tutorial on all things... Besides, this module just spits out events as it parses a file. I don't see how this is at all relevant to the original problem of modifying the config by injecting another paragraph. ...unless you want to use the stream of events to detect and reconstruct parts of the object, and then inject things that way... Which I wouldn't be infavor of because that just sounds so indirect, compared to my way.
|
# ? Dec 21, 2007 21:32 |
|
I figured it out What I did was add a comment to the conf file I was trying to add data to, then I did a find/replace on that comment. The replacement would also re-add the comment below the new information making it ready for the next entry.
|
# ? Dec 21, 2007 23:27 |
|
You should have a look at Tie::File some time. Lets you modify a file in-place, maps the lines to an array. Pretty good, I use it often. E: ONLY A DAY AND A HALF LATE
|
# ? Dec 23, 2007 12:31 |
|
Did you ever hear anyone say "design your modules like you would release them on CPAN"? Is there any part of that advice that's negative? I've also been thinking of creating another movement... All the companies I've been at store their utility functions (example, for text munging) in Company::Utility::Text. And it's started to bother me. Why not design it like you'd really release it on CPAN, so it goes under Text::Something. I guess that ties into the first question... Like, I want to keep real business logic seperate from fake business logic. Is that so bad? Although I do see the argument of "well, it's a module we developed internally, so we have to put it in our own namespace". True, but sometimes you create things that aren't really proprietary, or could easily be shared with the world.
|
# ? Jan 3, 2008 23:38 |
|
Triple Tech posted:Although I do see the argument of "well, it's a module we developed internally, so we have to put it in our own namespace". True, but sometimes you create things that aren't really proprietary, or could easily be shared with the world. Most any application/module/plugin developed at a company is going to be an IP, even small things like a slightly more specific text parser. Everywhere I've worked has used their own namespace, and even namespaces specific to each individual group. It just adds one more layer of structure, in my opinion, and I see no reason to be rid of the practice.
|
# ? Jan 4, 2008 04:47 |
|
Fenderbender posted:Most any application/module/plugin developed at a company is going to be an IP, even small things like a slightly more specific text parser. Everywhere I've worked has used their own namespace, and even namespaces specific to each individual group. It just adds one more layer of structure, in my opinion, and I see no reason to be rid of the practice. Plus it keeps knowledge sharing a little easier - if you have a namespace specifically for the company, you know where to look for modules related to company or product-specific business logic.
|
# ? Jan 4, 2008 15:51 |
|
ashgromnies posted:Plus it keeps knowledge sharing a little easier - if you have a namespace specifically for the company, you know where to look for modules related to company or product-specific business logic. But that's the point of my post. The code in question isn't specific to the company, at all. It could be used by other people. It's like if Amazon made an ISBN parser... Where ISBNs aren't unique to Amazon the company. Instead of putting it in Amazon::ISBN, it should be in ISBN::Parser, as if it were a public facing module.
|
# ? Jan 4, 2008 15:57 |
|
Triple Tech posted:But that's the point of my post. The code in question isn't specific to the company, at all. It could be used by other people. It's like if Amazon made an ISBN parser... Where ISBNs aren't unique to Amazon the company. Instead of putting it in Amazon::ISBN, it should be in ISBN::Parser, as if it were a public facing module. Personally if this was a public module and Amazon made it, I wouldn't hold a grudge if it was released on CPAN under the name Amazon::ISBN. On the other hand I would also understand if they named it ISBN::Parser since it's general-purpose... I guess what I'm trying to say is.. eh. It shouldn't really matter should it?
|
# ? Jan 5, 2008 10:36 |
|
TiMBuS posted:Personally if this was a public module and Amazon made it, I wouldn't hold a grudge if it was released on CPAN under the name Amazon::ISBN. On the other hand I would also understand if they named it ISBN::Parser since it's general-purpose... Exactly. While arguments could be made for module names (which is to say: CPAN hierarchies) being meanigful or not being meaningful, the truth is that they are not. There is no CPAN-police enforcing any sort of naming scheme or quality control standards (although the perl-qa project evaluates all modules uploaded to the CPAN for "kwalitee", which is a metric of how well-formed a module is according to current standards). search.cpan.org is your friend (as are cpanratings and annocpan (both integrated into search.cpan)).
|
# ? Jan 5, 2008 21:25 |
|
I have perl 5.10 downloaded and extracted on to my desktop. I have no idea how to use it. I downloaded activeperl before and i was able to "install it" and run basic script on my computer. Can anyone show me how to get started with perl 5.10? The book programming perl i got and a lot of the tutorials on line never touch up on this fact.
awesomepanda fucked around with this message at 03:00 on Jan 8, 2008 |
# ? Jan 8, 2008 02:49 |
|
CrazyPanda posted:I have perl 5.10 downloaded and extracted on to my desktop. I have no idea how to use it. I downloaded activeperl before and i was able to "install it" and run basic script on my computer. Can anyone show me how to get started with perl 5.10? The book programming perl i got and a lot of the tutorials on line never touch up on this fact. I can't say for sure, but I think what you might have there is a source tarball, since you seem to indicate that it's not ActivePerl. You might be interested in Strawberry Perl, which is created and maintained by one of the Perl community's most dedicated hackers. This still won't tell you exactly how to get going though. Personally, I'd recommend a copy of the Llama book (Beginning Perl), and I'd recommend that you skip chapter 1. If you already have references on hand, just realize that Strawberry Perl (or a Perl you build yourself) is not an IDE, it's just a language interpreter, the core modules, and some helper tools like 'cpan', which will fetch new modules for you from the CPAN -- the expectation is that you're going to write scripts in the editor of your choice and run them. Sorry if any of this is too basic or redundant; I have no idea about your skill level, and I'm not a Windows user, so I can only speak to the universalities of the language. Finally, since you're asking about Perl 5.10, you might wanna check out this pretty sweet little piece of work: Perl 5.10 For People Who Aren't Totally Insane, a deep but generally followable introduction to the new bits in 5.10
|
# ? Jan 8, 2008 05:05 |
|
mdxi posted:I can't say for sure, but I think what you might have there is a source tarball, since you seem to indicate that it's not ActivePerl. You might be interested in Strawberry Perl, which is created and maintained by one of the Perl community's most dedicated hackers. I find it much easier to install Cygwin with the perl runtimes and your editor of choice(vi is pretty nice for perl). Windows-native perl is kind of difficult to work with due to the lack of a strong command-line.
|
# ? Jan 8, 2008 16:21 |
|
ashgromnies posted:I find it much easier to install Cygwin with the perl runtimes and your editor of choice(vi is pretty nice for perl). Windows-native perl is kind of difficult to work with due to the lack of a strong command-line. That's exactly the purpose of the Strawberry Perl distro; it obviates the need to install Cygwin, or anything else. It's a fully self-contained Perl for Windows Hmmm. Rereading your comment, I realize that you might be talking about perl-as-system-glue and not simply perl-the-language, in which case I'm sure you would want Cygwin as well. But if you want Just Perl, you don't need to fiddle with Cygwin installs anymore. I just wanted to point out that Strawberry Perl can act as a standalone distro because there has been some confusion about that issue in the past week as people's interest has been piqued due to the 5.10 accouncements.
|
# ? Jan 8, 2008 17:50 |
|
mdxi posted:That's exactly the purpose of the Strawberry Perl distro; it obviates the need to install Cygwin, or anything else. It's a fully self-contained Perl for Windows I just think it's much easier to deal with perl when you have a nice command line to fall back on.
|
# ? Jan 8, 2008 20:16 |
|
|
# ? May 21, 2024 15:09 |
|
I use ubuntu. It's my fav distro and you cant change my mind >=( However, it relies on the perl package provided for a lot of programs, so I can't uninstall it and manually build and install perl 5.10 I can only guess how long ubuntu will take to upgrade the perl package, but it probably won't be soon because they like to quadruple check the drat stuff they release has no bugs, plus they'll have to upgrade and repack all of their current packaged perl modules as well. So, wat du I do? The only solution I can think of is making my own package and overriding the ubuntu one, but who knows how much stuff I could break doing that.. Maybe I should just wait?
|
# ? Jan 14, 2008 06:24 |