Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: adding an element in existing file..

by TedPride (Priest)
on Jun 04, 2006 at 21:17 UTC ( [id://553507]=note: print w/replies, xml ) Need Help??


in reply to adding an element in existing file..

use strict; use warnings; my ($user, $third, @data); $user = 'Thomas'; $third = 'newvalue'; chomp(@data = <DATA>); for (@data) { # Skip if user is not $user next if !m/^\Q$user\E\s*:/; # Change third field and exit loop @_ = split /:/, $_; $_[2] = $third; $_ = join ':', @_; last; } # Print data back to file (replace this) print $_, "\n" for @data; __DATA__ Username : Password : Download | Tom : 12345678 : Thomas : 12345678 : 121312313123131313

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://553507]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-23 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found