Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Using module for different operating systems

Reply
Thread Tools

Using module for different operating systems

 
 
Michael
Guest
Posts: n/a
 
      12-13-2010
I have a crossplatform script, which requires the utf8 module for Linux
version. Windows version don't need this module (I/O is wrong when it is
present). How to restrict appearing of this module to Lunix version
without deleting this string every time when it's necessary?
"use utf8 if $^O eq 'linux' " does not work.
 
Reply With Quote
 
 
 
 
Peter J. Holzer
Guest
Posts: n/a
 
      12-13-2010
On 2010-12-13 10:45, Michael <(E-Mail Removed)> wrote:
> I have a crossplatform script, which requires the utf8 module for Linux
> version. Windows version don't need this module (I/O is wrong when it is
> present).


The UTF-8 pragma doesn't affect I/O, it only says that the source code
is encoded in UTF-8. So you are probably barking up the wrong tree here.

If a script using the utf8 pragma behaves differently on Linux and
Windows you probably have converted it from one encoding to another
when you transferred the script from one OS to the other. Make sure that
the script is UTF-8-encoded on both systems.

It is also possible that you made a different mistake (possibly a wrong
encoding on I/O) which doesn't have anything to do with the utf8 macro
directly but which is masked by a (probably erroneous) use of the utf8
macro. This is hard to guess, though, we would need to see a minimal
script which demonstrates the behaviour.

> How to restrict appearing of this module to Lunix version
> without deleting this string every time when it's necessary?
> "use utf8 if $^O eq 'linux' " does not work.


I won't answer that because I think that isn't the problem and I prefer
solving the real problem instead of patching over the symptoms.

hp

 
Reply With Quote
 
 
 
 
Jrgen Exner
Guest
Posts: n/a
 
      12-13-2010
Michael <(E-Mail Removed)> wrote:
>I have a crossplatform script, which requires the utf8 module for Linux
>version. Windows version don't need this module (I/O is wrong when it is
>present). How to restrict appearing of this module to Lunix version
>without deleting this string every time when it's necessary?
>"use utf8 if $^O eq 'linux' " does not work.


perldoc -f use:
[...]. It is exactly equivalent to
BEGIN { require Module; Module->import( LIST ); }
[...]

In other words: 'use' is executed at compile time, long before the "if"
would ever make a difference.

So don't use use() but instead require() directly to load the module at
runtime.

jue
 
Reply With Quote
 
C.DeRykus
Guest
Posts: n/a
 
      12-14-2010
On Dec 13, 2:45*am, Michael <(E-Mail Removed)> wrote:

[...]

> "use utf8 if $^O eq 'linux' " does not work.


The 'if' pragma has been available in Perl for
some time. See: perldoc if


use if ($^O eq 'linux'), utf8;

--
Charles DeRykus
 
Reply With Quote
 
Michael
Guest
Posts: n/a
 
      12-14-2010
14.12.2010 8:45, C.DeRykus пишет:
> On Dec 13, 2:45 am, Michael<(E-Mail Removed)> wrote:
>
> [...]
>
>> "use utf8 if $^O eq 'linux' " does not work.

>
> The 'if' pragma has been available in Perl for
> some time. See: perldoc if
>
>
> use if ($^O eq 'linux'), utf8;
>
> --
> Charles DeRykus


Thank you.

Michael
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How do I use the same contact management database with two different operating systems?? John Morrison Computer Support 1 10-10-2010 04:38 AM
Re: How do I use the same contact management database with two different operating systems?? G. Morgan Computer Support 0 10-08-2010 09:02 AM
sharing a printer with computers with different operating systems =?Utf-8?B?Z2VvYmVudGNwaHQ=?= Wireless Networking 1 08-12-2007 02:09 PM
Voip PBX,Private Phone Systems,PBX Telephone Systems, Business Phone Systems broadbandera@gmail.com UK VOIP 9 07-24-2006 03:44 PM
Printing on a network with 2 different operating systems Rampart Wireless Networking 2 04-29-2006 07:02 PM



Advertisments