Bellhop Pasteboard Package for Perl Reference

 

Overview

The Pasteboard package defines methods that allow you to query the services pasteboard for its content, as well as put data back onto it. There are also a number of symbolic constants that are dynamically loaded into the Perl interpreter that you can use to identify pasteboard data types, as well as targetting the general clipboard by name. These constants mimic those found in the Cocoa frameworks.

 

Pasteboard Data Types

The following global variables are automatically available to your Perl scripts and are used to identify the various types of pasteboard data. You can use these symbolic names instead of creating new strings. For more information on the meaning of these types, see the Apple developer documentation for the NSPasteboard class.

Additionally, you can target the general clipboard by name using the $NSGeneralPboard constant.

 

Method List for Pasteboard Package

The following methods are available in the pasteboard extension:

NOTE: Each function is shown with the arguments that are expected when invoking the function. For functions that require strings and numbers you can pass normal scalar values, however for arrays and hashes you must pass in references. Similarly, numeric and string return values are returned as scalars, however arrays and hashes are returned as references. Array and hash references can contain nested structures.

 

Method Descriptions for Pasteboard Package

Pasteboard::get_types(aPasteboard)
Returns a reference to an array of pasteboard types that are available on the services pasteboard identified by aPasteboard. The returned array will consist of strings from the list of global pasteboard type constants described earlier in the document.

 

Pasteboard::declare_types(aPasteboard, aTypeList)
Configures aPasteboard so that it can hold the pasteboard types contained in aTypeList, which should be a reference to an array of strings representing a subset of the known pasteboard types (as outlined in the global pasteboard type constants appearing earlier in this document).

 

Pasteboard::read_data(aPasteboard, aType)
Queries the services pasteboard aPasteboard for data of the given pasteboard type aType, and returns it as a string. The aType argument should be one of the global constant pasteboard data types.

 

Pasteboard::write_data(aPasteboard, aType, aData)
Writes aData, which should be a string, to aPasteboard with the pasteboard data type aType. Before calling this function, be sure to call Pasteboard::declare_types() to configure the pasteboard for the proper types.

 

Pasteboard::read_string(aPasteboard, aType)
Queries aPasteboard for data of the given pasteboard type aType, and returns it as a string. Strings are assumed to be UTF8 encoded.

 

Pasteboard::write_string(aPasteboard, aType, aString)
Writes aString, which should be a UTF8 string, to aPasteboard with the pasteboard data type aType. Before calling this function, be sure to call Pasteboard::declare_types() to configure the pasteboard for the proper types.

 

Pasteboard::read_array(aPasteboard, aType)
Queries aPasteboard for a list of objects of the given pasteboard data type aType. Returns the contents as a reference to an array, which may contain references to other arrays and hashes.

 

Pasteboard::write_array(aPasteboard, aType, anArray)
Writes anArray, which should be a reference to an array, to aPasteboard with the pasteboard data type aType. Before calling this function, be sure to call Pasteboard::declare_types() to configure the pasteboard for the proper types.

 

Pasteboard::read_hash(aPasteboard, aType)
Queries aPasteboard for a hash of the given pasteboard data type aType. Returns the contents as a reference to a hash, which may or may not contain references to other hashes and arrays.

 

Pasteboard::write_hash(aPasteboard, aType, aHash)
Writes aHash, which should be a reference to a hash, to aPasteboard with the pasteboard data type aType. Before calling this function, be sure to call Pasteboard::declare_types() to configure the pasteboard for the proper types.