| |
| |
| |
|
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
Comments:
<0> you do $content = file($file); <0> you dont have to install any modules or anything <1> derr, good for php <2> dude, file() is a crappy name and it returns an array <1> $content = read_in_fileAllatOnce( $file ) <2> you can do the same thing in perl with @contents = <$fh>; <3> Paladin, .. i just dont get it .. how can i say decimals separated by comas ? i tried putting decimals first but as soon as i make the rest optional thenit matches anything thatstarts with decimals but with even characters following it <4> /[\d,]+/ <4> that only matches, it allows ,,, too :) <0> mauke; file_get_contents() <0> ok last question <4> acidjazz: LEARN PERL KTHX <3> Botje, not good .. i need to get rid of multiple comas <0> now that i have the contents of the file, i need to pipe it through a unix command <2> yeah, that's pretty much File::Slurp::read_file <5> dos000: so you want a string to start with 1 or more decimals, followed by one or more of (comma followed by one or more decimals), right?
<0> mauke; right but you dont have to install that <3> Paladin, correct .. the coma is optional so you could have 1 only there <2> what's the problem with installing modules? <6> dos: \d+(?:,+\d+)? <5> dos000: ok.. so how do you say "start with one or more decimals"? <3> \d+ <5> dos000: then how do you say "followed by one or more of (comma followed by one or more decimals)"? <2> also, sub slurp { my ($file) = @_; open my $fh, '<', $file or die "$0: $file: $!\n"; wantarray ? <$fh> : do {local $/; <$fh>} } <5> dos000: or "followed by zero or more (comma followed by one or more decimals)" if that's the case <3> ([ ]*,+[ ]*\d)+ <3> Paladin, there could be spaces there as well <5> dos000: ok.. so add them where needed.. <5> dos000: did you want more than 1 comma in a row? <3> Paladin, only one comma ([ ]*,[ ]*\d+)+ <5> dos000: ok.. so now put them together <3> Paladin, \d+([ ]*,[ ]*\d+)+ <5> dos000: now test.. <3> Paladin, is there a one liner to test this in perl ? <5> dos000: print "yes" if "blah" =~ /foo/; <3> Paladin, ok ! thanks <3> Paladin, i tried perl -e 'print "yes" if "123" =~ /\d+/;' in bash but no matche :-( <3> Paladin, sorry .. my bad <3> perl -e 'print "yes\n" if "123" =~ /\d+/;' <3> Paladin, wait .. it even matches when i do perl -e 'print "yes\n" if "12l3l" =~ /\d+/;' <7> eval: $_="123"; /\d+/ ? "yes":"no"; <8> dec: Return: yes <0> ok so how about this, how can i pipe a file handle through a unix command? <3> dec, i cant make perl -e '' whith that expression <2> perl -wle 'print "123" =~ /\d/ ? "yes" : "no"' <7> perl -le 'print "yes" if "123" =~ /^\d+$/' <3> dec, this matches 123l also ... how do you say make the expression match this pattern. instead of search first match <3> wait <7> I don't understand. <3> dec, what you have with the end $ works ! <1> ooh snap, Package::Alias <0> i did it :0 <9> perldoc Package::Alias <10> another way to do it... <9> bleh, i guess the bot only gives URLs for CORE modules <10> my @chunks; { local $/ = \$size; open my $fh, "<", \$str; @chunks = <$fh>; } <10> (overkill, but who cares?) <9> japhy, $str is the name of a file in that example? <9> i've never seen the 3rd arg in an open be a scalar ref <9> what does that do?.. I don't see it mentioned in open's perldoc <2> Since v5.8.0, perl has built using PerlIO by default. Unless you've changed this (i.e. Configure -Uuseperlio), you can open file handles to "in memory" files held in Perl scalars via: <2> open($fh, '>', \$variable) <1> Package::Alias doesn't even p*** perl -cw <9> so the descriptor points to memory files (the contents of $variable) ? <9> descriptor/handle <11> perl -le '$str="abcdefghijk";@c=do{local$/=\2;open my$f,"<",\$str;<$f>};print for @c' <9> interesting <9> always somethin to learn <12> Can I do /(^|_)size$/ to match strings ending with _size or that equal size? <11> what happened when you tried it? <13> eval: [ map { /(^|_)size$ ? "match" : "no match" } "foo_size", "size" ] <8> revdiablo: Error: Search pattern not terminated at (eval 126) line 1. <13> eval: [ map { /(^|_)size$/ ? "match" : "no match" } "foo_size", "size" ] <8> revdiablo: Return: ['match','match'] <12> heh .. thanks <13> eval: [ map { /(^|_)size$/ ? "match" : "no match" } "foo_size", "size", "foo size" ]
<8> revdiablo: Return: ['match','match','no match'] <12> eval: [ map { /_b|(^|_)size$/ ? "match" : "no match" } "foo_size", "size", "foo size", "foo_b" ] <8> Woosta: Return: ['match','match','no match','match'] <12> lurvely <14> hey <14> how do I make Xwindows <14> go from 800 to 1024 <14> on debian <13> happy000: You realize you're in #perl? <13> I guess he didn't! <12> ^^ and that \n isn't a punctuation character <12> heh yeah <11> hehehe <15> revdiablo: Nice. <10> mmap_: mine reads $size-sized chunks from $str, but does so using filehandles <16> is there a function in perl similar to mirc's /timer? so that i can make it pause before doing something but without stopping the whole program with sleep() <17> err <16> i want to set it up to do something in a certain number of seconds <17> Eaglewolf: you'd need to use Event or some similair module <16> but i also want it to keep doing its other functions <16> in the meantime <18> Your question makes my brain remotely incinerate small critters. <16> :< <16> what module would you suggest? <17> Eaglewolf: your idea of programming might be flawed <16> or actually <17> what are you trying to do ? <2> for simple things you can use alarm <16> well <16> what im doing is <17> mauke: true <16> its for an irc bot im writing, (not using the bot module, for my own reasons), and i'd like to make it have a function to reconnect every n seconds, but whenever it recieves a ping, to delay the reconnect again <16> so that it doesnt ping out <16> thats a siggestion i saw before <17> Eaglewolf: don't write YAIB <18> "the bot module"? <16> or anything else to make it reconnect after it pings <17> It is stupid <16> Bot::Basicbot <17> Eaglewolf: use the POE IRC Client <17> it should meet all your needs <16> i'm using IO::Socket <16> well <2> Eaglewolf: what's wrong with Bot::BasicBot? <16> the reason im just using IO::Socket is so that i can learn how to do the stuff on my own <18> We've all made socket bots at one time or another, but we don't continue when we're aware of a better way. <11> Eaglewolf: use IO::Select to time out reads... <16> its my first big script in perl and i wanted something to keep me interested, which is why i wanted to do a bot <17> Eaglewolf: it is not a good idea <2> good, now reinvent POE <16> sigh <17> mauke: Event :P <2> or that <16> Well thanks for the help in any case <17> mauke: actually I use POE most of the time, but for something that just needs to do dumb sockets I prefer Event <17> Eaglewolf: seriously, don't reinvent the wheel in a really clumsy way <16> thats true i guess <19> POE has a dumb sockets API as well. All the bells and whistles are built atop it. <17> you are trying to make a wheel by blowing up rocks and hoping one is round <19> Well, s/sockets/filehandles/ <16> I suppose you're right <17> dngor: yes, but Event is simpler to quickly hack up :) <17> dngor: just my experience <20> Ikarus: that can work, ***uming you have a good understanding of explosives and rocks :) <19> Hair, on the other hand, can be quite difficult to hack up. :) <17> Khisanth: true <18> Cats are good at that, I hear. <17> Khisanth: but in that case you can prolly rewrite POE <17> bleah, I shouldn't be in this channel right now, I was trying to forget I have coding to do <21> ... <21> oh good a channel that i can speak in <21> ##linux was getting spamed the crap out of and then ops set it +m but didn't give me (or anyone else) voice <18> Lean on our shoulder, friend; just as soon as I get the mannquin set up. <22> because ##linux is full of idiots
Return to
#perl or Go to some related
logs:
aphunter deb grub chroot exec format error #fedora #linux #perl release_firmware unknown symbol 2.6.15 gentoo 855resolution slack #ubuntu #gaim necronomicron pdf
|
|