473,624 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

write while( length $name );

I found this code in /usr/bin/dprofpp. I am getting garbled output from
dprofpp so I thought I'd try to debug it. The code in the subject
line has me baffled. Some dprofpp code excerpts:

...
$~ = 'STAT';
...
format STAT =
^>>> ^>>>> ^>>>>> ^>>>>> ^>>>>> ^>>>>>
^<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<
$pcnt, $secs, $csecs, $ncalls, $percall, $cpercall, $name
Jul 19 '05 #1
1 1657
Harry DeLano wrote:
I found this code in /usr/bin/dprofpp. I am getting garbled output from
dprofpp so I thought I'd try to debug it. The code in the subject line
has me baffled. Some dprofpp code excerpts:

...
$~ = 'STAT';
...
format STAT =
^>>> ^>>>> ^>>>>> ^>>>>> ^>>>>> ^>>>>>
^<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<
$pcnt, $secs, $csecs, $ncalls, $percall, $cpercall, $name
.

So how does this code not loop forever?


The answer is in "perldoc perlform".

Perl puts as much text as it
can into the field, and then chops off the front of the string so that
the next time the variable is referenced, more of the text can be
printed. (Yes, this means that the variable itself is altered during
execution of the write() call, and is not returned.)

You might be interested in the message I posted to comp.lang.perl. misc
4/18/2004 1:33am (Message-ID: nntp:f3rgc.8641 $hw5.7761@attbi _s53).

unix> cat temp
my $FO_UN = " @<<<<<<<<<<<<< | ^<<<<<<<<<<<<<< <<<<<<<<<<<";

$name = 'John Doe';
$note = '123456789 abcdefghi ABCDEFGHI jklmnopqr JKLMNOPQR stu';
$psec .= swrite(<<"END", $name, $note);
$FO_UN
END

print qq/$psec\n/;
#---------------------------------------------------------------------------
sub swrite {
my($format,$arg 1,$arg2) = @_;
$^A = "";
print "before: arg2='$arg2'\n" ;
formline($forma t, $arg1, $arg2);
print "after: arg2='$arg2'\n" ;
substr($format, 1,14) = ' ' x 14; # Done with "@<<<<<<<<<<<<< " part
formline($forma t, $arg2) while $arg2 ne ""; # Do multi-line
return $^A;
}
unix> perl temp
before: arg2='123456789 abcdefghi ABCDEFGHI jklmnopqr JKLMNOPQR stu'
after: arg2='ABCDEFGHI jklmnopqr JKLMNOPQR stu'
John Doe | 123456789 abcdefghi
| ABCDEFGHI jklmnopqr
| JKLMNOPQR stu

unix>

-Joe

P.S. Please post to comp.lang.perl. misc next time, not comp.lang.perl
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3087
by: divya | last post by:
Hi, I have a table tblbwday with 2 fields Name and Birthday.I have written this script for displaying evryday names of the people on that day. <% set objConn =server.createobject("ADODB.connection") objConn.open "DSN=Photo" Dim sqlSELsite,ObjRSSel sqlSELsite = "SELECT Name FROM tblbwday WHERE B'day ="& date() &" " '
22
4016
by: semedao | last post by:
Hi , I am using asyc sockets p2p connection between 2 clients. when I debug step by step the both sides , i'ts work ok. when I run it , in somepoint (same location in the code) when I want to receive 5 bytes buffer , I call the BeginReceive and then wait on AsyncWaitHandle.WaitOne() but it is signald imidiatly , and the next call to EndReceive return zero bytes length , also the buffer is empty. here is the code: public static byte...
7
4823
by: abrad0189 | last post by:
Anybody able to help me? I can't get out of a while loop! It works, it just will not stop! public class getNames { public static void main( String args ) { String message = "Employee's Name Is" ; //set String Name String aPrompt = "Enter Employee's Name:"; String tmp = ""; String name = JOptionPane.showInputDialog( aPrompt );
5
2935
by: Stefantastisk | last post by:
Hey there, Anyone knows a clever method for knowing the length of the digit after a decimal point in a standard C# decimal value, WITHOUT use of any string formatting. Example: 5231,12231 <- Lengt = 5 Tnx for your attention hope you are capable of helping.
4
5729
Dim
by: elia | last post by:
Hello , I''ve got a problem with "dim". I want to receive a variable send from a formular with method GET Why it doesn't work?? <body> <% dim name dim vorname ....
2
27552
by: jolly | last post by:
hey guys, When i try to run my code I get an error. NameError name 'main is not defined' if __name__ == "__main__": main() filename = "addbook.dat"
2
23744
by: pythonnewb | last post by:
I am fairly new to programming but have some very basic Java background. I am just learning python and tried to make a module that would allow me to create a file containing an address book. I was planning to then create a program to detect input and use this module, but I am hung up. I have constructed the code that I thought would work (though there may be a better way) and I got this error message. Traceback (most recent call last): File...
1
2497
by: gaurav92K | last post by:
sir, how can we write our name in place of time which is situated in notification area. sir it is possible because i saw it a pc. but i don't know how can we write name in place of date & time .
2
3526
by: cmb3587 | last post by:
My task is to take a user input that ranges from 1-50 and use it to create a triangle of asterisks. I.E: Enter number: 5 * ** *** **** ***** ****
0
8238
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7164
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2607
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.