#perl - Wed 9 May 2007 between 07:11 and 07:31



rook2pawnthanks guys
talexbrindolf, Interesting article by Ovid.
http://use.perl.org/~nicholas/journal/33110 -- very interesting.
FuzzyBis it possible to take the output of a function parse it through a regex and assign it to a variable all in the same line?
BinGOsparse ?
FuzzyBsomething like my $name = unshift(@blocks); $name =~ s/\{//; in one line
BinGOsoh a substitution
integralwhy do you want to do something in one line?
(my $foo = func()) =~ s/// works for me anyway.
BinGOsmy ($name) = map { s/\{//; $_ } unshift @blocks; # perhaps ?
spx2FuzzyB, what does unshift(@blocks) do ?
FuzzyBbecause i would like to see efficency in my code
integralBinGOs: no.
BinGOsoh ignore me.
integralFuzzyB: Lines doesn't equate to efficiency.
spx2integral, what does that do (my $foo = func()) =~ s/// ?
BinGOsintegral++
integralspx2: It calls func() in scalar context, assigning its return to $foo, and then using the lvalue returned from the assignment which is $foo to bind to a substitution
savvashow would you make a perl one-liner equal to: sed -e 's/example/replaced/g' ?
rindolftalexb: yeah.
integralsavvas: perl -pe 's///g'
savvasmuch obliged :)
integralwhy not use s2p?
spx2integral, so the substitution replaces '/' with '' ?
integralspx2: Huh? The substitution replaces the empty pattern where it matches with the empty string.
It does nothing, it's an example, fill in your own pattern
spx2integral, i was stupid sorry
savvasintegral: can i make two substitutions in one line? like sed -e 's/one/moo/g' -e 's/two/moo2/g' ?
integralput them inside one '' with a ; in between, or just use s2p
savvasoh s2p was for me, yeah just started reading the manual, thanks
s2p or psed? same thing eh?
ion_bidonhello; %hash = @array is the correct way to convert array values into hash keys ?
hmm
FuzzyBmy counter = 0; foreach(@array) { $hash{$count} = $_; } maybe?
talexbion_bidon, How about %hash = map { $_ -> 1 } @array instead.
FuzzyBi don't know how to use map
rindolftalexb: map { $_ => 1 } @array
FuzzyB: it's not hard to learn.
ion_bidontalexb, rindolf: thanks
talexbrindolf, Sorry, my bad -- it's not 6am yet.

Page: 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 

IrcArchive