Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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

by dooberwah (Pilgrim)
on Jun 05, 2002 at 13:37 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://171824]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-20 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found