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.

adjusting characters in a field

Status
Not open for further replies.

ranjeeth

Newbie level 6
Newbie level 6
Joined
Aug 3, 2005
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Mumbai,India
Activity points
1,469
C uses "%6.2f" etc to align numbers properly ? Can it be done with characters in PERL i.e adjusting a group of characters within a field so as to have proper alignment for eg I wish to adjust and align an array of characters into a field of say 10.
 

You may use printf in perl as in C.
 

    ranjeeth

    Points: 2
    Helpful Answer Positive Rating
Hi ,
i think i need to frame my question properly , i wish to align characters and not numbers.
for eg given strings Jane Joe Mary etc i wish to store these strings as strings of 10 characters ,the trailing characters being spaces. is there a standard perl function for doing this.
 

Replace the format character f to s: "%-10s"
 

    ranjeeth

    Points: 2
    Helpful Answer Positive Rating
Perl's sprintf() does string formatting too.
**broken link removed**

Sound like you want "%-10.10s" or "%-10s". The first one truncates to 10 characters.
 

    ranjeeth

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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top