From: Ricardo SIGNES Date: Tue, 20 Jan 2009 23:32:17 +0000 (-0500) Subject: now get non-dual lived code X-Git-Tag: accepted/trunk/20130322.191538~12066 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b393bf410d9f1bf0b80132c4e8b5d6707a139f8;p=platform%2Fupstream%2Fperl.git now get non-dual lived code --- diff --git a/lib/Benchmark.pm b/lib/Benchmark.pm index 7e744a6..19a0343 100644 --- a/lib/Benchmark.pm +++ b/lib/Benchmark.pm @@ -81,9 +81,9 @@ countit - see how many times a chunk of code runs in a given time Returns the current time. Example: use Benchmark; - $t0 = new Benchmark; + $t0 = Benchmark->new; # ... your code here ... - $t1 = new Benchmark; + $t1 = Benchmark->new; $td = timediff($t1, $t0); print "the code took:",timestr($td),"\n"; @@ -91,9 +91,9 @@ Returns the current time. Example: Enables or disable debugging by setting the C<$Benchmark::Debug> flag: - debug Benchmark 1; + Benchmark->debug(1); $t = timeit(10, ' 5 ** $Global '); - debug Benchmark 0; + Benchmark->debug(0); =item iters diff --git a/lib/DirHandle.pm b/lib/DirHandle.pm index 0bddec2..757bf4b 100644 --- a/lib/DirHandle.pm +++ b/lib/DirHandle.pm @@ -9,7 +9,7 @@ DirHandle - supply object methods for directory handles =head1 SYNOPSIS use DirHandle; - $d = new DirHandle "."; + $d = DirHandle->new("."); if (defined $d) { while (defined($_ = $d->read)) { something($_); } $d->rewind; @@ -46,7 +46,7 @@ use Carp; use Symbol; sub new { - @_ >= 1 && @_ <= 2 or croak 'usage: new DirHandle [DIRNAME]'; + @_ >= 1 && @_ <= 2 or croak 'usage: DirHandle->new( [DIRNAME] )'; my $class = shift; my $dh = gensym; if (@_) { diff --git a/lib/Dumpvalue.pm b/lib/Dumpvalue.pm index f182297..d5d93c7 100644 --- a/lib/Dumpvalue.pm +++ b/lib/Dumpvalue.pm @@ -488,7 +488,7 @@ Dumpvalue - provides screen dump of Perl data. =head1 SYNOPSIS use Dumpvalue; - my $dumper = new Dumpvalue; + my $dumper = Dumpvalue->new; $dumper->set(globPrint => 1); $dumper->dumpValue(\*::); $dumper->dumpvars('main'); @@ -500,7 +500,7 @@ Dumpvalue - provides screen dump of Perl data. A new dumper is created by a call - $d = new Dumpvalue(option1 => value1, option2 => value2) + $d = Dumpvalue->new(option1 => value1, option2 => value2) Recognized options: diff --git a/lib/FileHandle.pm b/lib/FileHandle.pm index 6be2242..b609614 100644 --- a/lib/FileHandle.pm +++ b/lib/FileHandle.pm @@ -111,25 +111,25 @@ FileHandle - supply object methods for filehandles use FileHandle; - $fh = new FileHandle; + $fh = FileHandle->new; if ($fh->open("< file")) { print <$fh>; $fh->close; } - $fh = new FileHandle "> FOO"; + $fh = FileHandle->new("> FOO"); if (defined $fh) { print $fh "bar\n"; $fh->close; } - $fh = new FileHandle "file", "r"; + $fh = FileHandle->new("file", "r"); if (defined $fh) { print <$fh>; undef $fh; # automatically closes the file } - $fh = new FileHandle "file", O_WRONLY|O_APPEND; + $fh = FileHandle->new("file", O_WRONLY|O_APPEND); if (defined $fh) { print $fh "corge\n"; undef $fh; # automatically closes the file diff --git a/lib/I18N/Collate.pm b/lib/I18N/Collate.pm index 132b425..257390f 100644 --- a/lib/I18N/Collate.pm +++ b/lib/I18N/Collate.pm @@ -11,8 +11,8 @@ I18N::Collate - compare 8-bit scalar data according to the current locale use I18N::Collate; setlocale(LC_COLLATE, 'locale-of-your-choice'); - $s1 = new I18N::Collate "scalar_data_1"; - $s2 = new I18N::Collate "scalar_data_2"; + $s1 = I18N::Collate->new("scalar_data_1"); + $s2 = I18N::Collate->new("scalar_data_2"); =head1 DESCRIPTION @@ -81,8 +81,8 @@ European character set. # # Usage: use I18N::Collate; # setlocale(LC_COLLATE, 'locale-of-your-choice'); # 4) -# $s1 = new I18N::Collate "scalar_data_1"; -# $s2 = new I18N::Collate "scalar_data_2"; +# $s1 = I18N::Collate->("scalar_data_1"); +# $s2 = I18N::Collate->("scalar_data_2"); # # now you can compare $s1 and $s2: $s1 le $s2 # to extract the data itself, you need to deref: $$s1 diff --git a/lib/SelectSaver.pm b/lib/SelectSaver.pm index 1207b88..f0900a5 100644 --- a/lib/SelectSaver.pm +++ b/lib/SelectSaver.pm @@ -11,13 +11,13 @@ SelectSaver - save and restore selected file handle use SelectSaver; { - my $saver = new SelectSaver(FILEHANDLE); + my $saver = SelectSaver->new(FILEHANDLE); # FILEHANDLE is selected } # previous handle is selected { - my $saver = new SelectSaver; + my $saver = SelectSaver->new; # new handle may be selected, or not } # previous handle is selected @@ -39,7 +39,7 @@ use Carp; use Symbol; sub new { - @_ >= 1 && @_ <= 2 or croak 'usage: new SelectSaver [FILEHANDLE]'; + @_ >= 1 && @_ <= 2 or croak 'usage: SelectSaver->new( [FILEHANDLE] )'; my $fh = select; my $self = bless \$fh, $_[0]; select qualify($_[1], caller) if @_ > 1; diff --git a/lib/Term/ReadLine.pm b/lib/Term/ReadLine.pm index c1d1762..d251271 100644 --- a/lib/Term/ReadLine.pm +++ b/lib/Term/ReadLine.pm @@ -6,7 +6,7 @@ If no real package is found, substitutes stubs instead of basic functions. =head1 SYNOPSIS use Term::ReadLine; - my $term = new Term::ReadLine 'Simple Perl calc'; + my $term = Term::ReadLine->new('Simple Perl calc'); my $prompt = "Enter your arithmetic expression: "; my $OUT = $term->OUT || \*STDOUT; while ( defined ($_ = $term->readline($prompt)) ) { @@ -26,7 +26,7 @@ CPAN (under the C namespace). All the supported functions should be called as methods, i.e., either as - $term = new Term::ReadLine 'name'; + $term = Term::ReadLine->new('name'); or as diff --git a/lib/overload.pm b/lib/overload.pm index ba0202d..c5ac87a 100644 --- a/lib/overload.pm +++ b/lib/overload.pm @@ -194,7 +194,7 @@ overload - Package for overloading Perl operations ... package main; - $a = new SomeThing 57; + $a = SomeThing->new( 57 ); $b=5+$a; ... if (overload::Overloaded $b) {...} @@ -902,7 +902,7 @@ If some mutator methods are directly applied to the overloaded values, one may need to I other values which references the same value: - $a = new Data 23; + $a = Data->new(23); ... $b = $a; # $b is "linked" to $a ... @@ -911,13 +911,13 @@ same value: Note that overloaded access makes this transparent: - $a = new Data 23; + $a = Data->new(23); $b = $a; # $b is "linked" to $a $a += 4; # would unlink $b automagically However, it would not make - $a = new Data 23; + $a = Data->new(23); $a = 4; # Now $a is a plain 4, not 'Data' preserve "objectness" of $a. But Perl I a way to make assignments @@ -947,7 +947,7 @@ Put this in F in your Perl library directory: Use it as follows: require two_face; - my $seven = new two_face ("vii", 7); + my $seven = two_face->new("vii", 7); printf "seven=$seven, seven=%d, eight=%d\n", $seven, $seven+1; print "seven contains `i'\n" if $seven =~ /i/; @@ -994,7 +994,7 @@ array reference and a hash reference. Now one can access an object using both the array and hash syntax: - my $bar = new two_refs 3,4,5,6; + my $bar = two_refs->new(3,4,5,6); $bar->[2] = 11; $bar->{two} == 11 or die 'bad hash fetch'; @@ -1099,15 +1099,15 @@ This module is very unusual as overloaded modules go: it does not provide any usual overloaded operators, instead it provides the L operator C. In this example the corresponding subroutine returns an object which encapsulates operations done over -the objects: C contains C<['n', 3]>, C<2 + new -symbolic 3> contains C<['+', 2, ['n', 3]]>. +the objects: C<< symbolic->new(3) >> contains C<['n', 3]>, C<< 2 + +symbolic->new(3) >> contains C<['+', 2, ['n', 3]]>. Here is an example of the script which "calculates" the side of circumscribed octagon using the above package: require symbolic; my $iter = 1; # 2**($iter+2) = 8 - my $side = new symbolic 1; + my $side = symbolic->new(1); my $cnt = $iter; while ($cnt--) { @@ -1231,8 +1231,8 @@ explicit recursion in num()? (Answer is at the end of this section.) Use this module like this: require symbolic; - my $iter = new symbolic 2; # 16-gon - my $side = new symbolic 1; + my $iter = symbolic->new(2); # 16-gon + my $side = symbolic->new(1); my $cnt = $iter; while ($cnt) { @@ -1352,8 +1352,8 @@ To see it in action, add a method to the package C. After this change one can do - my $a = new symbolic 3; - my $b = new symbolic 4; + my $a = symbolic->new(3); + my $b = symbolic->new(4); my $c = sqrt($a**2 + $b**2); and the numeric value of $c becomes 5. However, after calling