@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3



Comments:

<0> Any perl users able to ***ist me
<1> mayhaps
<2> There are no mind readers in here...
<1> i knew you were going to say that
<3> you'll never know if you don't ask your question.
<4> hi. if some script.pl exits with "exit 2;", how could i get that exit code. stdout is clear :/
<5> in bash?
<5> $?
<4> i try to run perl script, which runs another script and checks his exit code. i run perl script with `command` and try to get a code
<4> what free perl editor with nice gui for win2k would you recomend ?
<6> VIm
<6> gVIm then.
<6> though you're many times faster if you know the keys and shortcuts for VIm
<4> and i dont :/
<6> you'll get used to it...



<6> and you can do it the click click click way =)
<4> well i tried optiperl for a trial period (40 hours :( )
<6> I don't know optiperl...
<6> but why a trial period ?
<4> because it isnt free
<7> anyone willing to help?
<6> and ActiveState ?
<7> =)
<8> Help what?
<7> I need uniq, for perl and perldoc perlfaq4 didn't help me.
<8> What's a "uniq"?
<7> sorry, unix binary uniq.
<5> my(@uniq, %exists); push @uniq, grep {!$exists{$_}++} @somearray
<7> go through a list and only display uniq text.
<5> oh
<8> unique, I see
<7> Yeah, I think I scrood myself cause I didn't use a hash to begin with.
<5> grep {!$exists{$_}++} @somearray
<5> that will pull unique items outta a list, yea
<7> I have a multi dimension array, $foo[$cnt][1] has an ip address in it, I want to find all uniq ips in @foo.
<5> my(@uniq, %exists); push @uniq, grep {!$exists{$_}++} @$_ foreach(@foo)
<5> then @uniq
<5> for lists of lists
<5> but..
<5> yea
<5> thts not gonna traverse every corner of every demension
<7> I know, I just haven't upgraded myself to use hashs ...
<5> could take a similar approach for sublists of each
<7> Thats what I thought, I will have to keep count around to know where it came from, righ?
<5> run that through yet another loop
<5> thats precisely what that I gave you does..
<7> k, will give a go. Thanks
<7> might be back if i can't understand it.
<5> heh
<5> k
<7> im back
<7> so in my case would the foreach(@foo) be foreach(@foo[$cnt]), which doesn't make sence...i'm missing something.
<5> well
<5> umm
<5> list of list?
<5> s
<5> in that case, the case of *lists of lists*
<5> @$_ foreach(@foo)
<5> is sufficent
<5> for the structure you gave as an example
<5> that line should do exactly what you want, as I wrote it
<7> k
<7> let me check
<7> while I check
<7> heres the basic of the data struc
<7> http://pastebin.ca/44092
<5> hm
<5> well
<7> oh kewl.
<5> thats not cleaning the lists in place
<5> but building a new one
<5> get it?
<7> Sort of.
<5> sort of?
<7> K, my expl tell me if I'm wrong.
<5> expl?



<7> Create Array and Hash, from the grep exists (which gets from @DNSDB???) push onto uniq
<7> explanation.
<5> ah yes
<5> sounds about right
<7> do how does it now what field from @DNSDB to compare and do the uniq to?
<5> well
<5> ok..
<5> lists of lists.. ([bleh blah bleh], [dadada lalala yay])
<7> k
<5> so say.. my @lists = ([bleh blah bleh], [dadada lalala yay]);
<7> k
<5> foreach(@lists) { here you have each *list* it encounters in @lists }
<5> grep {!$exists{$_}++} .. is essientially a count..
<5> so, the first tiem it encounters something, $exists{THIS} is gonna be a null value, adn therefore p*** the check (as its negated with !)
<5> but, the second time, will already be 1, as its already encountered this key once
<5> so, the grep just does that..
<5> goes over each sublist one by one, counting them mostly
<7> ok, soo
<7> I'm comparing bleh to dadada?
<5> soo
<5> umm, comaring it to each element of each sublist
<7> ok whats the first and second compare in the example list you gave?
<5> the grep
<5> grep is a loop in itself
<5> grep will traverse the list
<7> ok perldoc grep
<7> im a sysadm, I think of grep from the cmd line first
<5> is simply incrementing $exists{bleh}, $exists{blah} etc. each time its encountered
<5> as its negated, it'll only p*** the first tiem
<5> yea, is uh
<5> a similar concept..
<5> is a filter
<5> filters the list per {EXPR}
<7> ok, the loop through me for a loop =)
<5> heh
<5> I can see how code like that can be a bit difficult to follow at a glance
<7> ok, the only thing I don't want to happen is $foo[$cnt][2] $foo[$cnt+1][2] to be compared.
<5> is pretty easy to make perl of all languages, very difficult to read
<5> ooh
<7> right, perl is the write once language.
<5> you want each list filtered alone?
<7> I only want the first element in the list of the list compared, its and IP address, the second is a MAC address. I'm only trying to find uniq IPs right now.
<5> could sub filter(\@) {} and edit them in place even..
<5> oh
<5> shoulda said that eh
<5> same appraoch works though
<7> but how can I limit it?
<5> my(@uniq, %exists); push @uniq, grep {!$exists{$_}++} @{$foo[1]}
<5> grep {!$exists{$_}++} @{$foo[1]}
<7> K, thats what I was trying but It failed for me, thats why I asked more questions.
<7> let me try again.
<5> just that itself, will return a list of the unique items it contains
<5> my @uniq = grep {!$exists{$_}++} @{$foo[1]};
<7> What does the @ in front of {$foo[1]) do?
<5> local $\ = "\n"; print foreach( grep {!$exists{$_}++} @{$foo[1]});
<5> dereferencing operator..
<7> k
<7> not having much luck with the new one.
<7> so if I do print @uniq, can I add my seperator back in easly?
<5> well
<5> hats went wrong?
<5> whats*
<7> Here all the code
<7> http://pastebin.ca/44094
<5> oh
<7> Yeah.
<5> grep {!$exists{$_}++} @{$foo[$cnt][1]}
<5> or uh
<5> for a ingle item
<5> grep {!$exists{$_}} @{$_[1]} foreach(@DNSDB);
<5> grep {!$exists{$_}} @{$_->[1]} foreach(@DNSDB);
<5> rather
<5> my(@DNSDB, %exists); push @DNSDB, [ '', split ',', $line ] while(chomp($line = <DHCP>)); local $\ = "\n"; print join ', ', grep {!$exists{$_}} @{$_[1]} foreach(@DNSDB);
<5> my(@DNSDB, %exists); push @DNSDB, [ '', split ',', $line ] while(chomp($line = <DHCP>)); local $\ = "\n"; print join ', ', grep {!$exists{$_}} @{$_->[1]} foreach(@DNSDB);


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #perl
or
Go to some related logs:

singapore walk in interview
#allnitecafe
#chat-world
#chat-world
RTFMs digit
#php
#chat-world
#allnitecafe
call php page from java applet
#india



Home  |  disclaimer  |  contact  |  submit quotes