|< 1 2 >| | 15 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl
#verbindung aufbauen (port logischerweise 80/8080)
$host = open(FILE,"ip.txt");
$port = 80;
if(not defined($host)) {
die "\ndatei kann nicht geoeffnet werden!\n";
}
use IO::Socket;
my $sock = new IO::Socket;(
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp'
);
print $sock "GET index.php HTTP/1.1\n";
print $sock "Host: $host\n";
print $sock "Accept: */*\n";
print $sock "Connection: close\n\n";
my @answer=<$sock>;
foreach my $a (@answer) {
print $a;
}
my $answer = <$sock>;
print "$answer\n";
1
2
3
open(FILE, "<ip.txt") or die "\nDatei kann nicht geöffnet werden!\n";
my $host = <FILE>;
close(FILE);
use strict;
open FILE, '<', 'ip.txt' or die ...;
open FILE, '<', 'ip.txt' or die ...;
QuoteAny two-argument open(), readpipe() (aka qx//) and similar
operators found within the lexical scope of this pragma will
use the declared defaults. Three-argument opens are not
affected by this pragma since there you (can) explicitly
specify the layers and are supposed to know what you are
doing.
QuoteUse 3-argument form to open a file with arbitrary
weird characters in it,
open(FOO, '<', $file);
otherwise it's necessary to protect any leading and
trailing whitespace:
$file =~ s#^(\s)#./$1#;
open(FOO, "< $file\0");
(this may not work on some bizarre filesystems).
One should conscientiously choose between the magic
and 3-arguments form of open():
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
open( my $FH, '<', $file )
or die "Error: can't open file '$file': $!\n";
while( my $fileX = <$FH> ) {
chomp($fileX);
if (-f $fileX) {
my @data = &ReadFile($fileX);
print "# Reading $fileX\n", @data;
} # if
} # while
close ($FH);
sub ReadFile {
my $filename = shift;
open( my $FH, '<', $filename )
or die "Error: couldn't open file '$filename': $!\n";
my @lines = <$FH>;
close( $FH ); # eigentlich ueberfluessig
return @lines;
} # ReadFile
|< 1 2 >| | 15 Einträge, 2 Seiten |