| |
| |
| |
|
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
Comments:
<0> Botje: thats the idea, but there is no way to have the regex itself return a true/false? <1> Why are you so insistent on using a regex for this? <2> note that y/0-9// doesn't modify the string <1> I mean, /(?:.*?\d){9}/s is hideous. <1> s/9/10/ <3> cbrinker: \d\D*\d\D*\d\D*\d\D*... (you get the point) <2> \d(?:\D*\d){9} <3> yes. what mauke said. <1> Yeah, the \D is better. <3> except the y/// version is much much much much more readable. <3> but then again, your language (not perl) probably doesn't have y/// <0> My hope was to have a good regex that could be (re)used in my perl/ruby/cf/javascript/etc validation routines. <4> hahhahahaahhaha <5> why are you asking about non-perl regex in #perl <5> that's really being a bit dishonest <3> write your own damn state machine.
<5> in fact, almost downright mean <4> uh oh <4> you've hurt merlyn's feelings <6> does this happen daily at this time? <5> has nothing to do with my feelings. <4> bderrly: flaming? no, it happens round the clock <5> has to do with common sense. :) <5> the trouble with common sense is that it's not very common any more. :( <4> merlyn: i consider it a compliment. everybody knows perl folk know just about everything <2> (replicate 10 () <=) . map (const ()) . filter isDigit <3> mauke: O_o <2> what <0> merlyn: the people in cf chat rooms are not very regex savvy :) and lets just say I am not surprised that someone in here had an elegant answer <2> GumbyBRAIN: @run (replicate 10 () <=) . map (const ()) . filter isDigit $ "foo123456789bar0" <7> Filter it at http://perldoc.perl.org/functions/map.html. <2> wankit <8> The Greek pronunciation of Perl 6 is Zeus. <9> Will someone tell me how (or point me at a perldoc) to convert a string of 1s and 0s representing a binary number into that number? <10> ParlStalker, perldoc -f pack <8> pack. To access this perldoc please type, at a command line, 'perldoc -f pack'. You may also find it at http://perldoc.perl.org/functions/pack.html <11> PerlStalker: print oct("0b$binary_string"); <3> PerlJam: that's cheating :P <11> Botje: I'm sorry ... I thought this was #perl ;-) <3> go stand in the corner and wear this dunce cap :P <11> PerlStalker: note though that my solution is only good for numbers that have less than (on my architecture) 33 bits. <9> That should be fine. I'm playing with netmasks. <12> If I have a tied hash, can I bless that? <12> It's tied in XS. <11> postwait: you can only bless scalar references. <12> And I want to bless it in XS as well... you think that will backfire? <12> You can bless refs to just about anything <3> PerlStalker: I hope you're using Net::Netmask, Net::CIDR, or likewise <9> I figured I'd do it the hardway. <11> postwait: what I mean to say is that you can only bless references (which are scalar thingies). You can't bless a hash. <3> ah. reinventing the wheel for no particular reason. that's always fun ;) <9> Exactly <12> I have a ref to the hash. <12> It's an RV * (noinc) of an HV * that has hv_magic of PERL_MAGIC_tied <3> yay magic^WXS! <11> postwait: why is it that you want to bless this tied thing? <12> In XS. <12> I have a tied hash...(tied to a an XS implementation) <12> And I want to be able to invoke methods on it. <12> So it would make sense to bless the resulting tied hash's ref into a cl*** of my choice <12> and then implement whatever methods I need in that cl***. <12> just not sure if it is going to have an "unexpected" interaction with the tie. <11> postwait: try it and let us know how it goess :) <11> postwait: I think it'll be just fine given that bless and tie are orthogonalish <12> they are supposed to be.. yes. <12> Will let you know. <13> "SRCR" at 80.127.87.78 pasted "convert Snort signature .txt files to importable mysql file" (64 lines, 2.7K) at http://sial.org/pbot/17474 <14> postwait: it might be better to use the obect returned by the tie rather than the hash tied. <14> object too. <15> I want to get the right side of user=someone; <15> my $left =~ s/.*?=//g; <--- This I tried <15> But somehow it didn't work! <11> Stormbreaker: It did work. It did exactly as you asked of it. <3> my ($left, $right) = split /=/, $foo, 2 <15> Strange.. <15> (Meant the left side)
<14> eval: $_ = left=right; ($l, $r) = /([^=]+)=(.*)/; join ":", $l, $r <8> cfedde: Error: Can't modify constant item in scalar ***ignment at (eval 170) line 1, at EOF <14> eval: $_ = "left=right"; ($l, $r) = /([^=]+)=(.*)/; join ":", $l, $r <8> cfedde: Return: left:right <3> SRCR: what's so damn hard about it? <15> PerlJam, but somehow it doesn't print the left side <3> just slurp it all in one scalar <15> my $left =~ s/.*?=//g; <15> print($left); <3> and split on "\n--\n" <15> It's just acting as if nothing would be print. <3> or set $/ to "\n--\n" and read in chunks .. <11> Stormbreaker: did left start out as "foo=bar"? <11> s/left/$left/ <15> PerlJam, got it! My mistake!! <16> Does IO:Socket come with perl 5.8? <11> And if so, your s/// is asking perl to remove the left side and keep the right side. <3> corelist: IO::Socket <8> This was added to Perl5.00307 <3> whiteghost: it comes with perl 5.5, even :P <17> Botje: It's kinda difficult if you don't know any perl.. <3> SRCR: I can see that. <11> corelist++ <3> so why are you doing it in perl? <11> Botje: because perl is the obvious choice! ;) <16> Botje,I just download it lol <3> PerlJam: yes! perl is all about regexes! brilliant! <17> Botje: I agree with PerlJam <3> why? you don't know perl <17> Botje: I know that much about perl and I know regexp (in scripts) <18> PERL IS GUD <3> okay. <3> I told you how to do it <3> try, and if you can't get it to work, come back. <11> SRCR: http://learn.perl.org/library/beginning_perl <3> setting $/ is probably the easiest way, if you've done some perl before. <17> Botje: i have know idea what $/ is but splitting on \n--\n seems sensable <19> PerlJam, you asked before if i understood why woggle's fix worked. I don't (I have a notion of the problem space, but would not have thought that this would work) <19> woggle, I was pestering you folks on ##c 'cause I wanted to know the fundamentals behind a prob i'm working on in perl <19> woggle, i need to ***ign fd 3 to a particular pipe. i can use $(open FOO, '<&=', 3) to ***ociate a particular file handle with 3, but I need to ***ociate a file *descriptor* with 3. any pointers? <19> PerlJam, re Bummer, yeah, kinda was. i feel pretty sorry for those involved <1> Quoting Perl code like that will probably confuse people. <19> woggle, the $(foo) convention? borrowed from shell, but yeah, not so applicable here <1> However, you can use open() to dup2 one filehandle to descriptor 3. <11> ericP: in your first example you had something like for (my $i = 0; $i < $max; $i++) { ... } This uses the same $i for each iteration of the loop. woggle told you to use for my $i (0..$max-1) { ... } because it creates a new $i for each iteration of the loop. The nature of closures is to "close over" the environment when they are created, thus the first closed over the same $i which was 3 at the end of your loop. <20> ericP: You're not making sense <20> ericP: 3 _is_ a file descriptor, because file descriptors are numbers :) <20> ericP: if you want to do something with it, you open a handle to it, like you were showing. <1> Or more manually, you can use the POSIX's modules dup2(). <14> first you have to make cents, then the dollars will follow. <19> hobbs, yeah, the prob is that the current fd is like 11, after a fork. i need to move it down to 4 <20> ericP: ... why? <19> hobbs, in C, i guess i would dup <1> ericP: Once you have a filehandle that refers to the file descriptor you want, you ought to be able to reopen it. <19> hobbs, 'cause something later on knows of it as 3, and will try to open '<&=' 3 to get to it <20> ericP: you can use POSIX::dup in Perl -- but why do you need 4? And why do you ***ume that 4 is available? :) <1> I presume he's about to exec(). <1> In which case he needs to know about $^F <20> ericP: try POSIX::dup2 then <19> am indeed about to exec <19> hobbs, tx. will look at that as soon as i answer woggle and PerlJam <19> woggle, i had the impression that open would do it, but had no idea where to put the 3 (of course, it's not always a 3, but good for our discussion) <20> ericP: no, open always gives you an actual filehandle. POSIX::open returns fds, but it doesn't have any of the magical dup features that are in CORE::open -- because those are in POSIX::dup and POSIX::dup2 instead ;) <19> PerlJam, is it my imagination, or is the distinction between the lifetime of the for (my $i...) and the foreach my $i sort of arbitrary <20> ericP: not really <11> it's your imagination :) <19> PerlJam, that is, i very much appreciate both the solution and the explaination, but i'm trying to understand how i'd be able to figure that out (maybe from syntax hints?) <20> ericP: the for unrolls into "my $i = 0; { last unless $i < $max; ... } continue { $i++ }" <19> or maybe my imagination is just trying to let me off easy <20> er... that's sill <20> my $i = 0; while ($i < $max) { ... } continue { $i++ } <20> notice that $i is by necessity scoped _outside_ of that while loop
Return to
#perl or Go to some related
logs:
#perl install pptpconfig fedora 5 chroot ubuntu Gtk-WARNING **: cannot open display:
jorgepena.be #bash #perl #perl #debian ubuntu+nForce 410+ethernet #perl
|
|