: hi, i want to know how to write scripts such that i can use them in
: both windows and unix.....
:
Mostly, by avoiding stuff that doesn't work in both places.
: For example windows uses back-slash(\) whereas unix uses forward-
: slash(/) for specifying the path.....
:
I've generally found you can get away with using forward slashes on Windows and it won't complain. Especially if you're just using relative paths etc. You may be interested in a module called File::Spec.
: Another example could be using commands such as fc and diff which
: are file comparison commands in UNIX and DOS respectively.....
:
If you are going to be depending on external programs, you inherently risk cross-platform issues. It's often a good idea to see if you can manage a pure-Perl implementation. And remember to check out
http://search.cpan.org/ as someone else may have done some of the hard work for you.
: Is there any way to specify that if the OS detected is Windows then
: use one script and if the OS specified is UNIX or Linux then use
: another script???
:
if ($^O =~ /MSWin32/) {
# do Win32 stuff
} elsif ($^O =~ /linux/) {
# do Linux stuff
# other checks
} else {
# we have no idea - do something generic.
}
Jonathan
###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");