|
Rocko Bonaparte posted:It doesn't necessarily change what I was trying to say. I know that Pugs was a superhuman effort but Parrot wasn't very complete at the time either. Pugs did allow them to screw around with parts of the language though. Ok, i guess i expressed that shittily. Here's what i was trying to say: Your post reads to me like you think there was a deliberate decision by a group of people (committee-style) against Parrot, which never happened as such.
|
# ? Aug 7, 2010 07:32 |
|
|
# ? May 17, 2024 02:19 |
|
Mithaldu posted:Ok, i guess i expressed that shittily. These days I think I like the idea of Parrot more than Perl 6 itself since Parrot would allow all these languages to work together--so long as people actually convert (dare I say, "compile?") the code to the Parrot asm.
|
# ? Aug 8, 2010 06:32 |
|
Did this yesterdaycode:
|
# ? Aug 8, 2010 19:19 |
|
That is a pretty neat demonstration of how to use that module. I also have a question of my own. Two days ago i found myself faced with having a largish codebase that i was tasked with refactoring (really no other goal, because it's entirely poo poo). Since everything in it was bad, i couldn't decide where to begin, so i decided to run some statistics on the code. With a bit of poking at StackOverflow and a lot of reading of PPI documentation i got this script together: http://gist.github.com/514512 Now I'm thinking about how to convert it into a proper module distro for CPAN, and once again find myself faced with too many ways i can go. As such I'm looking for some input to help me think: How would you structure this? (i.e. in which different modules) (I'm intentionally not giving any examples of what I'm thinking of to get 'untainted' reactions.)
|
# ? Aug 9, 2010 20:51 |
|
Mithaldu posted:How would you structure this? (i.e. in which different modules) I'd put the stuff that generates the statistics in its own package and have some interface that returns a stats object. Probably another package to handle outputting stuff in various formats using the stats object. The main script would just process command-line options and glue it all together.
|
# ? Aug 11, 2010 16:36 |
|
SA Support Robot posted:I'd put the stuff that generates the statistics in its own package and have some interface that returns a stats object. Probably another package to handle outputting stuff in various formats using the stats object. The main script would just process command-line options and glue it all together. I was hoping for a bit more detail, but i guess i wasn't very detailed either. I've spent the night doing a rough sketch being heavily inspired by the excellent Dist::Zilla of how i think this whole thing can work: http://github.com/wchristian/code-statistics Working functionality is like this: bin/codestat is called as: codestat collect --dir=/perl/here It then runs through that directly, finds all files and gets their absolute paths. Then it runs each file against a search that looks for targets that are relevant to statistics. right now only blocks, but it's structured so that it's easy to add in new target types like subs, regexen, etc. Each target has a PPI class i don't think i need to try supporting non-PPI targets, as well as a list of supported metrics. size, length, indentation depth, line number, column number, etc. All found targets are then looped over and the measurements of each supported metric are collected on each target. That data is then stored in the file object, where it is stripped out back in the main processing module, and then dumped to JSON like so: code:
Now here's what I'm really looking for at this point: The design and structure is extremely bare-bones and only the minimum that i can envision working in the future as well. So, before i start on fleshing it out, i need to see if i can get some cold and brutal criticism. What did i overlook, fail to consider or just plain gently caress up? Where is my design poo poo in ways that will break stuff in the future or make it very hard to change or fix some things? Also, how do you think of yourself wanting to use this? I already have a bunch of use case scenarios in mind and am planning for the relevant changes, but input from people who aren't me would be invaluable in this department. My current future plans for the metric collector: Parameters for: - directories to search in (. as default) - file extensions to look for (File::Find::Rule::Perl as default) - file ignore patterns (empty as default) - custom lists of target ppi objects (planning to have it use only block as default) - custom metric lists (planning to have it use all by default) - config files looked for in current directory as well as in user directory - config files containing a global profile, as well as specific profiles, which can be used to generate parameter sets with this precendence: userdir( global < specific ) < cwd( global < specific ) < command line
|
# ? Aug 15, 2010 08:03 |
|
A small side result of my wrestling with the code statistics thing: Test::Class::TestGroup
|
# ? Aug 16, 2010 22:26 |
|
Has anyone got any tips on working with large files in Perl? I want to work on encrypting files, but I foresee problems with encrypting larger files, both binary and ASCII, as they would likely need to be loaded into memory before any operation can be performed on them. I'm Googling in the meantime, but it anyone has any suggestions, I'm all ears.
|
# ? Sep 3, 2010 18:22 |
|
Perl isn't going to force you to read the whole file into memory at once, and if you can possibly avoid doing so, you should. You probably don't need random access to the entire file; maybe you can collect the information you need in a first pass, then encrypt the file in a second? This is language-agnostic advice.
|
# ? Sep 3, 2010 18:34 |
|
Rohaq posted:Has anyone got any tips on working with large files in Perl? I want to work on encrypting files, but I foresee problems with encrypting larger files, both binary and ASCII, as they would likely need to be loaded into memory before any operation can be performed on them. I've always used Tie::File for processing large files.
|
# ? Sep 7, 2010 03:07 |
|
I've build a helper.pm full of helpful functions. I'm now working on an interactive command line that allows me to easily call functions from helper.pm. However, I'm having problems getting the syntax down. For example, if I have a defined function test which prints "Hello world", then the following would call that function: my $function = "test" &{$function}(); However, if I have a defined function test in helper.pm, I don't know how to call it from another file. All the following fail: &{Helper::$function}(); &Helper::{$function}(); Helper::&{$function}(); $Helper::&{$function}(); Does anyone know the solution to this problem? Thanks!
|
# ? Sep 22, 2010 01:45 |
|
Well, calling functions indirectly and tightly coupled like that is kinda asking for trouble, but here's how to do it (even when using strict):code:
|
# ? Sep 22, 2010 07:59 |
|
Mario Incandenza posted:Well, calling functions indirectly and tightly coupled like that is kinda asking for trouble, but here's how to do it (even when using strict): Yeah, this isn't the best solution. I am using this for testing my in house development tools and haven't had time to come up with a more elegant method due to other pressing issues. My main problem was my subroutines are in a different file, so I'm not sure how to call those functions. I was unclear about the syntax to make the call. However, I've figured it out. code:
code:
|
# ? Sep 22, 2010 21:45 |
|
You can also do something like this: in foo.pm: code:
code:
toadee fucked around with this message at 13:36 on Sep 29, 2010 |
# ? Sep 29, 2010 13:02 |
|
I intend to build a text-driven app that will allow lay-people to work their way down a decision tree where each step combines modular blocks of pre-written text and inserts variables to generate configuration files. Basically something like this:code:
code:
This is a fairly simplistic example and the finished product will be able to parse text to detect error messages, be able to use FTP for file transfer, be made to wait for x number of seconds, etc. What I want to do seems beyond batch files or Aspect scripting. Does this look like a good application for Perl? I have practically no experience with code, but I can learn, dammit.
|
# ? Oct 22, 2010 05:46 |
|
Kynetx posted:Does this look like a good application for Perl? Everything you mentioned sounds relatively easy in Perl. For the FTP transfer part, Perl's got the Net::FTP module in CPAN.
|
# ? Oct 22, 2010 14:09 |
|
Wanted to submit a patch to fix WWW::Calculator yesterday, so I finally got off my arse and got my PAUSE id set up. The id didn't get recognized by rt.cpan.org immediately, so I submitted the bug report and patch via email and gitpan instead
|
# ? Oct 22, 2010 20:53 |
|
Otto Skorzeny posted:Wanted to submit a patch to fix WWW::Calculator yesterday, so I finally got off my arse and got my PAUSE id set up. The id didn't get recognized by rt.cpan.org immediately, so I submitted the bug report and patch via email and gitpan instead Depending on which author you're dealing with, github might even be the better choice to push out patches. I know i've gotten picked up more by just forking things and hacking on them.
|
# ? Oct 22, 2010 21:12 |
|
Yeah, the fork & pull request model seems pretty convenient
|
# ? Oct 22, 2010 21:39 |
|
I have an array that I'm trying to output into a table. I want to alternate outputting text in first and second columns. Right now I'm able to send the correct data to one column, but I don't know how to do so for both columns.code:
Super Delegate fucked around with this message at 06:37 on Nov 6, 2010 |
# ? Oct 27, 2010 23:09 |
|
code:
|
# ? Oct 27, 2010 23:31 |
|
Your two-column table looks suspiciously like a hash:code:
|
# ? Oct 28, 2010 07:54 |
|
Keep in mind the above/latest/hash technique won't work if the keys are not unique.
|
# ? Oct 28, 2010 15:07 |
|
I have a 3d hash, and I am populating it by building 2d hashes using a function that returns references to 2d hashes and I want to merge the "inner" 3d hash with the 2d hash. If they were both 2d hashes I would do this:code:
code:
|
# ? Oct 29, 2010 07:06 |
|
Dooey posted:What should I be doing? You need to do with hash4d the same thing you did with hash2d: Dereference it. You also need to wrap the whole thing in curlies to make it generate an anonymous hash. Like so: code:
|
# ? Oct 29, 2010 07:46 |
|
Super Delegate posted:I have an array that I'm trying to output into a table. I want to alternate outputting text in first and second columns. Right now I'm able to send the correct data to one column, but I don't know how to do so for both columns. Another way is that if have the List::MoreUtils module or can get it from CPAN then you can use the natatime function. code:
|
# ? Nov 1, 2010 05:22 |
|
Otto Skorzeny posted:The id didn't get recognized by rt.cpan.org immediately] rt.cpan only syncs new accounts a couple times (maybe only once?) a day
|
# ? Nov 3, 2010 12:42 |
|
code:
|
# ? Nov 3, 2010 17:54 |
|
qntm posted:
Buffers. Try $| = 1;
|
# ? Nov 3, 2010 17:56 |
|
qntm posted:Why doesn't this print the letter "K"? Standard out is line buffered. Either terminate strings with \n, or flush the buffer: The $| variable sets 'autoflush' in perl
|
# ? Nov 3, 2010 19:06 |
|
I've got a list of family names I'd like to sort by their ending... I thought reversing them all would be the easiest way so I wrote this tiny thingy:code:
Аалунд Абабков Абаджев ... and perl doesn't seem to like reversing utf-8 at all edit: trying to find out how to use this String::Multibyte thing - maybe that's the solution I'm stupid - here's the solution: code:
Warthog fucked around with this message at 01:15 on Nov 4, 2010 |
# ? Nov 3, 2010 23:46 |
|
Right now at work we have a 400mb moloch of an SVN repo and i'm wanting hard to get that moved to git and eventually split up. The CTO gave me the go-ahead to write an email as to why git, and how to do it. Can you guys link me to recent write-ups on the advantages of git over svn that are more amenable to a management-type target audience?
|
# ? Nov 6, 2010 10:00 |
|
Here's one that has me pounding my head against a wall. I have an Apache VirtualHost that is served by two machines behind a load-balancer. I need to accurately get the load time from server A vs server B for a specific URL that resolves to the load balancer. I'm trying to find some way to make a "hostfile" that's local to the script itself without affecting name resolution for the rest of the monitoring server. There are 20,000 different ways to access the standard gethostbyname() function, but I have to find a way to short-circuit it. Thoughts? Ideas? Comments? Offers of alcohol?
|
# ? Nov 10, 2010 16:52 |
|
Cuddles posted:I need to accurately get the load time from server A vs server B for a specific URL that resolves to the load balancer. Instead of going crazy by subverting DNS, I'd suggest just hitting the IP of server A or server B directly with the Host header set to the appropriate VirtualHost. code:
|
# ? Nov 10, 2010 17:49 |
|
Erasmus Darwin posted:Instead of going crazy by subverting DNS, I'd suggest just hitting the IP of server A or server B directly with the Host header set to the appropriate VirtualHost. You are a scholar and a gentleman. I've been so busy hammering on name resolution I completely ignored the LWP headers.
|
# ? Nov 10, 2010 17:57 |
|
Just read about 5.13.7's keys(), push(), pop() etc now accepting refs as valid containers, noice. That was one of the few things that still seems to bug me about Perl's syntax. e.g. say() foreach keys $obj->returns_hashref()
|
# ? Dec 5, 2010 16:46 |
|
I didn't even know the delta for 5.13.7 was out yet
|
# ? Dec 5, 2010 20:04 |
|
I've been bashing my head against this problem, and I suspect I'm starting to see it sideways. Can someone help me access this complex data structure? Basically, I'm taking an XML page of hardware info and using XML::Simple's XMLIn() function to put into a Perl data structure. Now I'm trying to parse that data and show meaningful information to the user. Here is a snippet of that data - the output of running 'print Dumper(@Processors);' to be exact: code:
So, I guess that means it's not a reference to anything, but it's also not an array? Am I being very stupid here? syphon fucked around with this message at 01:03 on Dec 8, 2010 |
# ? Dec 8, 2010 01:00 |
|
syphon posted:How the hell do I access that data? print $array->[0]->{CLOCKSPEED}; gets you '2400 MHz'. With references you have to dereference to get the values. So for (@{$Processors} { ... } is how you tell perl to turn it back into array from a scalar. syphon posted:Am I being very stupid here? Not at all. Perl can be weird depending on what background you come from. If it's C, then it makes more sense.
|
# ? Dec 8, 2010 01:09 |
|
|
# ? May 17, 2024 02:19 |
|
The Gate of Nanna posted:print $array->[0]->{CLOCKSPEED}; code:
|
# ? Dec 8, 2010 01:25 |