Web Page - http://www.cs.tau.ac.il/~efif/courses/Software1_Spring_04
CSOURCES = bfs.c memory_man.c
OBJECTS = $(CSOURCES:.c=.o)
TARGET = $(firstword $(CSOURCES:.c=))
CFLAGS = -Wall -pedantic
$(TARGET): $(OBJECTS)
clean:
rm -rf $(OBJECTS) $(TARGET)
|
%.o : %.c $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ |
bfs: bfs.o memory_man.o
$(CC) $(LDFLAGS) $? $(LOADLIBES) $(LDLIBS) -o $@
|
.DELETE_ON_ERROR: *.e |
die LIST
LIST to
STDERR and exits with the current value of $!
(errno).
openFILEHANDLE,EXPRopenFILEHANDLE
EXPR, and
associates it with FILEHANDLE
EXPR is omitted, the scalar variable of the same
name as the FILEHANDLE must contain the filename
open(INST_H, ">inst.h") or die "Failed to open inst.h: $!\n"; |
$ARTICLE = "/usr/spool/news/comp/lang/perl/misc/38245";
open ARTICLE or die "Can't find article $ARTICLE: $!\n";
while (<ARTICLE>) {...
|
@ARGV array is
checked, and if it is null, $ARGV[0] is set to "-",
which when opened gives you standard input.
@ARGV array is then processed as a list of filenames.
while (<>) {
... # code for each line
}
|
split/PATTERN/,EXPR
EXPR for delimiters, and
splits the string into a list of substrings, returning the resulting list
value in list context,
($token1, $token3, $token4) = split(" ", $line);
|
FILEHANDLELISTprintLISTprint printfFILEHANDLEFORMATLISTprintfFORMATLIST
print prints a string or a comma-separated list of strings
to FILEHANDLE or, if omitted, the currently selected
output filehandle, initially STDOUT.
printf prints a formatted string
printf SOMEHANDLE "some tokens: %s %s %s\n", $token1, $token2, $token3; |
| decimal | hex | bit pattern | bit number |
|---|---|---|---|
| 1 | 0x0001 | 00000000 00000001 | 0 |
| 2 | 0x0002 | 00000000 00000010 | 1 |
| 4 | 0x0004 | 00000000 00000100 | 2 |
| 8 | 0x0008 | 00000000 00001000 | 3 |
| 16 | 0x0010 | 00000000 00010000 | 4 |
| 32 | 0x0020 | 00000000 00100000 | 5 |
| 64 | 0x0040 | 00000000 01000000 | 6 |
| 128 | 0x0080 | 00000000 10000000 | 7 |
| 256 | 0x0100 | 00000001 00000000 | 8 |
| 512 | 0x0200 | 00000010 00000000 | 9 |
| 1024 | 0x0400 | 00000100 00000000 | 10 |
| 2048 | 0x0800 | 00001000 00000000 | 11 |
| 4096 | 0x1000 | 00010000 00000000 | 12 |
| 8192 | 0x2000 | 00100000 00000000 | 13 |
| 16384 | 0x4000 | 01000000 00000000 | 14 |
| 32768 | 0x8000 | 10000000 00000000 | 15 |