Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

RazorbladeBidet's scratchpad

by RazorbladeBidet (Friar)
on Mar 07, 2005 at 20:25 UTC ( #437304=scratchpad: print w/ replies, xml ) Need Help??

Scope Question: File1:
package A; my $var = 1; sub mysub { print $var; } B::yoursub( \&mysub ); 1;
File2:
package B; sub yoursub { shift->(); }
1;
Infinite Loop:
#!/usr/bin/perl -w use strict; my $pid; my $output; defined( $pid = fork ) or die "Unable to fork!\n$!\n"; if ( $pid ) { print "Hi! I'm a parent! This is my child $pid\n"; while ( ( $output = kill( 0, $pid ) ) > 0 ) { print "I'm going to wait for my child to die...\n"; print $output, "\n"; sleep 2; } } else { print "I'm a kid! My name is $$\n"; print "I'm going to die now\n"; }

Terminated loop:
#!/usr/bin/perl -w use strict; my $pid; my $output; defined( $pid = fork ) or die "Unable to fork!\n$!\n"; $SIG{CHLD} = 'IGNORE'; # this is the only difference if ( $pid ) { print "Hi! I'm a parent! This is my child $pid\n"; while ( ( $output = kill( 0, $pid ) ) > 0 ) { print "I'm going to wait for my child to die...\n"; print $output, "\n"; sleep 2; } } else { print "I'm a kid! My name is $$\n"; print "I'm going to die now\n"; }

For hacker:

#!/usr/bin/perl -w use strict; my $input = qq( <style> My style is here </style> After first style <style file="while.css" /> After second style ); print $input, "\n-------------\n"; $input =~ s!<(s(?:cript|tyle))[^>]*>(?:.*?</\1>)?!!gis; print $input, "\n"; __END__ # output # <style> My style is here </style> After first style <style file="while.css" /> After second style ------------- After first style After second style

For stu96art:

Updated print loop

print "56565656565656565656565656565656565656565656\n"; $i = 0; foreach $point ( @$block ) { print "block $i\n"; $j = 0; foreach $vertex ( @$point ) { print"vertex $j\n"; $k = 0; foreach $vertexItem ( @$vertex ) { print '['.$i.']['.$j.']['.$k.'] =>', $vertexItem, "\n"; $k++; } print ''; $j++; } $i++; } print "56565656565656565656565656565656565656565656\n";


Prev. code

#!/usr/bin/perl -w use strict; use Data::Dumper; my ( @block, @datapoint ); $block[0][0][0] = 1; $block[0][0][1] = 367.642121; $block[0][0][2] = 1396.068976; $block[0][0][3] = 0; $block[0][0][4] = 88888; $block[0][0][5] = 99999; $block[0][0][6] = 99999; $block[0][0][7] = 0; $block[0][1][0] = 1; $block[0][1][1] = 958.697518; $block[0][1][2] = 1394.778302; $block[0][1][3] = 0; $block[0][1][4] = 88888; $block[0][1][5] = 99999; $block[0][1][6] = 99999; $block[0][1][7] = 0; #DATAPOINT $datapoint[0][0] = 1; $datapoint[0][1] = 725.166956; $datapoint[0][2] = 1315.976847; $datapoint[0][3] = 0; $datapoint[0][4] = 99999; $datapoint[1][0] = 2; $datapoint[1][1] = 706.139399; $datapoint[1][2] = 1240.897744; $datapoint[1][3] = 0; $datapoint[1][4] = 777; my ($blocka, $datapointa) = FINDPOINTSONVERTEX(\@block, \@datapoint); sub FINDPOINTSONVERTEX { my ($blocks, $datapoint) = @_; my $i10 = 0; my $oo = 0; my $jj; P: for my $kk (0..$#$datapoint) { print "KK: $kk\n"; BB: for $jj (0..$#{@{$blocks->[$datapoint->[$kk]->[3]]}}) { print "JJ: $jj\n"; if ($datapoint->[$kk]->[1] == $blocks->[$datapoint->[$kk]->[3 +]]->[$jj]->[1] ) { $datapoint->[$kk]->[4] = $jj; $blocks->[$datapoint->[$kk]->[3]]->[$jj]->[5] = 11112; $oo = $oo + 1; $datapoint->[$kk]->[4] = 777; next P; } } } return($blocks, $datapoint); } print Dumper( $blocka, $datapointa ); # # Output # # #$VAR1 = [ # [ # [ # 1, # '367.642121', # '1396.068976', # 0, # 88888, # 99999, # 99999, # 0 # ], # [ # 1, # '958.697518', # '1394.778302', # 0, # 88888, # 99999, # 99999, # 0 # ] # ] # ]; #$VAR2 = [ # [ # 1, # '725.166956', # '1315.976847', # 0, # 99999 # ], # [ # 2, # '706.139399', # '1240.897744', # 0, # 777 # ]
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2014-07-24 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (158 votes), past polls