- ANSI C
- PERL
- » Variable handling
- » Miscellaneous
- » POSIX
- » Date/Time
- » Math
- » menu_code_perlcode_strings
- » PCRE
- » Arrays
- » Classes
- » Program execution
- » Directories
- » Filesystem
- » GD
- » Network
- » Sockets
- » DBI
- PHP
- JavaScript
CONTENT
- CHANGES
Szukaj
#top Filesystem¶
code / perl / sysfile
#top Predefined Constants¶
Deklaracja stałych
SEEK_CUR
SEEK_END
SEEK_SET
znajduje się w pliku i386-linux-thread-multi/POSIX.pm
.fcntl_h => [qw( [...] SEEK_CUR SEEK_END SEEK_SET [...] )],
#top Datatypes / MACROS¶
No Datatypes here.
#top Filesystem Functions¶
#top close¶
Documentacja online: perldoc.perl.org | www.tutorialspoint.com
Deklaracja funkcji
close()
jest następująca:close FILEHANDLE close
Powiązane:
close(), open(),
Opis:
description
#top Copying Files¶
Documentacja online: perldoc.perl.org | www.tutorialspoint.com
Powiązane:
Opis:
description
Example:
zawartość pliku
copy.pl
SELECT ALL
#!/usr/bin/perl -w use strict; # force definations for all vars an subroutines use warnings; # force check of unset variables in expressions use diagnostics; # give var/code line number on faults my ($workdir, $filesrcs, $filedest); my ($FHSRCS, $FHDEST, $line, $data); if ($#ARGV+1<2) { print("Usage: $0 </path/to/source> </path/to/destination>\n"); print("Examples:\n"); print(" $0 /home/local/code/perlcode/sysfile/copy.pl /home/local/code/perlcode/sysfile/copy-copytest.pl\n"); print(" $0 /bin/bash /home/local/code/perlcode/sysfile/bash\n"); exit(1); } $filesrcs=$ARGV[0]; $filedest=$ARGV[1]; $workdir=$filedest; $workdir=~s,/[^/]*$,,g; if ( ! (-e $filesrcs && -f $filesrcs) ) { print(STDERR "$0: En"$0: Entry '$filesrcs' does not exists or not a file.\n"); exit(1); } if (! -r $filesrcs) { print(STDERR "$0: Fi"$0: File '$filesrcs' exists but is not readable!\n"); exit(1); } if (! (-e $workdir && -d $workdir) ) { print(STDERR "$0: En"$0: Entry '$workdir' does not exists or not a directory.\n"); exit(1); } if (! -w $workdir) { print(STDERR "$0: Di"$0: Directory '$workdir' exists but is not writable!\n"); exit(1); } if (!open($FHSRCS,$filesrcs)) { print(STDERR "$0: Un"$0: Unable to open file '$filesrcs' for read, Reason $!\n"); } print""$0: if (open($FHSRCS,$filesrcs)): Successful opened file '$filesrcs' for read.\n"); if (!open($FHDEST,">$filedest")) { print(STDERR "$0: if"$0: if (open($FHDEST,\">$filedest\")): else: Unable to open file '$filedest' for write, Reason $!\n"); } print""$0: if (open($FHDEST,\">$filedest\")): Successful opened file '$filedest' for write.\n"); if (-B $filesrcs) { $|=1; print("$0: copying content in BINARY mode ..."); while (read($FHSRCS,$data,16384)!=0) { print($FHDEST $data); } print("... DONE\n"); } else { $|=1; print("$0: copying content in TEXT mode ..."); while ($line=<$FHSRCS>) { print($FHDEST $line); } print("... DONE\n"); } print""$0: close($FHSRCS):\n"); close($FHSRCS); print""$0: close($FHDEST):\n"); close($FHDEST);
Aby zobaczyć jak działa program należy go uruchomić bez argumentów:
/home/local/code/perlcode/sysfile/copy.plprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/perlcode/sysfile/copy.pl </path/to/source> </path/to/destination> Examples: /home/local/code/perlcode/sysfile/copy.pl /home/local/code/perlcode/sysfile/copy.pl /home/local/code/perlcode/sysfile/copy-copytest.pl /home/local/code/perlcode/sysfile/copy.pl /bin/bash /home/local/code/perlcode/sysfile/bash
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/perlcode/sysfile/copy.pl /home/local/code/perlcode/sysfile/copy.pl /home/local/code/perlcode/sysfile/copy-copytest.pl /home/local/code/perlcode/sysfile/copy.pl /bin/bash /home/local/code/perlcode/sysfile/bashrezultat będzie zależny od podanego argumentu wywołania programu:
/home/local/code/perlcode/sysfile/copy.pl: if (open(GLOB(0x8db1dd8),/home/local/code/perlcode/sysfile/copy.pl)): Successful opened file '/home/local/code/perlcode/sysfile/copy.pl' for read. /home/local/code/perlcode/sysfile/copy.pl: if (open(GLOB(0x8db28f4),">/home/local/code/perlcode/sysfile/copy-copytest.pl")): Successful opened file '/home/local/code/perlcode/sysfile/copy-copytest.pl' for write. /home/local/code/perlcode/sysfile/copy.pl: copying content in TEXT mode ...... DONE /home/local/code/perlcode/sysfile/copy.pl: close(GLOB(0x8db1dd8)): /home/local/code/perlcode/sysfile/copy.pl: close(GLOB(0x8db28f4)): /home/local/code/perlcode/sysfile/copy.pl: if (open(GLOB(0x96dedd8),/bin/bash)): Successful opened file '/bin/bash' for read. /home/local/code/perlcode/sysfile/copy.pl: if (open(GLOB(0x96df8f4),">/home/local/code/perlcode/sysfile/bash")): Successful opened file '/home/local/code/perlcode/sysfile/bash' for write. /home/local/code/perlcode/sysfile/copy.pl: copying content in BINARY mode ...... DONE /home/local/code/perlcode/sysfile/copy.pl: close(GLOB(0x96dedd8)): /home/local/code/perlcode/sysfile/copy.pl: close(GLOB(0x96df8f4)):
#top FILEHANDLE Operator¶
Documentacja online: perldoc.perl.org | www.tutorialspoint.com
Deklaracja operatora
FILEHANDLE
jest następująca:<FILEHANDLE>
Powiązane:
FILEHANDLE Operator, print(), read(),
Opis:
description
Example:
zawartość pliku
FILEHANDLE.pl
SELECT ALL
#!/usr/bin/perl -w use strict; # force definations for all vars an subroutines use warnings; # force check of unset variables in expressions use diagnostics; # give var/code line number on faults if ($#ARGV+1<1) { print("Usage: $0 </path/to/file>\n"); print("Examples:\n"); print(" $0 /home/local/code/perlcode/sysfile/FILEHANDLE.pl\n"); exit(1); } my ($fileopen); $fileopen=$ARGV[0]; my ($FHRD, $oneline, @LINES); if (-e $fileopen && -f $fileopen) { if (-r $fileopen) { if (open($FHRD,$fileopen)) { printn"$0: if (open($FHRD,$fileopen)): Successful opened file '$fileopen' for read.\n"); $oneline=<$FHRD>; printn"$0: \$oneline=|$oneline|\n"); @LINES=<$FHRD>; printn"$0: \@LINES=|@LINES|\n"); unshift(@LINES, $oneline); printn"$0: count lines \@LINES \$#LINES=|".($#LINES+1)."|\n"); printn"$0: close($FHRD):\n"); close($FHRD); } else { print(STDERRRR "$0: "$0: Unable to open file '$fileopen' for read, Reason $!\n"); } } else { print(STDERRR "$0: E"$0: Entry '$fileopen' exists but is not readable!\n"); } } else { print(STDERR "$0: En"$0: Entry '$fileopen' does not exists or not a file.\n"); }
Aby zobaczyć jak działa program należy go uruchomić bez argumentów:
/home/local/code/perlcode/sysfile/FILEHANDLE.plprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/perlcode/sysfile/FILEHANDLE.pl </path/to/file> Examples: /home/local/code/perlcode/sysfile/FILEHANDLE.pl /home/local/code/perlcode/sysfile/FILEHANDLE.pl
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/perlcode/sysfile/FILEHANDLE.pl /home/local/code/perlcode/sysfile/FILEHANDLE.plrezultat będzie zależny od podanego argumentu wywołania programu:
/home/local/code/perlcode/sysfile/FILEHANDLE.pl: if (open(GLOB(0x8efddd8),/home/local/code/perlcode/sysfile/FILEHANDLE.pl)): Successful opened file '/home/local/code/perlcode/sysfile/FILEHANDLE.pl' for read. /home/local/code/perlcode/sysfile/FILEHANDLE.pl: $oneline=|#!/usr/bin/perl -w | /home/local/code/perlcode/sysfile/FILEHANDLE.pl: @LINES=| use strict; # force definations for all vars an subroutines use warnings; # force check of unset variables in expressions use diagnostics; # give var/code line number on faults if ($#ARGV+1<1) { print("Usage: $0 </path/to/file>\n"); print("Examples:\n"); print(" $0 /home/local/code/perlcode/sysfile/FILEHANDLE.pl\n"); exit(1); } my ($fileopen); $fileopen=$ARGV[0]; my ($FHRD, $oneline, @LINES); if (-e $fileopen && -f $fileopen) { if (-r $fileopen) { if (open($FHRD,$fileopen)) { print("$0: if (open($FHRD,$fileopen)): Successful opened file '$fileopen' for read.\n"); $oneline=<$FHRD>; print("$0: \$oneline=|$oneline|\n"); @LINES=<$FHRD>; print("$0: \@LINES=|@LINES|\n"); unshift(@LINES, $oneline); print("$0: count lines \@LINES \$#LINES=|".($#LINES+1)."|\n"); print("$0: close($FHRD):\n"); close($FHRD); } else { print(STDERR "$0: Unable to open file '$fileopen' for read, Reason $!\n"); } } else { print(STDERR "$0: Entry '$fileopen' exists but is not readable!\n"); } } else { print(STDERR "$0: Entry '$fileopen' does not exists or not a file.\n"); } | /home/local/code/perlcode/sysfile/FILEHANDLE.pl: count lines @LINES $#LINES=|47| /home/local/code/perlcode/sysfile/FILEHANDLE.pl: close(GLOB(0x8efddd8)):Jak widać na powyższym rezultacie wywołania programu działanie operatora
FILEHANDLE
zależne jest od kontekstu użycia. W przypadku przypisywania operatora do scalara operator zwraca jedną linię z pliku, natomiast w przypadku przypisania operatora do listy operator zwraca wszystkie linie z pliku. W powyższym przykładzie za pomocą funkcji unshift
do listy na początku dodawana jest pierwsza odczytana linia z pliku, aby lista zawierała wszystkie linie z pliku i obrazowała rzeczywistą liczbę linii z odczytanego pliku.#top File Information¶
Documentacja online: perldoc.perl.org | www.tutorialspoint.com
Powiązane:
Opis:
description
Example:
zawartość pliku
FileInformation.pl
SELECT ALL
#!/usr/bin/perl -w use strict; # force definations for all vars an subroutines use warnings; # force check of unset variables in expressions use diagnostics; # give var/code line number on faults if ($#ARGV+1<1) { print("Usage: $0 </path/to/file>\n"); print("Examples:\n"); print(" $0 /etc\n"); print(" $0 /tmp\n"); print(" $0 /root\n"); print(" $0 /dev/sda\n"); print(" $0 /dev/null\n"); print(" $0 /dev/log\n"); print(" $0 /dev/core\n"); print(" $0 /etc/fstab\n"); print(" $0 /usr/bin/GET\n"); print(" $0 /usr/bin/perl\n"); exit(1); } my $filename=$ARGV[0]; print""filename=$filename:\n"); if (-e $filename) { print("OK: $filename EXISTS\n"); } else { print("NOK: $filename not EXISTS !!!\n"); } if (-d $filename) { print("OK: $filename is DIRECTORY\n"); } else { print("NOK: $filename is not DIRECTORY !!!\n"); } if (-b $filename) { print("OK: $filename is BLOCK FILE\n"); } else { print("NOK: $filename is not BLOCK FILE !!!\n"); } if (-c $filename) { print("OK: $filename is CHAR FILE\n"); } else { print("NOK: $filename is not CHAR FILE !!!\n"); } if (-S $filename) { print("OK: $filename is SOCKET\n"); } else { print("NOK: $filename is not SOCKET !!!\n"); } if (-l $filename) { print("OK: $filename is SYMLINK\n"); } else { print("NOK: $filename is not SYMLINK !!!\n"); } if (-f $filename) { print("OK: $filename is REGULAR FILE\n"); } else { print("NOK: $filename is not REGULAR FILE !!!\n"); } if (-T $filename) { print("OK: $filename is SCRIPT\n"); } else { print("NOK: $filename is not SCRIPT !!!\n"); } if (-s $filename) { print("OK: $filename is NOT EMPTY\n"); } else { print("NOK: $filename is EMPTY !!!\n"); } if (-r $filename) { print("OK: $filename is READABLE\n"); } else { print("NOK: $filename is not READABLE !!!\n"); } if (-w $filename) { print("OK: $filename is WRITABLE\n"); } else { print("NOK: $filename is not WRITABLE !!!\n"); } if (-x $filename) { print("OK: $filename is EXECUTABLE\n"); } else { print("NOK: $filename is not EXECUTABLE !!!\n"); } if (-A $filename) { print("OK: $filename Age of file (at script startup) in days since modification.\n"); } else { print("NOK: $filename Age of file (at script startup) in days since modification.\n"); } if (-B $filename) { print("OK: $filename It is a binary file.\n"); } else { print("NOK: $filename It is a binary file.\n"); } if (-C $filename) { print("OK: $filename Age of file (at script startup) in days since modification.\n"); } else { print("NOK: $filename Age of file (at script startup) in days since modification.\n"); } if (-M $filename) { print("OK: $filename Age of file (at script startup) in days since modification.\n"); } else { print("NOK: $filename Age of file (at script startup) in days since modification.\n"); } if (-O $filename) { print("OK: $filename The file is owned by the real user ID.\n"); } else { print("NOK: $filename The file is owned by the real user ID.\n"); } if (-R $filename) { print("OK: $filename The file is readable by the real user ID or real group.\n"); } else { print("NOK: $filename The file is readable by the real user ID or real group.\n"); } if (-S $filename) { print("OK: $filename The file is a socket.\n"); } else { print("NOK: $filename The file is a socket.\n"); } if (-T $filename) { print("OK: $filename It is a text file.\n"); } else { print("NOK: $filename It is a text file.\n"); } if (-W $filename) { print("OK: $filename The file is writable by the real user ID or real group.\n"); } else { print("NOK: $filename The file is writable by the real user ID or real group.\n"); } if (-X $filename) { print("OK: $filename The file is executable by the real user ID or real group.\n"); } else { print("NOK: $filename The file is executable by the real user ID or real group.\n"); } if (-b $filename) { print("OK: $filename It is a block special file.\n"); } else { print("NOK: $filename It is a block special file.\n"); } if (-c $filename) { print("OK: $filename It is a character special file.\n"); } else { print("NOK: $filename It is a character special file.\n"); } if (-d $filename) { print("OK: $filename The file is a directory.\n"); } else { print("NOK: $filename The file is a directory.\n"); } if (-e $filename) { print("OK: $filename The file does exist.\n"); } else { print("NOK: $filename The file does exist.\n"); } if (-f $filename) { print("OK: $filename It is a plain file.\n"); } else { print("NOK: $filename It is a plain file.\n"); } if (-g $filename) { print("OK: $filename The file does have the setgid bit set.\n"); } else { print("NOK: $filename The file does have the setgid bit set.\n"); } if (-k $filename) { print("OK: $filename The file does have the sticky bit set.\n"); } else { print("NOK: $filename The file does have the sticky bit set.\n"); } if (-l $filename) { print("OK: $filename The file is a symbolic link.\n"); } else { print("NOK: $filename The file is a symbolic link.\n"); } if (-o $filename) { print("OK: $filename The file is owned by the effective user ID.\n"); } else { print("NOK: $filename The file is owned by the effective user ID.\n"); } if (-p $filename) { print("OK: $filename The file is a named pipe.\n"); } else { print("NOK: $filename The file is a named pipe.\n"); } if (-r $filename) { print("OK: $filename The file is readable by the effective user or group ID.\n"); } else { print("NOK: $filename The file is readable by the effective user or group ID.\n"); } if (-s $filename) { print("OK: $filename Returns the size of the file, zero size = empty file.\n"); } else { print("NOK: $filename Returns the size of the file, zero size = empty file.\n"); } if (-t $filename) { print("OK: $filename The filehandle is opened by a TTY (terminal).\n"); } else { print("NOK: $filename The filehandle is opened by a TTY (terminal).\n"); } if (-u $filename) { print("OK: $filename The is does file have the setuid bit set.\n"); } else { print("NOK: $filename The is does file have the setuid bit set.\n"); } if (-w $filename) { print("OK: $filename The file is writable by the effective user or group ID.\n"); } else { print("NOK: $filename The file is writable by the effective user or group ID.\n"); } if (-x $filename) { print("OK: $filename The file is executable by the effective user or group ID.\n"); } else { print("NOK: $filename The file is executable by the effective user or group ID.\n"); } if (-z $filename) { print("OK: $filename The file is size zero.\n"); } else { print("NOK: $filename The file is size zero.\n"); }
Aby zobaczyć jak działa program należy go uruchomić bez argumentów:
/home/local/code/perlcode/sysfile/FileInformation.plprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/perlcode/sysfile/FileInformation.pl </path/to/file> Examples: /home/local/code/perlcode/sysfile/FileInformation.pl /etc /home/local/code/perlcode/sysfile/FileInformation.pl /tmp /home/local/code/perlcode/sysfile/FileInformation.pl /root /home/local/code/perlcode/sysfile/FileInformation.pl /dev/sda /home/local/code/perlcode/sysfile/FileInformation.pl /dev/null /home/local/code/perlcode/sysfile/FileInformation.pl /dev/log /home/local/code/perlcode/sysfile/FileInformation.pl /dev/core /home/local/code/perlcode/sysfile/FileInformation.pl /etc/fstab /home/local/code/perlcode/sysfile/FileInformation.pl /usr/bin/GET /home/local/code/perlcode/sysfile/FileInformation.pl /usr/bin/perl
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/perlcode/sysfile/FileInformation.pl /etc /home/local/code/perlcode/sysfile/FileInformation.pl /tmp /home/local/code/perlcode/sysfile/FileInformation.pl /root /home/local/code/perlcode/sysfile/FileInformation.pl /dev/sda /home/local/code/perlcode/sysfile/FileInformation.pl /dev/null /home/local/code/perlcode/sysfile/FileInformation.pl /dev/log /home/local/code/perlcode/sysfile/FileInformation.pl /dev/core /home/local/code/perlcode/sysfile/FileInformation.pl /etc/fstab /home/local/code/perlcode/sysfile/FileInformation.pl /usr/bin/GET /home/local/code/perlcode/sysfile/FileInformation.pl /usr/bin/perlrezultat będzie zależny od podanego argumentu wywołania programu:
filename=/etc: OK: /etc EXISTS OK: /etc is DIRECTORY NOK: /etc is not BLOCK FILE !!! NOK: /etc is not CHAR FILE !!! NOK: /etc is not SOCKET !!! NOK: /etc is not SYMLINK !!! NOK: /etc is not REGULAR FILE !!! NOK: /etc is not SCRIPT !!! OK: /etc is NOT EMPTY OK: /etc is READABLE NOK: /etc is not WRITABLE !!! OK: /etc is EXECUTABLE OK: /etc Age of file (at script startup) in days since modification. OK: /etc It is a binary file. OK: /etc Age of file (at script startup) in days since modification. OK: /etc Age of file (at script startup) in days since modification. NOK: /etc The file is owned by the real user ID. OK: /etc The file is readable by the real user ID or real group. NOK: /etc The file is a socket. NOK: /etc It is a text file. NOK: /etc The file is writable by the real user ID or real group. OK: /etc The file is executable by the real user ID or real group. NOK: /etc It is a block special file. NOK: /etc It is a character special file. OK: /etc The file is a directory. OK: /etc The file does exist. NOK: /etc It is a plain file. NOK: /etc The file does have the setgid bit set. NOK: /etc The file does have the sticky bit set. NOK: /etc The file is a symbolic link. NOK: /etc The file is owned by the effective user ID. NOK: /etc The file is a named pipe. OK: /etc The file is readable by the effective user or group ID. OK: /etc Returns the size of the file, zero size = empty file. NOK: /etc The filehandle is opened by a TTY (terminal). NOK: /etc The is does file have the setuid bit set. NOK: /etc The file is writable by the effective user or group ID. OK: /etc The file is executable by the effective user or group ID. NOK: /etc The file is size zero. filename=/tmp: OK: /tmp EXISTS OK: /tmp is DIRECTORY NOK: /tmp is not BLOCK FILE !!! NOK: /tmp is not CHAR FILE !!! NOK: /tmp is not SOCKET !!! NOK: /tmp is not SYMLINK !!! NOK: /tmp is not REGULAR FILE !!! NOK: /tmp is not SCRIPT !!! OK: /tmp is NOT EMPTY OK: /tmp is READABLE OK: /tmp is WRITABLE OK: /tmp is EXECUTABLE OK: /tmp Age of file (at script startup) in days since modification. OK: /tmp It is a binary file. OK: /tmp Age of file (at script startup) in days since modification. OK: /tmp Age of file (at script startup) in days since modification. NOK: /tmp The file is owned by the real user ID. OK: /tmp The file is readable by the real user ID or real group. NOK: /tmp The file is a socket. NOK: /tmp It is a text file. OK: /tmp The file is writable by the real user ID or real group. OK: /tmp The file is executable by the real user ID or real group. NOK: /tmp It is a block special file. NOK: /tmp It is a character special file. OK: /tmp The file is a directory. OK: /tmp The file does exist. NOK: /tmp It is a plain file. NOK: /tmp The file does have the setgid bit set. OK: /tmp The file does have the sticky bit set. NOK: /tmp The file is a symbolic link. NOK: /tmp The file is owned by the effective user ID. NOK: /tmp The file is a named pipe. OK: /tmp The file is readable by the effective user or group ID. OK: /tmp Returns the size of the file, zero size = empty file. NOK: /tmp The filehandle is opened by a TTY (terminal). NOK: /tmp The is does file have the setuid bit set. OK: /tmp The file is writable by the effective user or group ID. OK: /tmp The file is executable by the effective user or group ID. NOK: /tmp The file is size zero. filename=/root: OK: /root EXISTS OK: /root is DIRECTORY NOK: /root is not BLOCK FILE !!! NOK: /root is not CHAR FILE !!! NOK: /root is not SOCKET !!! NOK: /root is not SYMLINK !!! NOK: /root is not REGULAR FILE !!! NOK: /root is not SCRIPT !!! OK: /root is NOT EMPTY NOK: /root is not READABLE !!! NOK: /root is not WRITABLE !!! NOK: /root is not EXECUTABLE !!! OK: /root Age of file (at script startup) in days since modification. NOK: /root It is a binary file. OK: /root Age of file (at script startup) in days since modification. OK: /root Age of file (at script startup) in days since modification. NOK: /root The file is owned by the real user ID. NOK: /root The file is readable by the real user ID or real group. NOK: /root The file is a socket. NOK: /root It is a text file. NOK: /root The file is writable by the real user ID or real group. NOK: /root The file is executable by the real user ID or real group. NOK: /root It is a block special file. NOK: /root It is a character special file. OK: /root The file is a directory. OK: /root The file does exist. NOK: /root It is a plain file. NOK: /root The file does have the setgid bit set. NOK: /root The file does have the sticky bit set. NOK: /root The file is a symbolic link. NOK: /root The file is owned by the effective user ID. NOK: /root The file is a named pipe. NOK: /root The file is readable by the effective user or group ID. OK: /root Returns the size of the file, zero size = empty file. NOK: /root The filehandle is opened by a TTY (terminal). NOK: /root The is does file have the setuid bit set. NOK: /root The file is writable by the effective user or group ID. NOK: /root The file is executable by the effective user or group ID. NOK: /root The file is size zero. filename=/dev/sda: OK: /dev/sda EXISTS NOK: /dev/sda is not DIRECTORY !!! OK: /dev/sda is BLOCK FILE NOK: /dev/sda is not CHAR FILE !!! NOK: /dev/sda is not SOCKET !!! NOK: /dev/sda is not SYMLINK !!! NOK: /dev/sda is not REGULAR FILE !!! NOK: /dev/sda is not SCRIPT !!! NOK: /dev/sda is EMPTY !!! NOK: /dev/sda is not READABLE !!! NOK: /dev/sda is not WRITABLE !!! NOK: /dev/sda is not EXECUTABLE !!! OK: /dev/sda Age of file (at script startup) in days since modification. NOK: /dev/sda It is a binary file. OK: /dev/sda Age of file (at script startup) in days since modification. OK: /dev/sda Age of file (at script startup) in days since modification. NOK: /dev/sda The file is owned by the real user ID. NOK: /dev/sda The file is readable by the real user ID or real group. NOK: /dev/sda The file is a socket. NOK: /dev/sda It is a text file. NOK: /dev/sda The file is writable by the real user ID or real group. NOK: /dev/sda The file is executable by the real user ID or real group. OK: /dev/sda It is a block special file. NOK: /dev/sda It is a character special file. NOK: /dev/sda The file is a directory. OK: /dev/sda The file does exist. NOK: /dev/sda It is a plain file. NOK: /dev/sda The file does have the setgid bit set. NOK: /dev/sda The file does have the sticky bit set. NOK: /dev/sda The file is a symbolic link. NOK: /dev/sda The file is owned by the effective user ID. NOK: /dev/sda The file is a named pipe. NOK: /dev/sda The file is readable by the effective user or group ID. NOK: /dev/sda Returns the size of the file, zero size = empty file. NOK: /dev/sda The filehandle is opened by a TTY (terminal). NOK: /dev/sda The is does file have the setuid bit set. NOK: /dev/sda The file is writable by the effective user or group ID. NOK: /dev/sda The file is executable by the effective user or group ID. OK: /dev/sda The file is size zero. filename=/dev/null: OK: /dev/null EXISTS NOK: /dev/null is not DIRECTORY !!! NOK: /dev/null is not BLOCK FILE !!! OK: /dev/null is CHAR FILE NOK: /dev/null is not SOCKET !!! NOK: /dev/null is not SYMLINK !!! NOK: /dev/null is not REGULAR FILE !!! OK: /dev/null is SCRIPT NOK: /dev/null is EMPTY !!! OK: /dev/null is READABLE OK: /dev/null is WRITABLE NOK: /dev/null is not EXECUTABLE !!! OK: /dev/null Age of file (at script startup) in days since modification. OK: /dev/null It is a binary file. OK: /dev/null Age of file (at script startup) in days since modification. OK: /dev/null Age of file (at script startup) in days since modification. NOK: /dev/null The file is owned by the real user ID. OK: /dev/null The file is readable by the real user ID or real group. NOK: /dev/null The file is a socket. OK: /dev/null It is a text file. OK: /dev/null The file is writable by the real user ID or real group. NOK: /dev/null The file is executable by the real user ID or real group. NOK: /dev/null It is a block special file. OK: /dev/null It is a character special file. NOK: /dev/null The file is a directory. OK: /dev/null The file does exist. NOK: /dev/null It is a plain file. NOK: /dev/null The file does have the setgid bit set. NOK: /dev/null The file does have the sticky bit set. NOK: /dev/null The file is a symbolic link. NOK: /dev/null The file is owned by the effective user ID. NOK: /dev/null The file is a named pipe. OK: /dev/null The file is readable by the effective user or group ID. NOK: /dev/null Returns the size of the file, zero size = empty file. NOK: /dev/null The filehandle is opened by a TTY (terminal). NOK: /dev/null The is does file have the setuid bit set. OK: /dev/null The file is writable by the effective user or group ID. NOK: /dev/null The file is executable by the effective user or group ID. OK: /dev/null The file is size zero. filename=/dev/log: OK: /dev/log EXISTS NOK: /dev/log is not DIRECTORY !!! NOK: /dev/log is not BLOCK FILE !!! NOK: /dev/log is not CHAR FILE !!! OK: /dev/log is SOCKET NOK: /dev/log is not SYMLINK !!! NOK: /dev/log is not REGULAR FILE !!! NOK: /dev/log is not SCRIPT !!! NOK: /dev/log is EMPTY !!! OK: /dev/log is READABLE OK: /dev/log is WRITABLE NOK: /dev/log is not EXECUTABLE !!! OK: /dev/log Age of file (at script startup) in days since modification. NOK: /dev/log It is a binary file. OK: /dev/log Age of file (at script startup) in days since modification. OK: /dev/log Age of file (at script startup) in days since modification. NOK: /dev/log The file is owned by the real user ID. OK: /dev/log The file is readable by the real user ID or real group. OK: /dev/log The file is a socket. NOK: /dev/log It is a text file. OK: /dev/log The file is writable by the real user ID or real group. NOK: /dev/log The file is executable by the real user ID or real group. NOK: /dev/log It is a block special file. NOK: /dev/log It is a character special file. NOK: /dev/log The file is a directory. OK: /dev/log The file does exist. NOK: /dev/log It is a plain file. NOK: /dev/log The file does have the setgid bit set. NOK: /dev/log The file does have the sticky bit set. NOK: /dev/log The file is a symbolic link. NOK: /dev/log The file is owned by the effective user ID. NOK: /dev/log The file is a named pipe. OK: /dev/log The file is readable by the effective user or group ID. NOK: /dev/log Returns the size of the file, zero size = empty file. NOK: /dev/log The filehandle is opened by a TTY (terminal). NOK: /dev/log The is does file have the setuid bit set. OK: /dev/log The file is writable by the effective user or group ID. NOK: /dev/log The file is executable by the effective user or group ID. OK: /dev/log The file is size zero. filename=/dev/core: OK: /dev/core EXISTS NOK: /dev/core is not DIRECTORY !!! NOK: /dev/core is not BLOCK FILE !!! NOK: /dev/core is not CHAR FILE !!! NOK: /dev/core is not SOCKET !!! OK: /dev/core is SYMLINK OK: /dev/core is REGULAR FILE NOK: /dev/core is not SCRIPT !!! OK: /dev/core is NOT EMPTY NOK: /dev/core is not READABLE !!! NOK: /dev/core is not WRITABLE !!! NOK: /dev/core is not EXECUTABLE !!! NOK: /dev/core Age of file (at script startup) in days since modification. NOK: /dev/core It is a binary file. NOK: /dev/core Age of file (at script startup) in days since modification. NOK: /dev/core Age of file (at script startup) in days since modification. NOK: /dev/core The file is owned by the real user ID. NOK: /dev/core The file is readable by the real user ID or real group. NOK: /dev/core The file is a socket. NOK: /dev/core It is a text file. NOK: /dev/core The file is writable by the real user ID or real group. NOK: /dev/core The file is executable by the real user ID or real group. NOK: /dev/core It is a block special file. NOK: /dev/core It is a character special file. NOK: /dev/core The file is a directory. OK: /dev/core The file does exist. OK: /dev/core It is a plain file. NOK: /dev/core The file does have the setgid bit set. NOK: /dev/core The file does have the sticky bit set. OK: /dev/core The file is a symbolic link. NOK: /dev/core The file is owned by the effective user ID. NOK: /dev/core The file is a named pipe. NOK: /dev/core The file is readable by the effective user or group ID. OK: /dev/core Returns the size of the file, zero size = empty file. NOK: /dev/core The filehandle is opened by a TTY (terminal). NOK: /dev/core The is does file have the setuid bit set. NOK: /dev/core The file is writable by the effective user or group ID. NOK: /dev/core The file is executable by the effective user or group ID. NOK: /dev/core The file is size zero. filename=/etc/fstab: OK: /etc/fstab EXISTS NOK: /etc/fstab is not DIRECTORY !!! NOK: /etc/fstab is not BLOCK FILE !!! NOK: /etc/fstab is not CHAR FILE !!! NOK: /etc/fstab is not SOCKET !!! NOK: /etc/fstab is not SYMLINK !!! OK: /etc/fstab is REGULAR FILE OK: /etc/fstab is SCRIPT OK: /etc/fstab is NOT EMPTY OK: /etc/fstab is READABLE NOK: /etc/fstab is not WRITABLE !!! NOK: /etc/fstab is not EXECUTABLE !!! NOK: /etc/fstab Age of file (at script startup) in days since modification. NOK: /etc/fstab It is a binary file. OK: /etc/fstab Age of file (at script startup) in days since modification. OK: /etc/fstab Age of file (at script startup) in days since modification. NOK: /etc/fstab The file is owned by the real user ID. OK: /etc/fstab The file is readable by the real user ID or real group. NOK: /etc/fstab The file is a socket. OK: /etc/fstab It is a text file. NOK: /etc/fstab The file is writable by the real user ID or real group. NOK: /etc/fstab The file is executable by the real user ID or real group. NOK: /etc/fstab It is a block special file. NOK: /etc/fstab It is a character special file. NOK: /etc/fstab The file is a directory. OK: /etc/fstab The file does exist. OK: /etc/fstab It is a plain file. NOK: /etc/fstab The file does have the setgid bit set. NOK: /etc/fstab The file does have the sticky bit set. NOK: /etc/fstab The file is a symbolic link. NOK: /etc/fstab The file is owned by the effective user ID. NOK: /etc/fstab The file is a named pipe. OK: /etc/fstab The file is readable by the effective user or group ID. OK: /etc/fstab Returns the size of the file, zero size = empty file. NOK: /etc/fstab The filehandle is opened by a TTY (terminal). NOK: /etc/fstab The is does file have the setuid bit set. NOK: /etc/fstab The file is writable by the effective user or group ID. NOK: /etc/fstab The file is executable by the effective user or group ID. NOK: /etc/fstab The file is size zero. filename=/usr/bin/GET: OK: /usr/bin/GET EXISTS NOK: /usr/bin/GET is not DIRECTORY !!! NOK: /usr/bin/GET is not BLOCK FILE !!! NOK: /usr/bin/GET is not CHAR FILE !!! NOK: /usr/bin/GET is not SOCKET !!! NOK: /usr/bin/GET is not SYMLINK !!! OK: /usr/bin/GET is REGULAR FILE OK: /usr/bin/GET is SCRIPT OK: /usr/bin/GET is NOT EMPTY OK: /usr/bin/GET is READABLE NOK: /usr/bin/GET is not WRITABLE !!! OK: /usr/bin/GET is EXECUTABLE NOK: /usr/bin/GET Age of file (at script startup) in days since modification. NOK: /usr/bin/GET It is a binary file. OK: /usr/bin/GET Age of file (at script startup) in days since modification. OK: /usr/bin/GET Age of file (at script startup) in days since modification. NOK: /usr/bin/GET The file is owned by the real user ID. OK: /usr/bin/GET The file is readable by the real user ID or real group. NOK: /usr/bin/GET The file is a socket. OK: /usr/bin/GET It is a text file. NOK: /usr/bin/GET The file is writable by the real user ID or real group. OK: /usr/bin/GET The file is executable by the real user ID or real group. NOK: /usr/bin/GET It is a block special file. NOK: /usr/bin/GET It is a character special file. NOK: /usr/bin/GET The file is a directory. OK: /usr/bin/GET The file does exist. OK: /usr/bin/GET It is a plain file. NOK: /usr/bin/GET The file does have the setgid bit set. NOK: /usr/bin/GET The file does have the sticky bit set. NOK: /usr/bin/GET The file is a symbolic link. NOK: /usr/bin/GET The file is owned by the effective user ID. NOK: /usr/bin/GET The file is a named pipe. OK: /usr/bin/GET The file is readable by the effective user or group ID. OK: /usr/bin/GET Returns the size of the file, zero size = empty file. NOK: /usr/bin/GET The filehandle is opened by a TTY (terminal). NOK: /usr/bin/GET The is does file have the setuid bit set. NOK: /usr/bin/GET The file is writable by the effective user or group ID. OK: /usr/bin/GET The file is executable by the effective user or group ID. NOK: /usr/bin/GET The file is size zero. filename=/usr/bin/perl: OK: /usr/bin/perl EXISTS NOK: /usr/bin/perl is not DIRECTORY !!! NOK: /usr/bin/perl is not BLOCK FILE !!! NOK: /usr/bin/perl is not CHAR FILE !!! NOK: /usr/bin/perl is not SOCKET !!! NOK: /usr/bin/perl is not SYMLINK !!! OK: /usr/bin/perl is REGULAR FILE NOK: /usr/bin/perl is not SCRIPT !!! OK: /usr/bin/perl is NOT EMPTY OK: /usr/bin/perl is READABLE NOK: /usr/bin/perl is not WRITABLE !!! OK: /usr/bin/perl is EXECUTABLE NOK: /usr/bin/perl Age of file (at script startup) in days since modification. OK: /usr/bin/perl It is a binary file. OK: /usr/bin/perl Age of file (at script startup) in days since modification. OK: /usr/bin/perl Age of file (at script startup) in days since modification. NOK: /usr/bin/perl The file is owned by the real user ID. OK: /usr/bin/perl The file is readable by the real user ID or real group. NOK: /usr/bin/perl The file is a socket. NOK: /usr/bin/perl It is a text file. NOK: /usr/bin/perl The file is writable by the real user ID or real group. OK: /usr/bin/perl The file is executable by the real user ID or real group. NOK: /usr/bin/perl It is a block special file. NOK: /usr/bin/perl It is a character special file. NOK: /usr/bin/perl The file is a directory. OK: /usr/bin/perl The file does exist. OK: /usr/bin/perl It is a plain file. NOK: /usr/bin/perl The file does have the setgid bit set. NOK: /usr/bin/perl The file does have the sticky bit set. NOK: /usr/bin/perl The file is a symbolic link. NOK: /usr/bin/perl The file is owned by the effective user ID. NOK: /usr/bin/perl The file is a named pipe. OK: /usr/bin/perl The file is readable by the effective user or group ID. OK: /usr/bin/perl Returns the size of the file, zero size = empty file. NOK: /usr/bin/perl The filehandle is opened by a TTY (terminal). NOK: /usr/bin/perl The is does file have the setuid bit set. NOK: /usr/bin/perl The file is writable by the effective user or group ID. OK: /usr/bin/perl The file is executable by the effective user or group ID. NOK: /usr/bin/perl The file is size zero.
#top open¶
Documentacja online: perldoc.perl.org | www.tutorialspoint.com
Deklaracja funkcji
open()
jest następująca:open FILEHANDLE, EXPR open FILEHANDLE
Powiązane:
close(), open(),
Opis:
description
Example:
zawartość pliku
open.pl
SELECT ALL
#!/usr/bin/perl -w use strict; # force definations for all vars an subroutines use warnings; # force check of unset variables in expressions use diagnostics; # give var/code line number on faults if ($#ARGV+1<1) { print("Usage: $0 </path/to/prefix-file>\n"); print("Examples:\n"); print(" $0 /home/local/code/perlcode/sysfile/open\n"); print(" It will be usage following files:\n"); print(" /home/local/code/perlcode/sysfile/open-read.txt # (need file to be exists (if not exists create them manually))\n"); print(" /home/local/code/perlcode/sysfile/open-write.txt # (if not exists it will be created)\n"); print(" /home/local/code/perlcode/sysfile/open-append.txt # (if not exists it will be created)\n"); exit(1); } my ($workdir, $fileopen, $filewrite, $fileappend); $fileopen=$ARGV[0].'-read.txt'; $filewrite=$ARGV[0].'-write.txt'; $fileappend=$ARGV[0].'-append.txt'; $workdir=$ARGV[0]; $workdir=~s,/[^/]*$,,g; my ($FHRD, $FHWR, $FHWA, $line); if (-e $fileopen && -f $fileopen) { if (-r $fileopen) { if (open($FHRD,$fileopen)) { printn"$0: if (open($FHRD,$fileopen)): Successful opened file '$fileopen' for read.\n"); while ($line=<$FHRD>) { $line=~s,[\r\n]*$,,g; printi"$0: line=|$line|\n"); } printn"$0: close($FHWR):\n"); close($FHRD); } else { print(STDERRRR "$0: "$0: Unable to open file '$fileopen' for read, Reason $!\n"); } if (open($FHRD,"<$fileopen")) { printn"$0: if (open($FHRD,\"<$fileopen\")): Successful opened file '$fileopen' for read.\n"); while ($line=<$FHRD>) { $line=~s,[\r\n]*$,,g; printi"$0: line=|$line|\n"); } printn"$0: close($FHWR):\n"); close($FHRD); } else { print(STDERRRR "$0: "$0: Unable to open file '$fileopen' for read, Reason $!\n"); } if (open($FHRD,'<',$fileopen)) { printn"$0: if (open($FHRD,'<',$fileopen)): Successful opened file '$fileopen' for read.\n"); while ($line=<$FHRD>) { $line=~s,[\r\n]*$,,g; printi"$0: line=|$line|\n"); } printn"$0: close($FHWR):\n"); close($FHRD); } else { print(STDERRRR "$0: "$0: Unable to open file '$fileopen' for read, Reason $!\n"); } } else { print(STDERRR "$0: E"$0: Entry '$fileopen' exists but is not readable!\n"); } } else { print(STDERR "$0: En"$0: Entry '$fileopen' does not exists or not a file.\n"); } if (-e $workdir && -d $workdir) { if (-w $workdir) { if (open($FHWR,">$filewrite")) { printn"$0: if (open($FHWR,\">$filewrite\")): Successful opened file '$filewrite' for write.\n"); printn"$0: close($FHWR):\n"); print($FHWRWR "ope"open(HANDLE,\">$filewrite\"):write:line1\n"); print($FHWRWR "ope"open(HANDLE,\">$filewrite\"):write:line2\n"); print($FHWRWR "ope"open(HANDLE,\"$filewrite\"):write:line3\n"); printn"$0: close($FHWR):\n"); close($FHWR); } else { print(STDERRRR "$0: "$0: if (open($FHWR,\">$filewrite\")): else: Unable to open file '$filewrite' for write, Reason $!\n"); } if (open($FHWR,'>',$filewrite)) { printn"$0: if (open($FHWR,'>',$filewrite)): Successful opened file '$filewrite' for write.\n"); print($FHWRWR "ope"open(HANDLE,'>',$filewrite):write:line1\n"); print($FHWRWR "ope"open(HANDLE,'>',$filewrite):write:line2\n"); print($FHWRWR "ope"open(HANDLE,'>',$filewrite):write:line3\n"); printn"$0: close($FHWR):\n"); close($FHWR); } else { print(STDERRRR "$0: "$0: if (open($FHWR,'>',$filewrite)): if (open($FHWR,'>',$filewrite)): else: Unable to open file '$filewrite' for write, Reason $!\n"); } } else { print(STDERRR "$0: D"$0: Directory '$workdir' exists but is not writable!\n"); } } else { print(STDERR "$0: En"$0: Entry '$fileopen' does not exists or not a directory.\n"); } if (-e $workdir && -d $workdir) { if (-w $workdir) { if (open($FHWA,">>$fileappend")) { printn"$0: if (open($FHWA,\">>$fileappend\")): Successful opened file '$fileappend' for append.\n"); print($FHWAWA "ope"open(HANDLE,\">>$fileappend\"):append:line1\n"); print($FHWAWA "ope"open(HANDLE,\">>$fileappend\"):append:line2\n"); print($FHWAWA "ope"open(HANDLE,\">>$fileappend\"):append:line3\n"); printn"$0: close($FHWA):\n"); close($FHWA); } else { print(STDERRRR "$0: "$0: if (open($FHWR,\">>$fileappend\")): else: Unable to open file '$fileappend' for append, Reason $!\n"); } if (open($FHWA,'>>',$fileappend)) { printn"$0: if (open($FHWA,'>>',$fileappend)): Successful opened file '$fileappend' for append.\n"); print($FHWAWA "ope"open(HANDLE,'>>',$fileappend):append:line1\n"); print($FHWAWA "ope"open(HANDLE,'>>',$fileappend):append:line2\n"); print($FHWAWA "ope"open(HANDLE,'>>',$fileappend):append:line3\n"); printn"$0: close($FHWA):\n"); close($FHWA); } else { print(STDERRRR "$0: "$0: if (open($FHWR,'>>',$fileappend)): else: Unable to open file '$fileappend' for append, Reason $!\n"); } } else { printt"$0: Directory '$workdir' exists but is not writable!\n"); } } else { print(STDERR "$0: En"$0: Entry '$fileopen' does not exists or not a directory.\n"); }
Aby zobaczyć jak działa program należy go uruchomić bez argumentów:
/home/local/code/perlcode/sysfile/open.plprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/perlcode/sysfile/open.pl </path/to/prefix-file> Examples: /home/local/code/perlcode/sysfile/open.pl /home/local/code/perlcode/sysfile/open It will be usage following files: /home/local/code/perlcode/sysfile/open-read.txt # (need file to be exists (if not exists create them manually)) /home/local/code/perlcode/sysfile/open-write.txt # (if not exists it will be created) /home/local/code/perlcode/sysfile/open-append.txt # (if not exists it will be created)
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/perlcode/sysfile/open.pl /home/local/code/perlcode/sysfile/openrezultat będzie zależny od podanego argumentu wywołania programu:
/home/local/code/perlcode/sysfile/open.pl: if (open(GLOB(0x989edd8),/home/local/code/perlcode/sysfile/open-read.txt)): Successful opened file '/home/local/code/perlcode/sysfile/open-read.txt' for read. /home/local/code/perlcode/sysfile/open.pl: line=|open:read:line1| /home/local/code/perlcode/sysfile/open.pl: line=|open:read:line2| /home/local/code/perlcode/sysfile/open.pl: line=|open:read:line3| /home/local/code/perlcode/sysfile/open.pl: close(GLOB(0x989edd8)): /home/local/code/perlcode/sysfile/open.pl: if (open(GLOB(0x989edd8),"</home/local/code/perlcode/sysfile/open-read.txt")): Successful opened file '/home/local/code/perlcode/sysfile/open-read.txt' for read. /home/local/code/perlcode/sysfile/open.pl: line=|open:read:line1| /home/local/code/perlcode/sysfile/open.pl: line=|open:read:line2| /home/local/code/perlcode/sysfile/open.pl: line=|open:read:line3| /home/local/code/perlcode/sysfile/open.pl: close(GLOB(0x989edd8)): /home/local/code/perlcode/sysfile/open.pl: if (open(GLOB(0x989edd8),'<',/home/local/code/perlcode/sysfile/open-read.txt)): Successful opened file '/home/local/code/perlcode/sysfile/open-read.txt' for read. /home/local/code/perlcode/sysfile/open.pl: line=|open:read:line1| /home/local/code/perlcode/sysfile/open.pl: line=|open:read:line2| /home/local/code/perlcode/sysfile/open.pl: line=|open:read:line3| /home/local/code/perlcode/sysfile/open.pl: close(GLOB(0x989edd8)): /home/local/code/perlcode/sysfile/open.pl: if (open(GLOB(0x989f8e8),">/home/local/code/perlcode/sysfile/open-write.txt")): Successful opened file '/home/local/code/perlcode/sysfile/open-write.txt' for write. /home/local/code/perlcode/sysfile/open.pl: close(GLOB(0x989f8e8)): /home/local/code/perlcode/sysfile/open.pl: close(GLOB(0x989f8e8)): /home/local/code/perlcode/sysfile/open.pl: if (open(GLOB(0x989f8e8),'>',/home/local/code/perlcode/sysfile/open-write.txt)): Successful opened file '/home/local/code/perlcode/sysfile/open-write.txt' for write. /home/local/code/perlcode/sysfile/open.pl: close(GLOB(0x989f8e8)): /home/local/code/perlcode/sysfile/open.pl: if (open(GLOB(0x98e8ee0),">>/home/local/code/perlcode/sysfile/open-append.txt")): Successful opened file '/home/local/code/perlcode/sysfile/open-append.txt' for append. /home/local/code/perlcode/sysfile/open.pl: close(GLOB(0x98e8ee0)): /home/local/code/perlcode/sysfile/open.pl: if (open(GLOB(0x98e8ee0),'>>',/home/local/code/perlcode/sysfile/open-append.txt)): Successful opened file '/home/local/code/perlcode/sysfile/open-append.txt' for append. /home/local/code/perlcode/sysfile/open.pl: close(GLOB(0x98e8ee0)):
#top print¶
Documentacja online: perldoc.perl.org | www.tutorialspoint.com
Deklaracja funkcji
print()
jest następująca:print FILEHANDLE LIST print LIST print
Powiązane:
FILEHANDLE Operator, print(), read(),
Opis:
description
Example:
zawartość pliku
print.pl
SELECT ALL
#!/usr/bin/perl -w use strict; # force definations for all vars an subroutines use warnings; # force check of unset variables in expressions use diagnostics; # give var/code line number on faults if ($#ARGV+1<1) { print("Usage: $0 </path/to/file>\n"); print("Examples:\n"); print(" $0 /home/local/code/perlcode/sysfile/print-write\n"); exit(1); } my ($workdir, $filewrite); $filewrite=$ARGV[0]; $workdir=$ARGV[0]; $workdir=~s,/[^/]*$,,g; my ($FHWR, $data, $result); if (-e $workdir && -d $workdir) { if (-w $workdir) { if (open($FHWR,'>',$filewrite)) { printn"$0: if (open($FHWR,'>',$filewrite)): Successful opened file '$filewrite' for write.\n"); $data=''; $data.='#!/usr/bin/perl -w'."\n"; $data.="\n"; $data.='use strict; # force definations for all vars an subroutines'."\n"; $data.='use warnings; # force check of unset variables in expressions'."\n"; $data.='use diagnostics; # give var/code line number on faults'."\n"; $data.="\n"; $data.="\n"; $data.="\n"; $data.='my $filewrite=$ARGV[0];'."\n"; $data.="\n"; $data.='if (open($FHWR,\'>\',$filewrite)) {'."\n"; $data.="\t".'$data="data content write for write to file";'."\n"; $data.="\t".'$result=write($FHWR, $data);'."\n"; $data.="\t".'close($FHWR);'."\n"; $data.='} else {'."\n"; $data.="\t".'print(STDERR "$0: if (open($FHWR,\'>\',$filewrite)): else: Unable to open file \'$filewrite\' for write, Reason $!\n");'."\n"; $data.='}'."\n"; $data.="\n"; $data.="\n"; #write($data); print($FHWR $data); printn"$0: close($FHWR):\n"); close($FHWR); } else { print(STDERRRR "$0: "$0: if (open($FHWR,'>',$filewrite)): else: Unable to open file '$filewrite' for write, Reason $!\n"); } } else { print(STDERRR "$0: D"$0: Directory '$workdir' exists but is not writable!\n"); } } else { print(STDERR "$0: En"$0: Entry '$workdir' does not exists or not a directory.\n"); }
Aby zobaczyć jak działa program należy go uruchomić bez argumentów:
/home/local/code/perlcode/sysfile/print.plprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/perlcode/sysfile/print.pl </path/to/file> Examples: /home/local/code/perlcode/sysfile/print.pl /home/local/code/perlcode/sysfile/print-write
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/perlcode/sysfile/print.pl /home/local/code/perlcode/sysfile/print-writerezultat będzie zależny od podanego argumentu wywołania programu:
/home/local/code/perlcode/sysfile/print.pl: if (open(GLOB(0x8cefdd8),'>',/home/local/code/perlcode/sysfile/print-write)): Successful opened file '/home/local/code/perlcode/sysfile/print-write' for write. /home/local/code/perlcode/sysfile/print.pl: close(GLOB(0x8cefdd8)):oraz zostanie utworzony plik
ls -l /home/local/code/perlcode/sysfile/print-write
:-rw-r--r-- 1 user users 489 2013-10-09 00:41 /home/local/code/perlcode/sysfile/print-writezawierający następującą zawartość
cat /home/local/code/perlcode/sysfile/print-write
:#!/usr/bin/perl -w use strict; # force definations for all vars an subroutines use warnings; # force check of unset variables in expressions use diagnostics; # give var/code line number on faults my $filewrite=$ARGV[0]; if (open($FHWR,'>',$filewrite)) { $data="data content write for write to file"; $result=write($FHWR, $data); close($FHWR); } else { print(STDERR "$0: if (open($FHWR,'>',$filewrite)): else: Unable to open file '$filewrite' for write, Reason $!\n"); }
#top read¶
Documentacja online: perldoc.perl.org | www.tutorialspoint.com
Deklaracja funkcji
read()
jest następująca:read FILEHANDLE, SCALAR, LENGTH, OFFSET read FILEHANDLE, SCALAR, LENGTH
Powiązane:
FILEHANDLE Operator, print(), read(),
Opis:
description
Example:
zawartość pliku
read.pl
SELECT ALL
#!/usr/bin/perl -w use strict; # force definations for all vars an subroutines use warnings; # force check of unset variables in expressions use diagnostics; # give var/code line number on faults if ($#ARGV+1<1) { print("Usage: $0 </path/to/file>\n"); print("Examples:\n"); print(" $0 /home/local/code/perlcode/sysfile/read.pl\n"); exit(1); } my ($fileopen); my ($FHRD, $data, $result); $fileopen=$ARGV[0]; if (-e $fileopen && -f $fileopen) { if (-r $fileopen) { if (open($FHRD,$fileopen)) { printn"$0: if (open($FHRD,$fileopen)): Successful opened file '$fileopen' for read.\n"); printn"$0: \$result=read($FHRD,\$data,64):\n"); $result=read($FHRD, $data, 64); printn"$0: \$result=read($FHRD,\$data,64): \$result=$result \$data=|$data|\n"); printn"$0: close($FHRD):\n"); close($FHRD); } else { print(STDERRRR "$0: "$0: Unable to open file '$fileopen' for read, Reason $!\n"); } } else { print(STDERRR "$0: E"$0: Entry '$fileopen' exists but is not readable!\n"); } } else { print(STDERR "$0: En"$0: Entry '$fileopen' does not exists or not a file.\n"); }
Aby zobaczyć jak działa program należy go uruchomić bez argumentów:
/home/local/code/perlcode/sysfile/read.plprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/perlcode/sysfile/read.pl </path/to/file> Examples: /home/local/code/perlcode/sysfile/read.pl /home/local/code/perlcode/sysfile/read.pl
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/perlcode/sysfile/read.pl /home/local/code/perlcode/sysfile/read.plrezultat będzie zależny od podanego argumentu wywołania programu:
/home/local/code/perlcode/sysfile/read.pl: if (open(GLOB(0x9b5cdd8),/home/local/code/perlcode/sysfile/read.pl)): Successful opened file '/home/local/code/perlcode/sysfile/read.pl' for read. /home/local/code/perlcode/sysfile/read.pl: $result=read(GLOB(0x9b5cdd8),$data,64): /home/local/code/perlcode/sysfile/read.pl: $result=read(GLOB(0x9b5cdd8),$data,64): $result=64 $data=|#!/usr/bin/perl -w use strict; # force definations for all| /home/local/code/perlcode/sysfile/read.pl: close(GLOB(0x9b5cdd8)):
#top seek¶
Documentacja online: perldoc.perl.org | www.tutorialspoint.com
Deklaracja funkcji
seek()
jest następująca:seek FILEHANDLE, POSITION, WHENCE
Powiązane:
seek(), tell(),
Opis:
description
Example:
zawartość pliku
seek.pl
SELECT ALL
#!/usr/bin/perl -w use strict; # force definations for all vars an subroutines use warnings; # force check of unset variables in expressions use diagnostics; # give var/code line number on faults use POSIX qw(SEEK_SET SEEK_CUR SEEK_END); if ($#ARGV+1<1) { print("Usage: $0 </path/to/file>\n"); print("Examples:\n"); print(" $0 /home/local/code/perlcode/sysfile/seek.pl\n"); exit(1); } my ($fileopen); my ($FHRD, $data, $result); $fileopen=$ARGV[0]; if (-e $fileopen && -f $fileopen) { if (-r $fileopen) { if (open($FHRD,$fileopen)) { printn"$0: if (open($FHRD,$fileopen)): Successful opened file '$fileopen' for read.\n"); $result=seek($FHRD, 0, SEEK_SET); if (int($result)>0) { print("$0: \$result=seek($FHRD, 0, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_SET)\n"); } else { print("$0: \$result=seek($FHRD, 0, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_SET), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, 12, SEEK_SET); if (int($result)>0) { print("$0: \$result=seek($FHRD, 12, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_SET)\n"); } else { print("$0: \$result=seek($FHRD, 12, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_SET), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, 8, SEEK_SET); if (int($result)>0) { print("$0: \$result=seek($FHRD, 8, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_SET)\n"); } else { print("$0: \$result=seek($FHRD, 8, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_SET), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, -4, SEEK_SET); if (int($result)>0) { print("$0: \$result=seek($FHRD, -4, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_SET)\n"); } else { print("$0: \$result=seek($FHRD, -4, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_SET), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, 10000, SEEK_SET); if (int($result)>0) { print("$0: \$result=seek($FHRD, 10000, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_SET)\n"); } else { print("$0: \$result=seek($FHRD, 10000, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_SET), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, -20000, SEEK_SET); if (int($result)>0) { print("$0: \$result=seek($FHRD, -20000, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_SET)\n"); } else { print("$0: \$result=seek($FHRD, -20000, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_SET), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, 0, SEEK_SET); if (int($result)>0) { print("$0: \$result=seek($FHRD, 0, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_SET)\n"); } else { print("$0: \$result=seek($FHRD, 0, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_SET), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, 0, SEEK_CUR); if (int($result)>0) { print("$0: \$result=seek($FHRD, 0, SEEK_CUR=".SEEK_CUR."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_CUR)\n"); } else { print("$0: \$result=seek($FHRD, 0, SEEK_CUR=".SEEK_CUR."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_CUR), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, 12, SEEK_CUR); if (int($result)>0) { print("$0: \$result=seek($FHRD, 12, SEEK_CUR=".SEEK_CUR."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_CUR)\n"); } else { print("$0: \$result=seek($FHRD, 12, SEEK_CUR=".SEEK_CUR."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_CUR), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, 8, SEEK_CUR); if (int($result)>0) { print("$0: \$result=seek($FHRD, 8, SEEK_CUR=".SEEK_CUR."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_CUR)\n"); } else { print("$0: \$result=seek($FHRD, 8, SEEK_CUR=".SEEK_CUR."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_CUR), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, -4, SEEK_CUR); if (int($result)>0) { print("$0: \$result=seek($FHRD, -4, SEEK_CUR=".SEEK_CUR."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_CUR)\n"); } else { print("$0: \$result=seek($FHRD, -4, SEEK_CUR=".SEEK_CUR."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_CUR), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, 10000, SEEK_CUR); if (int($result)>0) { print("$0: \$result=seek($FHRD, 10000, SEEK_CUR=".SEEK_CUR."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_CUR)\n"); } else { print("$0: \$result=seek($FHRD, 10000, SEEK_CUR=".SEEK_CUR."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_CUR), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, -20000, SEEK_CUR); if (int($result)>0) { print("$0: \$result=seek($FHRD, -20000, SEEK_CUR=".SEEK_CUR."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_CUR)\n"); } else { print("$0: \$result=seek($FHRD, -20000, SEEK_CUR=".SEEK_CUR."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_CUR), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, 0, SEEK_SET); if (int($result)>0) { print("$0: \$result=seek($FHRD, 0, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_SET)\n"); } else { print("$0: \$result=seek($FHRD, 0, SEEK_SET=".SEEK_SET."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_SET), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, 0, SEEK_END); if (int($result)>0) { print("$0: \$result=seek($FHRD, 0, SEEK_END=".SEEK_END."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_END)\n"); } else { print("$0: \$result=seek($FHRD, 0, SEEK_END=".SEEK_END."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_END), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, 12, SEEK_END); if (int($result)>0) { print("$0: \$result=seek($FHRD, 12, SEEK_END=".SEEK_END."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_END)\n"); } else { print("$0: \$result=seek($FHRD, 12, SEEK_END=".SEEK_END."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_END), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, 8, SEEK_END); if (int($result)>0) { print("$0: \$result=seek($FHRD, 8, SEEK_END=".SEEK_END."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_END)\n"); } else { print("$0: \$result=seek($FHRD, 8, SEEK_END=".SEEK_END."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_END), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, -4, SEEK_END); if (int($result)>0) { print("$0: \$result=seek($FHRD, -4, SEEK_END=".SEEK_END."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_END)\n"); } else { print("$0: \$result=seek($FHRD, -4, SEEK_END=".SEEK_END."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_END), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, 10000, SEEK_END); if (int($result)>0) { print("$0: \$result=seek($FHRD, 10000, SEEK_END=".SEEK_END."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_END)\n"); } else { print("$0: \$result=seek($FHRD, 10000, SEEK_END=".SEEK_END."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_END), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); $result=seek($FHRD, -20000, SEEK_END); if (int($result)>0) { print("$0: \$result=seek($FHRD, -20000, SEEK_END=".SEEK_END."); \$result=$result if (int(\$result)>0): Successful seek(SEEK_END)\n"); } else { print("$0: \$result=seek($FHRD, -20000, SEEK_END=".SEEK_END."); \$result=$result if (int(\$result)>0): else: Unable to seek(SEEK_END), Reason=$!\n"); } $result=tell($FHRD); printn"$0: \$result=ftell($FHRD): \$result=$result\n"); printn"$0: close($FHRD):\n"); close($FHRD); } else { print(STDERRRR "$0: "$0: Unable to open file '$fileopen' for read, Reason $!\n"); } } else { print(STDERRR "$0: E"$0: Entry '$fileopen' exists but is not readable!\n"); } } else { print(STDERR "$0: En"$0: Entry '$fileopen' does not exists or not a file.\n"); }
Aby zobaczyć jak działa program należy go uruchomić bez argumentów:
/home/local/code/perlcode/sysfile/seek.plprogram wyświetli informacje o sposobie uruchamiania programu:
Usage: /home/local/code/perlcode/sysfile/seek.pl </path/to/file> Examples: /home/local/code/perlcode/sysfile/seek.pl /home/local/code/perlcode/sysfile/seek.pl
jako argument wywołania programu można podać analogiczne jak poniżej argumenty:
/home/local/code/perlcode/sysfile/seek.pl /home/local/code/perlcode/sysfile/seek.plrezultat będzie zależny od podanego argumentu wywołania programu:
/home/local/code/perlcode/sysfile/seek.pl: if (open(GLOB(0x8613dd8),/home/local/code/perlcode/sysfile/seek.pl)): Successful opened file '/home/local/code/perlcode/sysfile/seek.pl' for read. /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), 0, SEEK_SET=0); $result=1 if (int($result)>0): Successful seek(SEEK_SET) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=0 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), 12, SEEK_SET=0); $result=1 if (int($result)>0): Successful seek(SEEK_SET) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=12 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), 8, SEEK_SET=0); $result=1 if (int($result)>0): Successful seek(SEEK_SET) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=8 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), -4, SEEK_SET=0); $result= if (int($result)>0): else: Unable to seek(SEEK_SET), Reason=Invalid argument /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=8 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), 10000, SEEK_SET=0); $result=1 if (int($result)>0): Successful seek(SEEK_SET) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=10000 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), -20000, SEEK_SET=0); $result= if (int($result)>0): else: Unable to seek(SEEK_SET), Reason=Invalid argument /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=10000 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), 0, SEEK_SET=0); $result=1 if (int($result)>0): Successful seek(SEEK_SET) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=0 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), 0, SEEK_CUR=1); $result=1 if (int($result)>0): Successful seek(SEEK_CUR) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=0 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), 12, SEEK_CUR=1); $result=1 if (int($result)>0): Successful seek(SEEK_CUR) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=12 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), 8, SEEK_CUR=1); $result=1 if (int($result)>0): Successful seek(SEEK_CUR) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=20 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), -4, SEEK_CUR=1); $result=1 if (int($result)>0): Successful seek(SEEK_CUR) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=16 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), 10000, SEEK_CUR=1); $result=1 if (int($result)>0): Successful seek(SEEK_CUR) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=10016 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), -20000, SEEK_CUR=1); $result= if (int($result)>0): else: Unable to seek(SEEK_CUR), Reason=Invalid argument /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=10016 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), 0, SEEK_SET=0); $result=1 if (int($result)>0): Successful seek(SEEK_SET) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=0 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), 0, SEEK_END=2); $result=1 if (int($result)>0): Successful seek(SEEK_END) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=10160 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), 12, SEEK_END=2); $result=1 if (int($result)>0): Successful seek(SEEK_END) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=10172 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), 8, SEEK_END=2); $result=1 if (int($result)>0): Successful seek(SEEK_END) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=10168 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), -4, SEEK_END=2); $result=1 if (int($result)>0): Successful seek(SEEK_END) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=10156 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), 10000, SEEK_END=2); $result=1 if (int($result)>0): Successful seek(SEEK_END) /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=20160 /home/local/code/perlcode/sysfile/seek.pl: $result=seek(GLOB(0x8613dd8), -20000, SEEK_END=2); $result= if (int($result)>0): else: Unable to seek(SEEK_END), Reason=Invalid argument /home/local/code/perlcode/sysfile/seek.pl: $result=ftell(GLOB(0x8613dd8)): $result=20160 /home/local/code/perlcode/sysfile/seek.pl: close(GLOB(0x8613dd8)):
#top tell¶
Documentacja online: perldoc.perl.org | www.tutorialspoint.com
Deklaracja funkcji
tell()
jest następująca:tell FILEHANDLE tell
Powiązane:
seek(), tell(),
Opis:
description
Zmodyfikowany ostatnio: 2014/09/02 09:58:11 (10 lat temu),
textsize: 70,6 kB,
htmlsize: 116 kB
Zapraszam do komentowania, zgłaszania sugestii, propozycji, własnych przykładów, ...
Dodaj komentarzKomentarze użytkowników