Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Perl File convertor??

Status
Not open for further replies.

davyzhu

Advanced Member level 1
Advanced Member level 1
Joined
May 23, 2004
Messages
494
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,298
Location
oriental
Activity points
4,436
Hi all,

I am new to Perl (I used to be a C/C++ user). And I want to write a file convertor in Perl to learn it. And I use ActivePerl.

// Input.txt context
s 1 2
a 4 5
a 9 8

// Output.txt context I want
Sub (wire1, wire2);
Add (wire4, wire5);
Add (wire9, wire8);

BTW, how to debug perl script in ActivePerl? can I set breakpoint in it?

Any suggestions will be appreciated!
Best regards,
Davy
 

if i'm not wrong activeperl only provides the interpreter on Windows. the command-based interpreter does not support debugging (e.g. breakpoint etc.)

you may have to google for "Perl IDE". some are commercial, some are free.

one example: **broken link removed**
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
Here is one script in perl which I wrote now and tested... it's working properly.. the input is t.txt file. The o/p will be o.txt.




#/usr/local/bin/perl -w

open(T,"<./t.txt") or die ("Could not open input file"); # input file is t.txt
open(O,">./o.txt"); # The output file is o.txt

foreach $line (<T>)
{
$line =~ s/^\s+//;
if($line)
{
($m,$n,$o) = split(' ',$line);
if($m eq "s")
{$m1=Sub;}
else
{$m1=Add;}
print O "$m1 \(wire$n, wire$o\)\;\n";
}
}

close(T);
close(O);
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top