[ale] Perl or Python for editing files...

Chuck Payne terrorpup at gmail.com
Mon Oct 17 15:26:44 EDT 2011


On Mon, Oct 17, 2011 at 3:05 PM, Erik Mathis <erik at mathists.com> wrote:
> In Perl you write to files with filehandels. In the example below its called OUT
>
> my $file="/tmp/file";
> open (OUT, ">$file") or die "Cant write to $file\n";
> print OUT "A line of text\n";
> print OUT "Another line of text\n";
> close OUT;
>
> Notice the ">", it writes a new file each time open() is called. Use
> ">>" if you want to append.
>
>
> hth!
> -Erik-
>
>
> On Mon, Oct 17, 2011 at 1:01 PM, Chuck Payne <terrorpup at gmail.com> wrote:
>> Guys,
>>
>> I have four files I like to be able to edit from a script. I have
>> heard that it's better to use Perl or Python to this than bash.
>>
>> I am new to be perl and python from a scripting. What would be easy? I
>> know it question that would open up a larger debate, but I really need
>> help on this.
>>
>> If you recommend one of the two can you show me a site that explain
>> how to open and write the files.
>>
>>
>> Thanks,
>>
>> --
>> (678) 636-9678
>> -----------------------------------------
>> Discover it! Enjoy it! Share it! openSUSE Linux.
>> -----------------------------------------
>> openSUSE -- en.opensuse.org/User:Terrorpup
>> openSUSE Ambassador/openSUSE Member
>> skype,twiiter,identica,friendfeed -- terrorpup
>> freenode(irc) --terrorpup/lupinstein
>> Register Linux Userid: 155363
>>
>> Have you tried SUSE Studio? Need to create a Live CD,  an app you want
>> to package and distribute , or create your own linux distro. Give SUSE
>> Studio a try. www.susestudio.com.
>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>> See JOBS, ANNOUNCE and SCHOOLS lists at
>> http://mail.ale.org/mailman/listinfo
>>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>

Erik,

Thanks, what I am looking for something like this

/usr/bin/perl -p -i -e "s/$1/$2/g" $3

but make into a scipt, I cam crawling the web currently for examples.

Chuck

-- 
(678) 636-9678
-----------------------------------------
Discover it! Enjoy it! Share it! openSUSE Linux.
-----------------------------------------
openSUSE -- en.opensuse.org/User:Terrorpup
openSUSE Ambassador/openSUSE Member
skype,twiiter,identica,friendfeed -- terrorpup
freenode(irc) --terrorpup/lupinstein
Register Linux Userid: 155363

Have you tried SUSE Studio? Need to create a Live CD,  an app you want
to package and distribute , or create your own linux distro. Give SUSE
Studio a try. www.susestudio.com.



More information about the Ale mailing list