|
Ninja Rope posted:I don't want to talk out my rear end without testing it, but I'm pretty sure that's not necessary. I've got some broadcast socket code somewhere I'll try and dig up later today and let you know how I got that working. Okay, so I see what's going on here. When you create the broadcast socket with a remote address of 255.255.255.255, it will only send data to and receive data sent from that address, as if it were a connected socket. In your case, you should create the socket without specifying a remote address, and then specify the destination address as a packed sockaddr in your call to send(). Like this: code:
|
# ? Oct 22, 2008 18:06 |
|
|
# ? Jun 3, 2024 23:39 |
|
Ninja Rope posted:Okay, so I see what's going on here. When you create the broadcast socket with a remote address of 255.255.255.255, it will only send data to and receive data sent from that address, as if it were a connected socket. In your case, you should create the socket without specifying a remote address, and then specify the destination address as a packed sockaddr in your call to send(). Like this: Ah! That makes sense, thanks. When I get home I'll screw around with it some more, thanks for the help!
|
# ? Oct 22, 2008 19:24 |
|
syphon^2 posted:Doing it this way means I have to rip out a bunch of code an put it in a separate .pl file though. (or can Win32::Process::Create execute Perl code within the same Perl executable?) You can stick it in the same script if you want. Just invoke the child processes with /child as one of the arguments and check @ARGV when you start up. quote:EDIT: I just thought of something else... Win32::Process::Create is like fork, in that I can't share variables, right? Yup. A quick and easy workaround is to just have the child processes write their results to textfiles that're checked by the parent process.
|
# ? Oct 22, 2008 19:48 |
|
JawnV6 posted:Ah! That makes sense, thanks. When I get home I'll screw around with it some more, thanks for the help! If you get stuck again on this let me know. I've got some code I use that does exactly this, but I'd rather not post it here.
|
# ? Oct 23, 2008 08:36 |
|
Ninja Rope posted:If you get stuck again on this let me know. I've got some code I use that does exactly this, but I'd rather not post it here. I ended up closing and re-opening, it's working fine from watching it on wireshark. Thanks.
|
# ? Oct 23, 2008 22:31 |
|
JawnV6 posted:I ended up closing and re-opening, it's working fine from watching it on wireshark. Thanks. Doesn't this introduce a timing issue, though? You can't guarantee how fast you can close and reopen the socket, or even that you can at all, if the OS runs out of sockets or your process out of FDs.
|
# ? Oct 24, 2008 07:35 |
|
I hope this is the right thread for this. The long story is I'm tried to install Catalyst on some shared hosting. The server I'm on provides perl 5.8.4, and I ran into some problems working with CPAN with that so I decided to install perl 5.10.0 in my user directory. I get it to compile and install perfectly fine. I'm not too sure on the specifics, but it also seems to set my @INC just fine: code:
code:
code:
code:
code:
code:
Any ideas on how to stop CPAN from installing certain modules in lib/perl5/? It's happened on new installations (ie not an upgrade) and it hasn't happened on all upgrades.
|
# ? Oct 25, 2008 22:27 |
|
local::lib is worth having a look at. It manages all the environment twiddling to let CPAN install into your home dir, and having Perl find it.
|
# ? Oct 25, 2008 22:55 |
|
Huh. Well. Since perl had properly set up @INC for the installation, I decided to see if it also worked for CPAN. The only change I made is I removed PREFIX and --install_base from Config.pm and now it works perfectly.
|
# ? Oct 26, 2008 02:33 |
|
There's going to be another Frozen Perl in Minneapolis on February 7th. I'll be there. I've submitted a talk for Devel::REPL and Carp::REPL that will probably be accepted (though I won't find out until November 20th). Anyone else planning on going?
|
# ? Oct 30, 2008 05:38 |
|
Are there any more of these Perl conferences listed somewhere? I know there's the YAPC website, but Frozen Perl wasn't listed on there. Am I missing any else? I want to eventually have my work send me there. Or at the very least I just tank it myself with vacation days. Hmm, how much for plane and stay in Sydney...
|
# ? Oct 30, 2008 05:53 |
|
If you're logged into the conference site you can see something like this in your main page: (Since the conference I'm browsing from is Frozen Perl 2009 it doesn't link it)
|
# ? Oct 30, 2008 06:01 |
|
I signed up, but it's kind of gay there isn't a master list of these things in order. So far the only things on my radar are Frozen Perl and OSDC Australia, which is a $3000 package (hotel, flight). Does that sound reasonable for work to expense or is it too much? Hmm maybe they'll only expense the days that I'm actually at the conference...
|
# ? Oct 30, 2008 06:10 |
|
If they can be convinced of a trip to OSDC, now is probably the best time to pay - the Aussie dollar has tanked in the last few months relative to the USD.
|
# ? Oct 30, 2008 09:00 |
|
Sartak posted:There's going to be another Frozen Perl in Minneapolis on February 7th. I'll be there. I've submitted a talk for Devel::REPL and Carp::REPL that will probably be accepted (though I won't find out until November 20th). i just looked at this and it seems like Carp::REPL owns. is there any chance that its pure perl?
|
# ? Oct 31, 2008 01:49 |
|
It is almost pure perl. It depends on PadWalker to get (and set!) lexical information for the entire stack. PadWalker is implemented in C but it's so loving useful that it may eventually get cored. The only other tricky bit is hooking into die. You can do this by sticking a code reference in $SIG{__DIE__} and it'll be run before the program aborts. code:
|
# ? Oct 31, 2008 02:34 |
|
So I am trying to do something that I think should be pretty simple, but it's just not coming to my mind. I have a reference to an element in an array and I want to completely remove it from the array. How can I delete the array's reference to it without knowing its position in the array? I don't think you can do this with delete. Ex: code:
Neither does this work correctly... code:
edit: of course, I can always follow that loop up with @arr = grep { $_ } @arr to resolve it but I'm looking for something cleaner. ashgromnies fucked around with this message at 22:14 on Oct 31, 2008 |
# ? Oct 31, 2008 22:11 |
|
@arr = grep { $_ ne 'not' } @arr;
|
# ? Oct 31, 2008 22:24 |
|
ShoulderDaemon's way is probably best. It's the clearest which is the most important thing for code. Anyway, the operator you're looking for is splice. Here's how you can use it: code:
|
# ? Oct 31, 2008 23:00 |
|
Sorry, I should have clarified, I need to do some work on the value. I am passing an array ref recursively to a function, and want to erase elements from it when they've been processed. Maybe I can explain the entire thing and it will make more sense... I have a list of directory names belonging to various projects in an array. Every project has a root directory with a special application file in it that lets you know it's the root. Projects may be infinitely nested within eachother. So what I'm trying to do is find the nearest application file to every directory in the array. Here's the code I have thusfar: code:
Anyways, this works, I was just wondering if there's a better way.
|
# ? Nov 1, 2008 00:51 |
|
ashgromnies posted:Sorry, I should have clarified, I need to do some work on the value. I am passing an array ref recursively to a function, and want to erase elements from it when they've been processed. code:
|
# ? Nov 1, 2008 01:11 |
|
quote:map { s/\/[^\/]+$// } code:
|
# ? Nov 1, 2008 01:55 |
|
ashgromnies posted:So I am trying to do something that I think should be pretty simple, but it's just not coming to my mind. code:
|
# ? Nov 1, 2008 02:23 |
|
ashgromnies posted:Anyways, this works, I was just wondering if there's a better way. Don't think of @{$directories_ref} as an array, think of it as a queue: code:
|
# ? Nov 1, 2008 11:30 |
|
rjmccall posted:Don't think of @{$directories_ref} as an array, think of it as a queue: loving ace. I always forget about queues working in Perl all the time I also didn't know about File::Basename... is there a good core module reference anywhere?
|
# ? Nov 1, 2008 14:33 |
|
Triple Tech posted:It's a shame that Devel::NTYProf doesn't work on Windows. 2.07, released today, does!
|
# ? Nov 1, 2008 20:21 |
|
ashgromnies posted:loving ace. I always forget about queues working in Perl all the time perlmodlib(1)
|
# ? Nov 1, 2008 21:15 |
|
Sartak posted:2.07, released today, does! Nevermind, selecting inode as mirror showed it. Also, NYTProf doesn't work with Coro at all. Throws bunches of errors and trying to run nytprofhtml on the out file results in it trying to read the file, then crashing without even so much as a peep. Procmon shows it accessing the file and then directly jumping to the vsjitdebugger. Mithaldu fucked around with this message at 22:41 on Nov 1, 2008 |
# ? Nov 1, 2008 21:49 |
|
I'm having difficulty trying to get the module HTTP::GHTTP to have a timeout value. I'm using GHTTP because I'm trying to pull down a ton of very small objects simultaneously, and it's from all accounts the most lightweight of perl HTTP modules. From the module's CPAN page: quote:Doing timeouts is an exercise for the reader (hint: lookup select() in perlfunc). Ok, so I have the following: code:
EDIT: and by stupid I mean I got that while loop with select statement from someone elses suggestion online and stuck it in there without having a clue why it would work, so maybe that's why it doesn't. toadee fucked around with this message at 12:13 on Nov 8, 2008 |
# ? Nov 8, 2008 12:05 |
|
Well, select(undef, undef, undef, 15); should timeout for 15 seconds, so if its hanging indefinitely then it's probably something to do with the $r->process method call. Perhaps the request is timing out? Maybe the async call is being messed up by select causing a halt? Dunno. Make it print for every iteration to see whats going on. Use warn instead of print so that you can output to stderr and you wont have buffering issues.
|
# ? Nov 8, 2008 12:25 |
|
TiMBuS posted:Well, select(undef, undef, undef, 15); should timeout for 15 seconds, so if its hanging indefinitely then it's probably something to do with the $r->process method call. Perhaps the request is timing out? Maybe the async call is being messed up by select causing a halt? Dunno. Make it print for every iteration to see whats going on. hmm, yes, I see, it just sits there until $stat gets returned, which is what it looked like it would do when I saw it, but you know, people on the internet giving perl advice never lie... So maybe I just need a better understanding of how select() works? Reading the perldoc for it I don't see how this becomes useful in working a timeout value into GHTTP.
|
# ? Nov 8, 2008 12:31 |
|
I just installed ghttp to have a look. It seems like it is looping as expected, its just when I add sleep/select into the loop, it runs stupidly slow. I'm guessing the request is being affected by the main process being halted.. Oh and yeah, select is used to select a specific handle to use for standard IO operations. Select is blocking, so it will wait until the filehandle is available or until the specified timeout value is hit. The last parameter to select is a timeout value.
|
# ? Nov 8, 2008 12:38 |
|
TiMBuS posted:I just installed ghttp to have a look. It seems like it is looping as expected, its just when I add sleep/select into the loop, it runs stupidly slow. I'm guessing the request is being affected by the main process being halted.. Hmm, well then, any suggestions for something very lightweight that will make an HTTP request that I can assign a timeout value to? LWP is way way too big but nothing else I've found has an option for timeout, which seems bizarre since I can think of a lot of reasons why you wouldn't want a script that is in need of a screamingly fast and light HTTP module to sit around waiting for a dead server.
|
# ? Nov 8, 2008 12:41 |
|
Well I don't really see why select is needed at all for a timeout.. I'd just do something like: code:
e: Oooh I see now, you didnt know at all that select with an undefined handle acted pretty much exactly like sleep. I should have realized that in the first place (I thought you were trying to use it to wait while you were in your loop, you know to save CPU). I was a bit confused there heh. But yeah the above code should handle timeouts for you. TiMBuS fucked around with this message at 12:54 on Nov 8, 2008 |
# ? Nov 8, 2008 12:46 |
|
oh! duh! Alright, yes, that does work... thanks!
|
# ? Nov 8, 2008 12:54 |
|
I'm having difficulty writing a program that determines whether a 7 character input is a character. I am not allowed to use arrays, reverse, split, join; just basic perl functions. So far I have code:
|
# ? Nov 9, 2008 21:43 |
|
Voltaire posted:[9,8,7,6,5,4,3,2,1,0] == [0,1,2,3,4,5,6,7,8,9] This doesn't work; equality for array references just checks if they point to the same array. You need to iterate over the elements. This seems terribly obtuse for a homework question. Job interview?
|
# ? Nov 9, 2008 21:48 |
|
Sartak posted:This doesn't work; equality for array references just checks if they point to the same array. You need to iterate over the elements. Yes it is for a job interview. They very specifically said no arrays or use of reverse. Urghhhh....
|
# ? Nov 9, 2008 21:50 |
|
Voltaire posted:7 character input is a character. Voltaire posted:if ($input = [9,8,7,6,5,4,3,2,1,0] == [0,1,2,3,4,5,6,7,8,9]) Also, they're right. All you need for this is one regexp and some ifs. Lastly, try reading the PBP sometime, if you're going to program in it. Any coworkers will be grateful for that.
|
# ? Nov 9, 2008 21:56 |
|
|
# ? Jun 3, 2024 23:39 |
|
Mithaldu posted:You mean palindrome? Yes a palindrome. it can be numbers, letters, spaces. i have. im not even sure where to start with this one without using split and join.
|
# ? Nov 9, 2008 21:59 |