#!/usr/bin/env perl
our $ssta = 10;
print "0 ssta (t.pl): $ssta\n";
require 'rt.pl'; # либо: do 'rt.pl';
print "1 ssta (t.pl): $ssta\n";
#!/usr/bin/env perl
my $sta = 15;
print "2 ssta (rt.pl): $ssta\n";
$ssta += $sta;
print "3 sta (rt.pl): $sta\n";
print "4 ssta (rt.pl): $ssta\n";
0 ssta (t.pl): 10
2 ssta (rt.pl): 10
3 sta (rt.pl): 15
4 ssta (rt.pl): 25
1 ssta (t.pl): 25
use Mojo::DOM;
my $text = '<img id = "3" class="lazy" src="/media/a.jpg" data-original="/media/a.jpg" alt="text">';
my $data_original = Mojo::DOM->new( $text )->find( 'img' )->map( attr => 'data-original' );
print "$_\n" foreach @$data_original;
BEGIN { unshift @INC, 'c:\mailer\lib'; }
# или
use lib qw( c:\mailer\lib );
# или
use lib::abs qw( c:\mailer\lib );
# или
use lib::abs qw( lib );
# ...еще какая-то магия
#!/usr/bin/perl
#use forks;
use threads;
use threads::shared;
use strict;
use warnings;
use Data::Dumper;
use lib::abs qw( lib );
use file;
<VirtualHost 222.222.222.222:81 >
ServerName somedomain.com
CustomLog /var/www/httpd-logs/somedomain.com.access.log combined
DocumentRoot /var/www/someuser/data/www/somedomain.com
ErrorLog /var/www/httpd-logs/somedomain.com.error.log
ServerAlias www.somedomain.com
SuexecUserGroup someuser somegroup
ServerAdmin webmaster@somedomain.com
ScriptAlias /cgi-bin/ /var/www/someuser/data/www/somedomain.com/cgi-bin/
</VirtualHost>
<VirtualHost 222.222.222.222:81 >
ServerName somedomain1.com
CustomLog /var/www/httpd-logs/somedomain1.com.access.log combined
DocumentRoot /var/www/someuser/data/www/somedomain1.com
ErrorLog /var/www/httpd-logs/somedomain1.com.error.log
ServerAlias www.somedomain1.com
SuexecUserGroup someuser somegroup
ServerAdmin webmaster@somedomain1.com
ScriptAlias /cgi-bin/ /var/www/someuser/data/www/somedomain1.com/cgi-bin/
</VirtualHost>
<VirtualHost 222.222.222.222:81 >
ServerName somedomain2.com
CustomLog /var/www/httpd-logs/somedomain2.com.access.log combined
DocumentRoot /var/www/someuser/data/www/somedomain2.com
ErrorLog /var/www/httpd-logs/somedomain2.com.error.log
ServerAlias www.somedomain2.com
SuexecUserGroup someuser somegroup
ServerAdmin webmaster@somedomain2.com
ScriptAlias /cgi-bin/ /var/www/someuser/data/www/somedomain2.com/cgi-bin/
</VirtualHost>
sub removeIfSomedomain($$) {
my $text = shift;
my $domain = shift;
$text = '' if $text =~ m{^\s*?ServerName\s+?$domain\s*?$}igsm;
return $text;
}
sub changeContent($$$) {
my $text = shift;
my $domain = shift;
my $new_values = shift;
return $text if $text !~ m{^\s*?ServerName\s+?$domain\s*?$}igsm;
foreach my $key ( keys %$new_values ) {
$text =~ s{^(\s*?$key\s+?).+?$}{$1$new_values->{$key}}igsm;
}
return $text;
}
my $config = ... ; # содержимое конфига
$config =~ s{(<VirtualHost[^>]*?>.*?<\/VirtualHost>)}{ removeIfSomedomain($1,'somedomain1.com') }igse;
$config =~ s{(<VirtualHost[^>]*?>.*?<\/VirtualHost>)}{
changeContent($1,'somedomain2.com', { SuexecUserGroup => 'justuser justgroup',
ServerAlias => 'www.sd2.com',
ServerAdmin => 'admin@somedomain2.com' } )
}igse;
<VirtualHost 222.222.222.222:81 >
ServerName somedomain.com
CustomLog /var/www/httpd-logs/somedomain.com.access.log combined
DocumentRoot /var/www/someuser/data/www/somedomain.com
ErrorLog /var/www/httpd-logs/somedomain.com.error.log
ServerAlias www.somedomain.com
SuexecUserGroup someuser somegroup
ServerAdmin webmaster@somedomain.com
ScriptAlias /cgi-bin/ /var/www/someuser/data/www/somedomain.com/cgi-bin/
</VirtualHost>
<VirtualHost 222.222.222.222:81 >
ServerName somedomain2.com
CustomLog /var/www/httpd-logs/somedomain2.com.access.log combined
DocumentRoot /var/www/someuser/data/www/somedomain2.com
ErrorLog /var/www/httpd-logs/somedomain2.com.error.log
ServerAlias www.sd2.com
SuexecUserGroup justuser justgroup
ServerAdmin admin@somedomain2.com
ScriptAlias /cgi-bin/ /var/www/someuser/data/www/somedomain2.com/cgi-bin/
</VirtualHost>
foreach my $el (@series){
print $el->{'login'};
}