---
name: "TM::QL"
section: "3pm"
platform: "linux"
package: "libtm-perl"
version: "1.42-1"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/TM::QL"
---

# TM::QL(3pm)

TM::QL - Topic Maps, Query Language Expressions

```
   use TM::QL;
   # compile a TMQL query (here path expression style)
   my $q = new TM::QL ('// hypocrite [ . <- employee -> organisation == $org ]');
```

```
   use TM;
   my $tm = new TM (....);                         # get a map from somewhere
```

```
   my $or  = $tm->mids ('vagabond-university');    # find internal id
   my $ts = $q->eval ('%_' => $tm,                 # explicitly pass in a default map
                      '$o' => $or);                # and any number of other variable bindings
```

```
   foreach my $tuple (@$ts) {                      # iterate through the tuple sequence
      foreach my $value (@$tuple) {                # do something with the tuple
        print ref ($value)
                 ? $value->[0]                     # literal
                 : $value                          # internal map identifier
      }
   }
```

This class implements TMQL expression handling. A TMQL expression can be parsed, stored in an object, optimized and then evaluated. The results of this process is a tuple sequence as described in

```
    http://topicmaps.it.bond.edu.au/junk/tmql.html
```

**NOTE**: This is work in progress, so there might be discrepancies.\
 **Constructor** Given a TMQL query expression, this constructor will build a compiled version of the query, which then can be executed with the method `"eval"`. If an already compiled is passed as parameter, the constructor behaves as a cloner. (Note: no deep copy of the compiled query).\
 **Methods** Given a query object, this method will evaluate it according to the TMQL semantics. The result is a tuple sequence (TM::QL::TS).

Optionally, a hash reference can be passed into this method. It will be used as variable binding. Robert Barta, \<drrho@cpan.org\> Copyright (C) 200\[4-6\] by Robert Barta This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.4 or, at your option, any later version of Perl 5 you may have available.
