Perl is the camel of languages: useful, but not always beautiful. It has rather good documentation of its own which can be accessed using the perldoc
command from your shell/command prompt. It's also available online at perldoc.perl.org.
Perl does not have a boolean data type, nor does it have any true
and false
keywords like many other languages. However, every scalar value will evaluate to true or false when evaluated in a boolean context (the condition in an if statement or a while loop, for example).
''
, the empty string. This is what the built-in comparison operators return (e.g. 0 == 1
)0
, the number 0, even if you write it as 000 or 0.0'0'
, the string that contains a single 0 digitundef
, the undefined valueJSON::false
1
, 3.14
, 'NaN'
or 'Inf'
'0'
, such as '00'
, '0e0'
, "0\n"
and "abc"
.'0E0'
(used by well known modules) or '0 but true'
(used by Perl functions)' '
, 'false'
\''
, []
, or {}
@a
returns whether the array is empty or not
%h
returns whether the hash is empty or not
grep
returns whether any matching items were found or not
@a = LIST
and (LIST) = LIST
return whether the right-hand side LIST produced any scalars or not
Subroutines get their arguments to magic variable called @_
. While it doesn't have to be unpacked, it's recommended, as it helps readability, and prevents accidental changes as arguments of @_
are passed by reference (can be modified).
chomp
is often used when reading from a file. By default it trims the newline character, although for its full functionality refer to the perldocs.
Beware of the difference between characters and bytes: Not all encodings - especially UTF-8 - use 1-byte-characters. While this is handled pretty much flawlessly by PerlIO, there is one potential pitfall of note:
read
uses characters for its length and offset parametersseek
and tell
always use bytes for positioningSo don't use arithmetics based on these mixed values. Instead use e.g. Encode::encode('utf8',$value_by_read)
to get the octets(bytes) from a read
result, whose count you can then use with tell
and seek
.
The version syntax doesn't allow us to guard off versions that don't exist yet, so this is a reminder for somebody to go back and edit them in once it lands( RE: Perl 5.26 ). The version guards rather need to have a "future" classification for tentative features that might be available to people brave enough to do a source checkout.
Link for information about Colors on Excel: http://dmcritchie.mvps.org/excel/colors.htm
Link for information about Excel constants: http://msdn.microsoft.com/en-us/library/aa221100%28office.11%29.aspx
Links from Win32::OLE module: http://search.cpan.org/~jdb/Win32-OLE-0.1712/lib/Win32/OLE.pm#EXAMPLES
Useful information about usage of Excel can be found at this address
It should be worth mentioning that Filename Encoding is not only platform specific but also filesystem specific.
It is never entirely safe to assume (but often usually is) that just because you can encode and write to a given filename, that when you later try to open that same filename for reading, it will still be called the same thing.
For instance, if you write to a filesystem such as FAT16
which doesn't support unicode, your filenames might silently get translated into ASCII-compatible forms.
But it is even less safe to assume that a file you can create, read and write to by explicit naming will be called the same thing when queried through other calls, for instance, readdir
might return different bytes for your filename than you specified to open
.
On some systems such as VAX, you can't even always assume that readdir
will return the same filename you specified with open
for filenames as simple as foo.bar
, because filename extensions can be mangled by the OS.
Also, on UNIX, there is a very liberal set of legal characters for filenames that the OS permits, excluding only /
and \0
, where as on Windows, there are specific ranges of characters that are forbidden in filenames and will cause errors.
Exercise much caution here, avoid fancy tricks with filenames if you have a choice, and always have tests to make sure any fancy tricks you do use are consistent.
Exercise doubly as much caution if you're writing code intended to be run on platforms outside your control, such as if you're writing code that is intended for CPAN
, and assume at least 5% of your user base will be stuck using some ancient or broken technology, either by choice, by accident, or by powers outside their control, and that these will conspire to create bugs for them.
Since UTF-8 is one of the internal formats for representation of strings in Perl, the encoding/decoding step may often be skipped. Instead of :encoding(utf-8)
, you can simply use :utf8
, if your data is already in UTF-8. :utf8
can be used safely with output streams, whereas for input stream it can be dangerous, because it causes internal inconsistency when you have invalid byte sequences. Also, using :utf8
for input may result in security breaches, so the use of :encoding(utf-8)
is advisable.
More details: What is the difference between :encoding and :utf8
As of Perl v5.8.7
, "UTF-8"
(with dash) means UTF-8 in its strict and security-conscious form, whereas "utf8"
means UTF-8 in its liberal and loose form.
For example, "utf8"
can be used for code points that don't exist in Unicode, like 0xFFFFFFFF
. Correspondingly, invalid UTF-8 byte sequences like "\x{FE}\x{83}\x{BF}\x{BF}\x{BF}\x{BF}\x{BF}"
will decode into an invalid Unicode (but valid Perl) codepoint (0xFFFFFFFF
) when using "utf8"
, whereas the "UTF-8"
encoding would not allow decoding to codepoints outside the range of valid Unicode and would give you a substitution character (0xFFFD
) instead.
Since encoding names are case insensitive, "UTF8"
is the same as "utf8"
(i.e. non-strict variant).
More details: UTF-8 vs. utf8 vs. UTF8
Details about Perl's Unicode handling is described in more detail in the following sources:
Posts from stackoverflow.com (caveat: might not be up-to-date):
Youtube videos:
Tk is one of the most commonly used GUI toolkits for Perl. Other common toolkits are GTK+2 & 3, WxWidgets, and Win32 widgets. Less commonly used are Qt4, XUL, Prima, and FLTK.
Tk, GTK+3, Wx, Win32, Prima, FLTK, and XUL are actively updated. Qt4 and GTK+2 are no longer developed actively, but may have maintenance releases.
Documentation for perl's rand() function: http://perldoc.perl.org/functions/rand.html
TO DO : Add more contents.
Install a current Strawberry Perl 64 bit package from http://strawberryperl.com. In my case it was 5.24.1.1.
Download the current version of the SAP NW RFC SDK x64 bit from https://launchpad.support.sap.com/#/softwarecenter
You can find it with the following trace: Support Packages and Patches => By Category => Additional Components => SAP NW RFC SDK => SAP NW RFC SDK 7.20
In my case the current version was 7.20 PL42 x64.
Extract the downloaded file with
sapcar -xvf NWRFC_42-20004568.SAR
I renamed the folder to C:\nwrfcsdk_x64
Create .def and .a files for the MinGW compiler / linker with the following commands in the directory C:\nwrfcsdk_x64:
gendef *.dll
dlltool --dllname icuin34.dll --def icuin34.def --output-lib icuin34.a
dlltool --dllname icudt34.dll --def icudt34.def --output-lib icudt34.a
dlltool --dllname icuuc34.dll --def icuuc34.def --output-lib icuuc34.a
dlltool --dllname libsapucum.dll --def libsapucum.def --output-lib libsapucum.a
dlltool --dllname libicudecnumber.dll --def libicudecnumber.def --output-lib libicudecnumber.a
dlltool --dllname sapnwrfc.dll --def sapnwrfc.def --output-lib sapnwrfc.a
In the dircectory C:\nwrfcsdk_x64\lib the following files should exist:
icudt34.a
icudt34.def
icudt34.dll
icuin34.a
icuin34.def
icuin34.dll
icuuc34.a
icuuc34.def
icuuc34.dll
libicudecnumber.a
libicudecnumber.def
libicudecnumber.dll
libsapucum.a
libsapucum.def
libsapucum.dll
libsapucum.lib
sapdecfICUlib.lib
sapnwrfc.a
sapnwrfc.def
sapnwrfc.dll
sapnwrfc.lib
Start command prompt with cmd.exe
and start the program cpan
.
Start the command get sapnwrfc
to download the Perl module sapnwrfc from CPAN.
Leave the cpan environment with the exit
command.
Change directory to C:\Strawberry\cpan\build\sapnwrfc-0.37-0
.
Build the Makefile(s) with the following command. Adapt the folder names according to your setup.
perl Makefile.PL --source=C:\nwrfcsdk_x64 --addlibs "C:\nwrfcsdk_x64\lib\sapnwrfc.a C:\nwrfcsdk_x64\lib\libsapucum.a"
Run the commands dmake
and dmake install
to build and install the module.
Copy the files from C:\nwrfcsdk_x64\lib
to C:\Strawberry\perl\site\lib\auto\SAPNW\Connection
.