|
The directories I'm copying to are monitored by various processes which consume the files I move. They're expecting a file to be there - I have no idea how they'd perform given a link. I don't expect it to go well.
|
# ? Sep 6, 2012 00:35 |
|
|
# ? May 17, 2024 20:30 |
|
Clanpot Shake posted:The directories I'm copying to are monitored by various processes which consume the files I move. They're expecting a file to be there - I have no idea how they'd perform given a link. I don't expect it to go well. A hard link is a file, for all intents and purposes.
|
# ? Sep 6, 2012 00:44 |
|
I didn't write these listeners, so I have no idea how they'll work given a link. Given all the weird poo poo I've seen them do, I'm not counting on a link working in this case. How do I move a file and set it to no read permissions in the destination?
|
# ? Sep 6, 2012 01:38 |
|
Clanpot Shake posted:I didn't write these listeners, so I have no idea how they'll work given a link. Given all the weird poo poo I've seen them do, I'm not counting on a link working in this case. On unix-like systems, there is literally no difference between a link and a file. Every file is a link. Clanpot Shake posted:How do I move a file and set it to no read permissions in the destination? Just set the file to no have read permissions, then move it. You don't need any permissions whatsoever on a file to move it.
|
# ? Sep 6, 2012 01:52 |
|
ShoulderDaemon posted:On unix-like systems, there is literally no difference between a link and a file. Every file is a link.
|
# ? Sep 6, 2012 02:06 |
|
Clanpot Shake posted:Is there a way to do it without changing the source permissions? I've already written the thing and changing it to do links instead of copy sounds like more trouble than it's worth. To be honest, your entire problem doesn't make much sense to me. Moving files is just a rename operation; it's instantaneous, and there's no way for another process to read a file that's been "half-way moved". It really sounds like you're copying a file, not moving it. If that's the case, you could perhaps copy to a temporary location, then move from that temporary location to the final location in order to avoid your race condition.
|
# ? Sep 6, 2012 02:14 |
|
Clanpot Shake posted:Is there a way to do it without changing the source permissions? I've already written the thing and changing it to do links instead of copy sounds like more trouble than it's worth. Note that if the source and destination directories are on different filesystems, you will not be able to hard link across them. edit: ShoulderDaemon posted:To be honest, your entire problem doesn't make much sense to me. Moving files is just a rename operation; it's instantaneous, and there's no way for another process to read a file that's been "half-way moved".
|
# ? Sep 6, 2012 02:15 |
|
Well, yes, moving across file systems is a typical situation that I hadn't thought about. Anyway, Perl's sysopen function lets you specify the exact file mode (you'll probably want 0200, write-only) and IO::File::open does too. If you're using some other module I can't say what its equivalent would be.
Gazpacho fucked around with this message at 02:23 on Sep 6, 2012 |
# ? Sep 6, 2012 02:20 |
|
Sorry if I wasn't clear: I'm copying the file, not moving it. The source and destination are on the same mount point, which is shared by multiple servers. I'll look into sysopen and rename tomorrow; those sound like what I need. Thanks guys.
|
# ? Sep 6, 2012 02:58 |
|
ShoulderDaemon posted:Moving files is just a rename operation; it's instantaneous, and there's no way for another process to read a file that's been "half-way moved". Historically, there have been some lovely "weirdnix" Unix implementations where rename(2) either didn't exist, wasn't ever atomic, or wasn't atomic under some circumstances. The most recent of these is OS X through Snow Leopard (I think Lion fixed it).
|
# ? Sep 6, 2012 03:01 |
|
Otto Skorzeny posted:Historically, there have been some lovely "weirdnix" Unix implementations where rename(2) either didn't exist, wasn't ever atomic, or wasn't atomic under some circumstances. The most recent of these is OS X through Snow Leopard (I think Lion fixed it).
|
# ? Sep 6, 2012 03:09 |
|
Clanpot Shake posted:I've got a problem that requires some deeper knowledge of of Unix file permissions than I have. I have a script that moves files from one directory to another (really a map of several dozen source->dest directories but that isn't important). Permissions are going to throw up all kinds of errors in the other service. Does it recheck permissions or only watch the folder for new files? Cause if it only watched, that's going to break. Does the service picking up files pick up only specific extensions, or all files? The correct way to do this would be like suggested earlier -- having a temporary, unwatched folder. Copy the file to there, then move the file from the holding folder to the target directory.
|
# ? Sep 6, 2012 17:59 |
|
I've been trying to use Web::Scraper more, but basic html always pushes me to resort to regex. An example of a repeating chunk that is easy to do with regex, but I can't figure out with Web::Scrapercode:
Here is the script I wrote that uses a mix of Web::Scraper and regex. You'll want to turn off word wrap http://pastebin.com/F6G6zwaH
|
# ? Sep 30, 2012 05:30 |
|
I cannot for the life of me get the tr/// function to work. Here's a snippet of my code (although I've repeated trying to use it in various other places, and still doesn't work):code:
syntax error at Test.pl line 71, near "tr/ATGC/TACG/i" Execution of Test.pl aborted due to compilation errors. And geany is highlighting "tr/ATGC/TACG/i" as if it's not even a function available to me. After several hours of searching, the most I can come up with is that using perl -v, gives me 5.14, but that shouldn't be an issue, right?
|
# ? Oct 2, 2012 05:52 |
|
i isn't a flag to tr; honestly if it's possible I would recommend normalizing case before doing any of this and then you won't have to worry about it edit: this is admittedly a really cruddy way of erroring out
|
# ? Oct 2, 2012 05:57 |
|
tr/// is not a regex, so the 'i' doesn't actually do case insensitivity like you might think it does (tr/// has c,d,s). You want s///
|
# ? Oct 2, 2012 06:04 |
|
uG posted:tr/// is not a regex, so the 'i' doesn't actually do case insensitivity like you might think it does (tr/// has c,d,s).
|
# ? Oct 2, 2012 06:21 |
|
het posted:s///i won't preserve case though, I was assuming if he was using tr that was necessary. You could also just do two tr lines I guess. If it's just the GATC you want transliterated and you want to preserve their case, you'd want tr/ATGC/TACG/ and then tr/atgc/tagc/ If you want just the sequencing data uppercased then tr/atgc/ATGC/ tr/ATGC/TACG/ It depends on what you actually want to do with your source data, and what your source data contains (whether or not your data is just a file full of GATGAACTGCGATCGATGCAT or other information/headers, and whether case is sensitive on the sequence).
|
# ? Oct 2, 2012 06:53 |
|
The Gripper posted:Would tr/ABC/DEF/i preserve case though, if it was an actual thing? I'd think it'd just replace all search characters (upper and lower) with uppercase replace characters. quote:If it's just the GATC you want transliterated and you want to preserve their case, you'd want tr/ATGC/TACG/ and then tr/atgc/tagc/ edit: to be clear, I think the best option is to make sure the output is fine with a normalized case and to just do that first off before you do anything else.
|
# ? Oct 2, 2012 07:32 |
|
Or, indeed,code:
|
# ? Oct 2, 2012 10:42 |
|
In this case the output doesn't matter much. This is for a class of sorts, so I'm doing my best to refrain from getting answers - I'm trying to troubleshoot and the PhD student teaching it (bioinformatics) is teaching this for the first time. I sent him the error, and have yet to receive an answer. Anyways, all we're attempting to design primers for two strands of DNA. For the reverse primer, we're taking a strand (lets say AAATTTCGC), reversing it (hence reverse($primer_r) to CGCTTTAAA, then translating it to it's complement so it can anneal (GCGAAATTT). Taking the /i flag off seems to work. It was my understanding using s/// would substitute whole strings, say if I wanted every AAT in the sequence to be translated to TTA; whereas tr/// would replace each individual character (which is what I want to do). Am I on base here?
|
# ? Oct 3, 2012 03:08 |
|
SaxMaverick posted:Taking the /i flag off seems to work. It was my understanding using s/// would substitute whole strings, say if I wanted every AAT in the sequence to be translated to TTA; whereas tr/// would replace each individual character (which is what I want to do). Am I on base here? s/// will match an entire pattern and replace it with the replacement string/pattern e.g. s/hello/hi/ will turn "hello everyone!" into "hi everyone!". tr/// replaces individual characters with their counterparts e.g. tr/ABC/DEF/ will replace all A's with D's, B's with E's, C's with F's, but those characters don't need to be consecutive. It'll turn something like "A Big Cat" into "D Eig Fat", for example.
|
# ? Oct 3, 2012 04:22 |
|
I'm sure there is a reason its not a good idea, but why can't I use system/exec calls to run code inside a thread (to avoid running out of memory)?
|
# ? Oct 6, 2012 20:45 |
|
uG posted:I'm sure there is a reason its not a good idea, but why can't I use system/exec calls to run code inside a thread (to avoid running out of memory)? Threads share address space, so any memory they allocate is counted against you too. But from the way you formed that question I'm guessing that if you give a better description of what you're trying to do we can come up with a better solution.
|
# ? Oct 6, 2012 21:15 |
|
This is a shortened piece of code that I'm using to test a subroutine.code:
(here is the input file for reference) code:
SaxMaverick fucked around with this message at 03:42 on Oct 8, 2012 |
# ? Oct 8, 2012 03:37 |
|
Well, I'll leave the last post up in case there's a huge mistake, but I seemed to have fixed my problem by using:code:
|
# ? Oct 8, 2012 03:48 |
|
SaxMaverick posted:Well, I'll leave the last post up in case there's a huge mistake, but I seemed to have fixed my problem by using: Also that code doesn't work for me outright because of line 20 with use warnings; enabled (Perl 5.14), since it tries to get the value of $fasta_database{key} before setting it for the first line after a key line. Changing it to: Perl code:
|
# ? Oct 8, 2012 10:24 |
It's kind of cool to see that PERL (sorry, Perl... looks like it isn't all caps, these days) is still alive and kicking. I don't care what anyone says, I like Perl, and I loved coding in it. It's been ten years since I logged into my PerlMonks account, but I've still probably written more lines of PERL than any other single language I've used. Who can tell what this does without cheating via Google or executing it? s>>sp>;s>..|>\u$&ace>g;print;
|
|
# ? Oct 9, 2012 03:25 |
|
Ninja Rope posted:Threads share address space, so any memory they allocate is counted against you too. But from the way you formed that question I'm guessing that if you give a better description of what you're trying to do we can come up with a better solution. There isn't actual sharing between threads, it was just scripted this way for some reason. It can get about 90% done before I run out of memory and get a segfault, so i'm trying to pinch as much overall memory as possible even if it ruins readability. For the record I am scraping drivers from a different manufacturer's website, so for every product I start a new thread to scrape each language/OS combination (the web site is EXTREMELY slow). Another question though. i have a module that creats the dameru levenshetin edit distance between 2 strings. If I wanted to create an automaton to take a list and find all matches under a certain distance, should I relase it as Module::Name::automaton? or build it as an additional method in the original module? The reason I am using separate namespaces as an option is because i'd like to release XS versions of these (which I know absolutely nothing about). uG fucked around with this message at 04:03 on Oct 9, 2012 |
# ? Oct 9, 2012 03:58 |
|
uG posted:Although it seems like forks is a drop in, and while having more overhead, should help a little to counter act memory leaks growing on stop in threads (maybe this doesn't happen)? The code I generally use for fork/exec on syscalls that I don't give a poo poo about the return value of is: Perl code:
The Gripper fucked around with this message at 07:09 on Oct 9, 2012 |
# ? Oct 9, 2012 06:52 |
|
Centripetal Horse posted:It's kind of cool to see that PERL (sorry, Perl... looks like it isn't all caps, these days) is still alive and kicking. I don't care what anyone says, I like Perl, and I loved coding in it. It's been ten years since I logged into my PerlMonks account, but I've still probably written more lines of PERL than any other single language I've used.
SpaceAce
|
# ? Oct 9, 2012 11:20 |
|
Today I learned that Perl regular expressions have a \u escape sequence which can be used to upper-case the next character. Whyyyyyyyyy
|
# ? Oct 9, 2012 11:46 |
|
qntm posted:Today I learned that Perl regular expressions have a \u escape sequence which can be used to upper-case the next character. You can do some seriously loving magical poo poo to data using regular expressions. I really suggest reading through the Perl Regular Expressions Reference page properly and doing some experimenting. Regex (generally) carries across languages too, so it's useful in other places, and it also makes you look like a goddamned wizard when it comes to transforming data. Rohaq fucked around with this message at 13:29 on Oct 9, 2012 |
# ? Oct 9, 2012 13:27 |
|
Rohaq posted:It's useful when you've transposed data, or used capture groups, and don't want to do some messy coding just to convert your output to Title Case. Also, if you can find a first edition of "Mastering Regular Expressions", you grab that motherfucker with both hands. It's one of the few tech books I've genuinely enjoyed reading, and it will expand your regex understanding by a degree you can't imagine. (It got revised in later editions to be suckier.)
|
# ? Oct 9, 2012 13:32 |
|
prefect posted:Also, if you can find a first edition of "Mastering Regular Expressions", you grab that motherfucker with both hands. It's one of the few tech books I've genuinely enjoyed reading, and it will expand your regex understanding by a degree you can't imagine. (It got revised in later editions to be suckier.)
|
# ? Oct 9, 2012 14:08 |
Rohaq posted:
You worked that out without running it or Googling? Very nicely done! The "..|" stumped many people, including some experienced Perl Monks, when I used it as my Perl signature (back when such a thing was common... is it still?) Mostly, it was the capitalizing of the "A" in Ace that they couldn't get a grip on without running the code. I love Perl. I especially love regular expressions in Perl. qntm posted:Today I learned that Perl regular expressions have a \u escape sequence which can be used to upper-case the next character. Knowing is half the battle. Centripetal Horse fucked around with this message at 17:41 on Oct 9, 2012 |
|
# ? Oct 9, 2012 17:38 |
|
Centripetal Horse posted:It's kind of cool to see that PERL (sorry, Perl... looks like it isn't all caps, these days) is still alive and kicking. I don't care what anyone says, I like Perl, and I loved coding in it. It's been ten years since I logged into my PerlMonks account, but I've still probably written more lines of PERL than any other single language I've used. the perl shibboleths I use are less code:
code:
code:
|
# ? Oct 9, 2012 17:46 |
|
tef posted:
|
# ? Oct 9, 2012 17:57 |
|
het posted:What does this do? I tried running it and nothing printed and @butts wasn't modified; is the point just that if you pass sort something that always returns 1, it won't do anything? Did you try loading @butts with numbers? If you didn't, I bet you weren't using warnings.
|
# ? Oct 9, 2012 18:11 |
|
|
# ? May 17, 2024 20:30 |
|
Anaconda Rifle posted:Did you try loading @butts with numbers? If you didn't, I bet you weren't using warnings.
|
# ? Oct 9, 2012 18:15 |