Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

(dooberwah) Re: how can i modify the array ?

by dooberwah (Pilgrim)
on Jun 05, 2002 at 13:37 UTC ( #171824=note: print w/replies, xml ) Need Help??


in reply to how can i modify the array ?

Greetings

First of all, You really should use CGI.pm, strict, and warnings. With that said: you can easily modify $sign_msg and then join all the variables back one string.

($number, $sign_name, $sign_email, $sign_homepage, $sign_icon, $sign_t +ime, $sign_msg ) = split ( /__/, $line ) ; $sign_msg = "Hello, World!\n"; # Do your modification here $newline = join ( /__/, ($number, $sign_name, $sign_email, $sign_homep +age, $sign_icon, $sign_time, $sign_msg ); push @newarray, $newline;

-Ben Jacobs (dooberwah)
http://dooberwah.perlmonk.org
"one thing i can tell you is you got to be free"

Replies are listed 'Best First'.
Re: (dooberwah) Re: how can i modify the array ?
by Anonymous Monk on Jun 05, 2002 at 20:12 UTC
    thx for reply
    use join can modify the sign_msg
    but how to write it back in the middle of the array?

    4__taka__email__url__icon__time__message
    3__12monkey__email__url__icon__time__message
    2__sarah__email__url__icon__time__message
    1__john__email__url__icon__time__message
    (after i modify third message , how to write into the orginal place ?)
Re: (dooberwah) Re: how can i modify the array ?
by 12monkey (Initiate) on Jun 05, 2002 at 20:21 UTC
    if ( $admin eq $pw ) { foreach $line(@lines) { ( $num,$sign_name,$sign_email,$sign_homepage,$sign_icon,$sign_time,$si +gn_msg ) = split ( /__/, $line ) ; if ( $modnum < $num ) { push @largedata , $line ; } elsif ( $modnum eq $num ) { $sign_msg="$adminmsg"; $new = join ('__',( $modnum , $sign_name , $sign_email , $sign_hom +epage , $sign_icon , $sign_time , $sign_msg)); push @modifydata , $new; } elsif ( $modnum > $num) { push @lessdata , $line ; } } open(WRITE,">guestbook.dat"); print WRITE @largedata; print WRITE @modifydata; print WRITE "\n"; print WRITE @lessdata; close(WRITE);
    yeah , i have done it
    anything need to improve?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://171824]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2018-05-28 02:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?