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

Erik Mathis erik at mathists.com
Mon Oct 17 15:05:53 EDT 2011


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
>



More information about the Ale mailing list