Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: perl script for adding information to c file.

by Utilitarian (Vicar)
on Oct 10, 2011 at 09:06 UTC ( #930561=note: print w/replies, xml ) Need Help??


in reply to perl script for adding information to c file.

#!/usr/bin/perl use warnings; use strict; open (my $code , "<", 'ccode.c')||die "Could not open ccode.c\n\t$!"; my %data = ('24'=>"temperature", '25'=>"pressure", '26'=>"humidity", ); my %nums = ('24'=>"information1: ", '25'=>"information2: ", '26'=>"information3: ", ); %data = reverse %data; my $test_string="(" .join("|", keys %data).")" ; while(<$code>){ if (/$test_string/){ $_=$nums{$data{$1}}.$_; } print $_ }
I could have sworn I saw this over on unix.com last week....?
Anyway, I hope this resolves your question.
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2016-12-10 06:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (160 votes). Check out past polls.