|
CanSpice posted:If I have to go to my Programming Perl book to figure out what a special variable is for, I won't use it. There are plenty of perfectly good arguments against just using special variables to golf, but does your system have neither perldoc nor google? perlvar is pretty readable and searchable
|
# ? Jan 12, 2010 21:52 |
|
|
# ? May 17, 2024 04:04 |
|
To be fair special variables are basically impossible to google for. The further explosion of punctuation is one reason I dislike Perl 6.
|
# ? Jan 12, 2010 22:17 |
|
Just going to reask this:Fenderbender posted:On that note, how would I go about altering the delagations (handles) for an attribute. My idea is to call the fields method on a Rose::DB::Object subclass and then push that all to a specific attribute's delegations. Haven't been able to figure out how to do this yet but it will solve a lot of upcoming issues I'm going to have to slave over if I don't do this now.
|
# ? Jan 12, 2010 22:30 |
|
Filburt Shellbach posted:To be fair special variables are basically impossible to google for. The further explosion of punctuation is one reason I dislike Perl 6. This is stupid. If you're within reach of Google, you're within reach of perlvar.
|
# ? Jan 12, 2010 22:40 |
|
Triple Tech posted:This is stupid. If you're within reach of Google, you're within reach of perlvar. This is stupid. Google knows many orders of magnitude more about Perl than perldoc does.
|
# ? Jan 12, 2010 22:57 |
|
Did I mention the flip flop operator is cool as heck lately? Scraping function signatures from manpages:code:
|
# ? Jan 12, 2010 23:27 |
|
So I have a small project that needs to be distributed as a binary executable. It involves a lot of string manipulation. It's been a few years since I programmed anything, I never did anything too complicated, and when I did it was C or C++. I was thinking I should use something friendlier for text than one of those, especially since the last developers of an analogous project used CPLAT and left an unmaintainable mess. Should I bother to learn Perl for this one, and is there an easy way to turn Perl scripts into binaries?
|
# ? Jan 13, 2010 06:00 |
|
MolluskGoneBad posted:is there an easy way to turn Perl scripts into binaries? As long as you only want to distribute as a single file for ease-of-use purposes, you're probably best off using PAR to package your script and all its dependencies as a single executable; it works very well and is just about as seamless as you can get for users. If you're hoping to get some sort of security from compiling to a binary, you're pretty much out of luck. But Perl isn't really any different from any other language in this regard; binaries from any language are not particularly hard to decompile for a motivated hacker.
|
# ? Jan 13, 2010 06:08 |
|
ShoulderDaemon posted:As long as you only want to distribute as a single file for ease-of-use purposes, you're probably best off using PAR to package your script and all its dependencies as a single executable; it works very well and is just about as seamless as you can get for users. Yeah, it's ease of use for our editors, some of whom require babysitting for anything trickier than "Click Here", some of whom would be wont to go and muck around with the scripts.
|
# ? Jan 13, 2010 16:12 |
|
Triple Tech posted:This is stupid. If you're within reach of Google, you're within reach of perlvar. I can get perlvar on my iPhone?
|
# ? Jan 13, 2010 21:16 |
|
CanSpice posted:I can get perlvar on my iPhone? You sho can, little boy! Just point yer Safaris to here!
|
# ? Jan 13, 2010 21:29 |
|
I have a script that calls tar in a call to system(). While the script was running I decided to kill it with control c. What it did wasn't what I expected. Instead of killing the script it just killed tar and went straight to the next line in the script. What is the mechanism that is causing this behavior and how can I make the script die like I want it to?
|
# ? Jan 14, 2010 01:51 |
|
http://perldoc.perl.org/perlfaq8.html#How-do-I-make-a-system()-exit-on-control-C%3f
|
# ? Jan 14, 2010 02:26 |
|
If I may be so bold: http://search.cpan.org/~bingos/Archive-Tar-1.54/lib/Archive/Tar.pm For quick and dirty stuff system() and `` are fine, for anything I actually need to maintain I will find a module that does what I need (or write one). The one exception of course is ssh, I haven't been able to successfully install any pure-perl version of ssh on any system ever.
|
# ? Jan 14, 2010 11:18 |
|
Mario Incandenza posted:http://perldoc.perl.org/perlfaq8.html#How-do-I-make-a-system()-exit-on-control-C%3f Well, that's easy enough to fix. Thanks. But it's not clear to me why that has to be the case. Any thoughts? Kidane posted:If I may be so bold: http://search.cpan.org/~bingos/Archive-Tar-1.54/lib/Archive/Tar.pm I've seen this module before. I've never used it but I have looked it over. The problem with it is that I am dealing with many archives on the order of tens of gigabytes. By its own admission it is quite slow and I really don't want to have to spend more time taring and untaring than I have to. As it is this script will already be spending an hour or two in tar alone, per run. Plus, this script will always be running on a machine with tar installed. If that ever changes then I am willing to spend the time to move it over to Archive::Tar. I'm curious about what problems you've encountered when trying to install Net::Perl. Usually installing perl modules is quite easy. What were the unique troubles with this one?
|
# ? Jan 14, 2010 18:35 |
|
Paradox posted:I'm curious about what problems you've encountered when trying to install Net::Perl. Usually installing perl modules is quite easy. What were the unique troubles with this one? I ended up using Expect.pm, which worked great, but anything I ever write using Expect feels like a hack.
|
# ? Jan 14, 2010 22:31 |
|
Dicking around on irc a lil earlier, something interesting was noted...pre:17:39 <@Sartak> .pl my %r = (a => 'b'); delete $r{a}; my $as_string = %r; "<$as_string>" 17:39 <+cheesebot> <0> 17:39 <@Sartak> .pl my %r = (a => 'b'); my $as_string = %r; "<$as_string>" 17:39 <+cheesebot> <1/8> 17:40 <@Sartak> oh ok cool 17:40 <@Sartak> so an empty hash in scalar context is probably always 0, good 17:40 <@Sartak> but a non-empty hash in scalar context has hilarious semantics 17:40 <@Sartak> 1/8 is buckets used/allocated
|
# ? Jan 15, 2010 00:09 |
|
Fix cheesebot already so I don't have to resort to <>, thanks.
|
# ? Jan 15, 2010 00:15 |
|
Paradox posted:Well, that's easy enough to fix. Thanks. But it's not clear to me why that has to be the case. Any thoughts? code:
|
# ? Jan 15, 2010 03:41 |
|
Are there any initiatives to get Perl5 or Perl6 onto .NET? It seems like there used to be for Perl5, but I think it's dead now. I use C# at work and I'm a junkie now, I love it. Perl6 looks good in the way Duke Nukem Forever looks good.
|
# ? Jan 19, 2010 19:58 |
|
There's been more progress with 6 and with Parrot in the last year or so to the point that the Rakudo people think they can have something generally usable as a beta out by April ('Rakudo Star') I haven't seen any plans to get it onto .Net though :/
|
# ? Jan 19, 2010 20:41 |
|
I've been listening the FLOSS Weekly podcast and I heard about IronPython, Jython, and IronRuby, etc... It made me think, wow, this is almost as bad/crazy as Parrot! And now I feel like making a chart... Here are all the VMs, .NET, JVM, Parrot, and here are all the languages on top of it... And you can have crazy permutations! C# on Parrot IronPerl JPHP Although I don't know any sane person that would want to redo the abortion that is PHP.
|
# ? Jan 19, 2010 21:12 |
|
nevermind, got it
SynVisions fucked around with this message at 01:07 on Jan 21, 2010 |
# ? Jan 21, 2010 00:55 |
|
Quick question about nested data structures: I have a hash that contains a bunch of data in various formats. This one part is a little tricky to wrap my brain around and I want to be sure what I'm doing makes sense. I am generating a 2D array that is not keyed off of integer values, but rather specific floats that each line of the matrix is keyed off of. I just want to be sure that I am accessing each individual scalar correctly. Basically what I have is:code:
|
# ? Jan 21, 2010 20:45 |
|
Just because you can jam everything on to one line doesn't mean you have to. What's matrix?
|
# ? Jan 21, 2010 21:07 |
|
Triple Tech posted:Just because you can jam everything on to one line doesn't mean you have to. How would you set it up? I'm really not that experienced with perl so I'm not really sure about the best way to show what I'm doing. matrix is my name for the 2D array that I'm trying to set up.
|
# ? Jan 21, 2010 21:15 |
|
Captain Frigate, could you describe the problem at a bit higher level of abstraction? I'm not quite sure what your goal is and I think we're having an x/y problem here ("I want to do x, y seems like a way to do x, I'll ask about y rather than x")
|
# ? Jan 21, 2010 21:30 |
|
So... you want to set up a 2D array. Super, that's pretty straight forward. And I'm guessing "matrix" is a key. It should really be quoted to make it more clear. Keys for hashes should be quoted since they are strings/scalars. If you're doing a 2D array, why would you need a hash? If it's a single value hash/dictionary, that doesn't really make sense. Why not start just at the 2D array? A 2D array in Perl is not unlike the way it's done in other languages. It's literally an array of arrays. Except that Perl does not support typed or first class 2D arrays (where it isn't an array OF arrays but a native, 2-dimensional data structure with two indices).
|
# ? Jan 21, 2010 21:37 |
|
Triple Tech posted:If you're doing a 2D array, why would you need a hash? I thought he explained that pretty clearly in his first post. One of the array indices is a float, not an integer.
|
# ? Jan 21, 2010 22:06 |
|
Well the issue for me is that the array would look like this:code:
|
# ? Jan 21, 2010 22:07 |
|
Well if both values aren't indices starting at zero, it's not really an array, is it? I mean, the storage mechanism could be anything (AoA) but accessing it is a whole different story. Storing the 10th and 20th values of something results in what, a 20 element array or a 2 element array? You want a hash of hashes, each key happening to be a number. code:
Edit: Alternatively, you could have an x_lookup and a y_lookup and a 2D array for storing the values themselves. But that's three data structures instead of one monster one.
|
# ? Jan 21, 2010 22:24 |
|
Triple Tech posted:Well if both values aren't indices starting at zero, it's not really an array, is it? I mean, the storage mechanism could be anything (AoA) but accessing it is a whole different story. Well, they do have to be in ascending order, so what I have now are the two arrays, which give me the keys which happen to be numbers. I did it like that so I can iterate on them, making sure I get the numbers in the right order. So instead of directly iterating on the hash, I can iterate on the array, and use the value of the array as the key for the hash. I'm also not sure what you mean by having an x_lookup and a y_lookup.
|
# ? Jan 21, 2010 22:39 |
|
If you value iterating over them cell by cell in order, then a 2D array is the way to go. What I meant by the lookups is that the array indices will have no semantic value to you. Hence the lookup table to provide a mapping between semantic index and array index.code:
|
# ? Jan 21, 2010 22:49 |
|
Triple Tech posted:If you value iterating over them cell by cell in order, then a 2D array is the way to go. What I meant by the lookups is that the array indices will have no semantic value to you. Hence the lookup table to provide a mapping between semantic index and array index. Ok so what you have here is pretty much the opposite of what I have already as far as array vs hash goes, and I think I understand what you're doing, but how do you make sure to print out %x and %y in order?
|
# ? Jan 21, 2010 23:13 |
|
I'm assuming you have you x keys and your y keys already in an ordered list (or some sort of source). If not, then you need to keep sorting them if you iterate over the keys in the lookup hash or keep a regular list of values in their significant order. There are so many ways of tackling this problem and the answer is IT DEPENDS on your use case. Are you building this structure, are you reading it, does it need to be fast, how are you reading it, etc. All of these things matter and I have no idea what you want. PS - If building and arbitrary reading are all important, consider making or finding a matrix class that provides ordered and random access, implementation be damned.
|
# ? Jan 21, 2010 23:39 |
|
Captain Frigate posted:Ok so what you have here is pretty much the opposite of what I have already as far as array vs hash goes, and I think I understand what you're doing, but how do you make sure to print out %x and %y in order? I'll give you a hint based on how you do it with a one-dimensional hash: code:
|
# ? Jan 22, 2010 01:09 |
|
Well I appreciate the help, and I think I was able to improve some bits of the code with your advice! But I have another smallish question: I am running a number of for-loops iterating through these kinds of constructs and I keep running into a syntax error and I'm not sure what to do with it. The code looks like:code:
|
# ? Jan 22, 2010 16:27 |
|
You've got an extra semi-colon after $j++. Edit: Actually, you've got an extra one after $i++, so that isn't the problem. It is unnecessary though. So it's probably the conditional clause that's causing trouble ("$j <= $#array_of_hashes_of_arrays[$i]{some_array}"). Let me do some testing.
|
# ? Jan 22, 2010 16:37 |
|
Erasmus Darwin posted:You've got an extra semi-colon after $j++. Actually the first semicolon was a typo. When I leave out the semicolon on the second one I get an error, and when I put one on the first one I get an error. The way I have it now is: code:
|
# ? Jan 22, 2010 16:42 |
|
|
# ? May 17, 2024 04:04 |
|
You need to stop golfing your stuff so hard. Try it like this.code:
code:
Mithaldu fucked around with this message at 16:48 on Jan 22, 2010 |
# ? Jan 22, 2010 16:44 |