473,499 Members | 1,562 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 1652
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,$arg1,$arg2) = @_;
$^A = "";
print "before: arg2='$arg2'\n";
formline($format, $arg1, $arg2);
print "after: arg2='$arg2'\n";
substr($format,1,14) = ' ' x 14; # Done with "@<<<<<<<<<<<<<" part
formline($format, $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
3070
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...
22
3974
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...
7
4818
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...
5
2927
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 <-...
4
5723
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
27418
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
23731
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...
1
2490
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 &...
2
3512
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
7134
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,...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7392
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...
0
5479
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,...
1
4920
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...
0
3105
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...
0
1429
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 ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.