Recent Changes - Search:

edit SideBar


Firefox 2
Get Thunderbird!

Strings

Perl.Strings History

Hide minor edits - Show changes to markup

July 13, 2005, at 03:53 AM by Özgün
Changed lines 14-18 from:

$s = q(Don't let yourself go);

to:
  1. $s = q(Don't let yourself go);
  2. print "$s \n";

  3. qq

$s = qq(I said: "go away");

Changed lines 21-25 from:
  1. qq

$s = qq(I said: "go away"); print "$s \n";

to:
July 13, 2005, at 03:52 AM by Özgün
Changed line 6 from:
  1. =perl
to:
July 13, 2005, at 03:52 AM by Özgün
Changed line 1 from:

=perl [=

to:

(:source lang=perl:) [=

Changed line 6 from:
to:
  1. =perl
July 13, 2005, at 02:57 AM by Özgün
Changed line 1 from:

<code>

to:

=perl [=

Changed line 117 from:

</code>

to:

=]

July 13, 2005, at 02:49 AM by Özgün
Added line 1:

<code>

Changed lines 116-117 from:

printf "2d\n", "onuc", 13,33;

to:

printf "2d\n", "onuc", 13,33; </code>

July 13, 2005, at 02:49 AM by Özgün
Added lines 1-115:
  1. !/usr/bin/perl
  2. String Manipulation

use strict; use warnings;

my ($s, $s1, $s2, $s3); my (@l, @l1, @l2);

  1. q

$s = q(Don't let yourself go); print "$s \n";

  1. qq

$s = qq(I said: "go away"); print "$s \n";

  1. identifier

print <<EOF;

	Hey
	man
	i am alive

EOF

  1. identifier

$s =<<EOF2?; go go go EOF2? print "$s \n";

  1. identifie ''

$s =<<'EOF'; [email protected] EOF print "$s \n";

  1. identifie ""

$s =<<"EOF"; oz\@kozgun.net oz\nat\nkozgun.net EOF print "$s \n";

  1. substr

$s1 = "Hey man i am alive"; $s2 = substr($s1, 4, 4, "girl"); $s3 = substr($s1, -4, 4); print "$s1 - $s2 - $s3\n";

  1. uc, lc

print uc($s1), "\n"; print lc($s1), "\n";

  1. ucfirst, lcfirst

print ucfirst($s1), "\n"; print lcfirst($s1), "\n";

  1. length

print "length: " , length($s1) , "\n";

  1. chop: Son karakteri çıkarır ve çıkarılan karakteri döndürür. Liste veya string ile çalışabilir.

$s1 = "ozx"; print "$s1 : ", chop($s1) , "\n";

  1. chomp: Sadece $/ input record seperator'a atanan karakteri çıkarır. Öntanımlı olarak "/n"
  2. Liste veya string ile çalışabilir.

$s1 = "oz\n"; print chomp($s1) , "\n"; print "$s1 \n";

  1. index: Aranan kelimenin ilk görüldüğü yerin indexini döndürü.
  2. Bulunanamazsa -1 döner.

$s1 = "oz ko"; $s2 = index($s1, "ko", 0); print "$s2 \n";

  1. rindex: tersten arama yapar.

$s1 = "perl perl perl"; $s2 = rindex($s1, "perl"); print "$s2 \n";

  1. join: Bir listeyi verilen seperator ile birleştirerek, string oluşturur.

@l1 = qw(red green blue); $s1 = join(",", @l1); $s2 = join(" and ", @l1); print "$s1 \n"; print "$s2 \n";

  1. split: Bir stringi verilen ayraça göre bölüp bir listeye atar.

$s1 = "red,blue,green"; @l1 = split(/,/,$s1,2); #Limit 2 @l2 = split(/,/,$s1); print "@l1 \n"; print "@l2 \n";

  1. tr: Translation operator.

$s1 = "win win win"; $s1 =~ tr/w/l/; print "$s1\n"; $s1 =~ tr/[a-z]/[A-Z]/; print "$s1\n"; $s1 = "ABCDEFGH"; $s1 =~ tr/ABCD/ab/d; #CD silinir. print "$s1\n"; $s1 = "peeerrllll pppppeerrrrll"; $s1 =~ tr/[a-z]/[a-z]/s; # veya tr/[a-z]//s print "$s1\n";

  1. printf

printf "2d\n", "onuc", 13,33;

Edit - History - Print - Recent Changes - Search
Page last modified on July 13, 2005, at 03:53 AM