| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
Comments:
<0> Zaphar_work, what is a compiled regex? <1> perldoc perlreref <2> perlreref - Perl regular expressions quick reference. To access this perldoc please type, at a command line, 'perldoc perlreref'. You may also find it at http://perldoc.perl.org/perlreref.html <0> something like: "foreach my $filename (@included) { # some regex magic here }" <0> ? <1> yes <1> something like <3> perldoc -f qr// <2> qr. To access this perldoc please type, at a command line, 'perldoc -f qr'. You may also find it at http://perldoc.perl.org/functions/qr.html <3> (qr - quote regex) <0> hm, I don't know regex well enuff for this... just simple matching <1> gr00ber: perfect time to learn :-) <0> or does the regex engine know about wildcards? <1> gr00ber: all you could wish to know are in the above links to documentation <0> Zaphar_work, I guess :-) But my boss is almost sitting on my lap waiting for me to be done. Time to g00gle for shortcuts :-)
<0> Zaphar_work, do I need a double loop? I.e. inside the loop above, have another loop over @excluded that matches against $filename using some regex? <0> or can regex work on items in an array directly? <1> my $regex = gr/debug.*\.txt/; print "found a debug file" if $filename =~ $regex <1> gr00ber: yes a double loop <0> lemme see... g is global and r is ? <1> actually that should be qr <1> mistyped <1> it creates a precompiled regex which you could then store in an array <1> push @regex, qr/regex here/; <0> will this work? my @ignorelist = (qr/debug.*\.txt/, ...); <1> yep <0> thanks <3> gr00ber: It can never be global. Regex modifiers (such as the global modifier g) go at the end. Never at the start <1> what he said :-) <0> oh <0> let's see: "debug.*\.txt" .... what does the dot after debug mean? <1> read up on the meta characters when you create your regex's cause the wildcards and such don't work like a dos wildcard <1> the dot stands for any single character <0> ok <0> like slash :) <1> the star modifies the dot to mean 0 or more of any character <3> AKA quantifier. :) <0> ah <1> and the slash escapes the next dot to mean an actual dot <1> now go read :-) <3> s/slash/back slash/; <0> yup :) <4> i got it to work guys, thanks Ani-_, Zaphar_work, and dkr. i used a relative path this time <4> using a predefined base variable <1> you'll quickly get addicted to regex's if you do much of this <0> and \/ means an actual slash, right? <1> you got it <3> That's one way to write it. :) <1> this being perl of course there's more than one way to write it :-) <0> yeah, regex seems very powerful, but I never got around to learn'em. Time to roll up the sleeves. <5> m#/slashes/are/fun# too <3> If you have a regex with a lot of slashes then it is easier to change the delimiter. For example: m#a/b/c/d# would match the string: a/b/c/d (# can be whatever you want. But to do that you need the m) <1> yeah for long regexes with a lot of slashes that is very helpful <1> Spetsnazgg_: glad you got it working <0> Ani-_, nice! <3> If it's a really long regex then x-modifier can be handy aswell. (If you want to know what it does then look at the docs) <6> don't use #, that can be a valid regex char, :) <7> #perl topic for the evening "Regexen for fun and profit!" <6> (if you use /x liek Ani-_ just mentioned ;) <8> regexes are also useful in writing the actual code <6> it's raining yet again and my convertible top is leaking, :( <3> dkr, but how ofthen do you use /x? :) <6> Ani-_: I just wrote one actually, and I even used # to help me figure out what part of the regex wasw rong, :) <8> Sometimes you can prevent lot of typing with some good regexp <6> Ani-_: it was for parsing an xml formatted logfile <0> ok, so in this double loop I would like to move on in the outer loop. Is there an "next outer" thingy ? :-) <3> dkr: I use m## more ofthen then m//x; (Mainly because I can't think of a better delimiter) :/ <6> yeah, use a label <0> ah, like OUTER: for ... <6> nod <0> then next OUTER; ? <3> gr00ber: perldoc -f redo <2> redo. To access this perldoc please type, at a command line, 'perldoc -f redo'. You may also find it at http://perldoc.perl.org/functions/redo.html <0> niiice <0> hm
<3> redo has an example of it usage. It also applied to last and next <0> right... worked nicely. Thanks. <6> Ani-_: I like ~ as a delimiter since it doesn't mean anything to perl and rarely appears in strings. so my code has lots of q~ and qq~ in it, :) <0> next task: get the timestamp of each file and put them in a database or something... maybe a text file. So the next time the script runs, compare against it's previous timestamp and skip building if unchanged. <0> design suggestions before I hack on ? :) <6> someone brought up the point the other day that if you use m{} then yuo can have ensted { and } inside <3> dkr: $x =~ m~ ~g; looks a bit strange... :/ <6> Ani-_: yeah, I just use it for quotes, not matches <6> oh yeah, ~ does mean something to perl, forgot, :) <1> it looks like a lot of characters swimming around in the code :-) <3> What character doesn't? :) <9> you can even use ';' as a delimeter <10> http://www.flickr.com/photos/clearhop/165029704/in/pool-wm2006/ <10> what's with the Keep me English <11> "rbellamy" at 67.169.146.106 pasted "SVK mirror to mirror copy error" (6 lines, 407B) at http://sial.org/pbot/18036 <3> eval: "mxm" =~ mmxm ? "Match" : "No match"; <2> Ani-_: No match <1> gr00ber: why are you making a build system anyway? why not just use one of the freely available ones? <3> deparse: "mxm" =~ mmxm ? "Match" : "No match"; <2> (('mxm' =~ /mmxm/) ? 'Match' : 'No match'); <3> Bah. <3> deparse: "x" =~ msxs ? "Match" : "No match"; <2> (('x' =~ /msxs/) ? 'Match' : 'No match'); <0> Zaphar_work, it's highly specialized <3> eval: "x" =~ m mxm ? "Match" : "No match"; <2> Ani-_: Match <0> I usually use GNU make <12> I have a ~/.cpan/CPAN/MyConfig.pm and a /etc/perl/CPAN/Config.pm. They're identical and work fine on another system. But when I try to install a module, I get "we have to reconfigure CPAN.pm due to the following uninitialized parameters..." followed by a list of parameters covered in my config, followed by a MyConfig.pm initialized line, then am I ready for manual configuration. How can I get cpan to use my config? <0> maybe a text file with "filename, timestamp since epoch" pairs on each line will do? <9> eval: quote for you <2> pravus: <1> gr00ber: how many files are you talking? <0> Zaphar_work, about 2000 <13> How can I flush STDIN? I'm trying to create a script that accepts piped input (eg. echo "test" | myscript.pl ) and then asks the user for further input. The problem I have is that the piped input is being used when I want the further user input. I'm currently using Term::ReadKey to get the input, is there perhaps a better way of getting the user input on the console? <1> hrmmm not too bad but might be easier to just store in a sqlite3 db <3> gr00ber: you do know that one can change the timestamp of a file? <14> You can't flush STDIN <14> The thing that sends data to you, has to flush its STDOUT <0> Ani-_, yes? <3> gr00ber: yes. man touch <1> gr00ber: you might want to use a hash of the file instead to check if it changed <0> oh, you mean not the modified date but something else <0> Zaphar_work, yeah, been thinking about that <3> I do mean the modified date. <13> LeoNerd: OK. Thanks. Is there an alternative way of doing what I want to do (accept piped input and then ask for further user input)? <0> Ani-_, well... that's the point: only build files who's modification date has changed <15> If a user enters a relative filesystem path, can someone reccomend how I can change this to complete path? <3> man touch: -m Change the modification time of file <0> Ani-_, i don't get your drift <14> Sure.. You can open /dev/tty, and if your process is connected to a terminal, you'll get that. <3> gr00ber: and my little point is that one can change the file and modify it's timestamp. <3> To make it look to your script that it didn't change <0> Ani-_, ah, but I don't care about that, since I control all the files <1> he means that a timestamp isn't a reliable indicator <0> they are only changed by my editor <0> Zaphar_work, fair <0> but not an issue <0> it would be an issue in a production quality system, but this is a specialized, short-lived script for prototype system <1> ahh <3> I never said it was an issue. I only asked if you knew that you could. <0> Ani-_, ok :) <1> Ani-_: is looking out for ya :-) <1> he's got your back <1> if it's just a quick and dirty script then a text file is probably just fine <1> if it has to be used more robustly then sqlite would be my preference for storing the file and timestamps <0> Zaphar_work, ok... but I've used sqlite in C++ and it worked out nicely <0> are the Perl bindings easy to use? <0> and install? <1> install DBD::sqlite in cpan and that's all you have to do <1> DBI is pretty simple to use <1> perldoc DBI <0> that way I could store even the regexp's... you see: it's not THAT shortlived - we're making prototypes of a huge system with multiple languages, etc... so it will live at least 6 months or so. So it should **** to much :) <0> DBI == database interface? :)
Return to
#perl or Go to some related
logs:
xorg-server app autostart nukepuppy automated id3-tagging linux -windows merge strings python #oe programs i digitalbit #css #xine Player for encrypted wmv djpirate
|
|