0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

perl 1

Last updated at Posted at 2024-12-14
[root@centos8_1 ~]# cat perl.pl
#!/usr/bin/perl

my $a = "SHIBATAZZZZZZZZZZZ";
my $b = "HI";

if ( $a =~ $b ) {

   print "$aに$bは含まれます\n";

}

print "END\n";

shiftの使い方

[root@centos8_1 ~]# cat perl2.pl
#!/usr/bin/perl

sub make {

my $num1 = shift;
my $num2 = shift;
my $num3 = shift;

print "$num1\n";
print "$num2\n";
print "$num3\n";

}

&make(1,2,3);

splitの使い方

root@centos8_1 ~]# cat perl3.pl
#!/usr/bin/perl

my $user = "xyzzys:x:1000:1000:xyzzys:/home/xyzzys:/bin/bash";

my @users = split(/:/,$user);


for (my $i = 0; $i < @users; $i++){
  print "$users[$i]\n";
}

[root@centos8_1 ~]#

perl正規表現の技

 

大前提 chompは行いましょう!!


####文字列の前のスペースをなくす方法####

s/^\s+//;

####文字列の後ろにあるスペースをなくす方法####

s/\s+$//;


0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?