Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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."


Comment on Re: perl script for adding information to c file.
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2014-09-19 17:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (143 votes), past polls