what's wrong here.. - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

what's wrong here..

jgrjgr Posts: 12Member
Hi, what's wrong with this code ?



while (1) {

while () {

if (/jgr/) {

@data= split (/ /, $_);

$data[3]=~ s/^://g;
$data[3]=~ s/=//g;

print ($data[3]--), "
";

# I do ($data[3]--), beacuse $data[3] is with '
' .
# And in data[3] is now '!help'

open (CONF, "mowa.conf") or die "Missing mowa.conf !!!
";

# In mowa.conf is:
# !help:bleble
# !ble:hehe

@datafile= ;

foreach $num (0 .. scalar (@datafile)) {

@compare = split (/:/, $datafile[$num]);

# $compare[0] now is !help or !ble

if (($compare[0] cmp ($data[3]--)) == 0) {
print "YEAH !";
}
# This compare is not work, I mean at stdout it's show nothing, why is
# that ? :))
}
}
}
}

At last, sorry for my english :)

Comments

  • JonathanJonathan Posts: 2,914Member
    : Hi, what's wrong with this code ?
    :
    OK, I'm tired, have been at a party, and my brain isn't really working. But anyhow...

    : while (1) {
    :
    : while () {
    :
    : if (/jgr/) {
    :
    : @data= split (/ /, $_);
    :
    : $data[3]=~ s/^://g;
    : $data[3]=~ s/=//g;
    :
    : print ($data[3]--), "
    ";
    :
    : # I do ($data[3]--), beacuse $data[3] is with '
    ' .
    : # And in data[3] is now '!help'
    :
    : open (CONF, "mowa.conf") or die "Missing mowa.conf !!!
    ";
    :
    : # In mowa.conf is:
    : # !help:bleble
    : # !ble:hehe
    :
    : @datafile= ;
    :
    : foreach $num (0 .. scalar (@datafile)) {
    :
    : @compare = split (/:/, $datafile[$num]);
    :
    : # $compare[0] now is !help or !ble
    :
    : if (($compare[0] cmp ($data[3]--)) == 0) {
    : print "YEAH !";
    : }
    : # This compare is not work, I mean at stdout it's show nothing, why is
    : # that ? :))
    : }
    : }
    : }
    : }
    :
    : At last, sorry for my english :)
    :
    I'm pretty sure your $data[3]-- is the problem. If you want to remove the
    , you should use:-

    chomp $data[3];
    print $data[3];

    Also note you actually end up executing $data[3]-- twice, which I expect is not what you want it to do. So, get rid of the --'s and do chomp $data[3];
    Before the print statement.

    Hope this helps,

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • jgrjgr Posts: 12Member
    : I'm pretty sure your $data[3]-- is the problem. If you want to remove the
    , you should use:-
    :
    : chomp $data[3];
    : print $data[3];
    :

    Hmm, when I use chomp $data[3], and I do print $data[3]; then print "show" nothing.. :/

    : Also note you actually end up executing $data[3]-- twice, which I expect is not what you want it to do. So, get rid of the --'s and do chomp $data[3];

    I use ($data[3]--) beacuse, I use many combination with this.. beacuse
    I don't have ideas, why this code not work correctly..
    In that code, I do lentgh ($data[3]), and length ($compare[0]), and He show is len $data[3] = 7, and len $compare[0] = 5, but
    $data[3] = !help so 7 also with '
    ', not 6 ? ee ? why ?
    $compare[0] = !help <- 5

    So any other ideas ? :))

  • JonathanJonathan Posts: 2,914Member
    : : I'm pretty sure your $data[3]-- is the problem. If you want to remove the
    , you should use:-
    : :
    : : chomp $data[3];
    : : print $data[3];
    : :
    :
    : Hmm, when I use chomp $data[3], and I do print $data[3]; then print "show" nothing.. :/
    :
    : : Also note you actually end up executing $data[3]-- twice, which I expect is not what you want it to do. So, get rid of the --'s and do chomp $data[3];
    :
    : I use ($data[3]--) beacuse, I use many combination with this.. beacuse
    : I don't have ideas, why this code not work correctly..
    Yes, but -- is for decrementing numbers.

    $a = 3;
    $a--;
    print $a; # Prints 2

    You seem to want to remove characters from a string using it. No, that's not what it's for. Your code won't work if that's what you're trying to do.

    : In that code, I do lentgh ($data[3]), and length ($compare[0]), and He show is len $data[3] = 7, and len $compare[0] = 5, but
    : $data[3] = !help so 7 also with '
    ', not 6 ? ee ? why ?
    : $compare[0] = !help <- 5
    :
    I would guess it is 7 because some platforms have
    and
    , e.g. two end of line characters. You may need to use chomp twice, or altenatively do:-

    $data[3] =~ s/
    |
    //g;

    But two chomps are more efficient. Either are better than --, which is just...well...wrong. :-)

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • jgrjgr Posts: 12Member
    : I would guess it is 7 because some platforms have
    and
    , e.g. two end of line characters. You may need to use chomp twice, or altenatively do:-

    Yes, you have right. :)

    : $data[3] =~ s/
    |
    //g;
    :
    : But two chomps are more efficient. Either are better than --, which is just...well...wrong. :-)

    ok, I do that what i want. Here code:

    while (1) {
    while () {

    if (/jgr/) {

    open (CONF, "mowa.conf") or die "Missing mowa.conf !!!
    ";

    @plik = ;

    foreach $num (0 .. scalar @plik) {

    @porownaj = split (/:/, $plik[$num]);
    @data= split (/ /, $_);

    $data[3] =~ s/^:|
    |
    |=//g;

    if (($porownaj[0] cmp $data[3]) == 0) {

    print "YEAH !!!
    ";

    }

    }
    }
    }
    }

    close FILE;

    Thanks Jonathan for help, you help me second time ;) thanks doode ;)

    jgr

  • JonathanJonathan Posts: 2,914Member
    : : I would guess it is 7 because some platforms have
    and
    , e.g. two end of line characters. You may need to use chomp twice, or altenatively do:-
    :
    : Yes, you have right. :)
    :
    : : $data[3] =~ s/
    |
    //g;
    : :
    : : But two chomps are more efficient. Either are better than --, which is just...well...wrong. :-)
    :
    : ok, I do that what i want. Here code:
    :
    : while (1) {
    : while () {
    :
    : if (/jgr/) {
    :
    : open (CONF, "mowa.conf") or die "Missing mowa.conf !!!
    ";
    :
    : @plik = ;
    :
    : foreach $num (0 .. scalar @plik) {
    :
    : @porownaj = split (/:/, $plik[$num]);
    : @data= split (/ /, $_);
    :
    : $data[3] =~ s/^:|
    |
    |=//g;
    :
    : if (($porownaj[0] cmp $data[3]) == 0) {
    :
    : print "YEAH !!!
    ";
    :
    : }
    :
    : }
    : }
    : }
    : }
    :
    : close FILE;
    :
    : Thanks Jonathan for help, you help me second time ;) thanks doode ;)
    :
    You're welcome. Sorry for confusion, but just to check - it works now, right? :-)

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.