[29762] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1005 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 6 03:09:39 2007

Date: Tue, 6 Nov 2007 00:09:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 6 Nov 2007     Volume: 11 Number: 1005

Today's topics:
    Re: FAQ 8.17 How can I measure time under a second? <ben@morrow.me.uk>
        How to get only one character input in perl? <tena@makniovotht.hr>
    Re: How to get only one character input in perl? <jurgenex@hotmail.com>
    Re: How to get only one character input in perl?  usenet@DavidFilmer.com
    Re: How to get only one character input in perl? <m@rtij.nl.invlalid>
        How to handle fields names in comma separated file? <some@body.com>
    Re: How to handle fields names in comma separated file? <ramesh.thangamani@gmail.com>
    Re: How to handle fields names in comma separated file? <ben@morrow.me.uk>
    Re: Least Squares <1usa@llenroc.ude.invalid>
    Re: Least Squares <alexxx.magni@gmail.com>
    Re: Math Functions in Perl <m@rtij.nl.invlalid>
    Re: Math Functions in Perl <bik.mido@tiscalinet.it>
        new CPAN modules on Tue Nov  6 2007 (Randal Schwartz)
        Platypus - Current Working Directory - write files <youcontrol@hispeed.ch>
    Re: Platypus - Current Working Directory - write files <kenslaterpa@hotmail.com>
    Re: Platypus - Current Working Directory - write files <tadmc@seesig.invalid>
    Re: Platypus - Current Working Directory - write files <dontmewithme@got.it>
    Re: Platypus - Current Working Directory - write files <ben@morrow.me.uk>
    Re: Simple question to experts <tadmc@seesig.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 5 Nov 2007 20:57:37 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: FAQ 8.17 How can I measure time under a second?
Message-Id: <1nc405-qr4.ln1@osiris.mauzo.dyndns.org>


Quoth PerlFAQ Server <brian@stonehenge.com>:
> This is an excerpt from the latest version perlfaq8.pod, which
> comes with the standard Perl distribution. These postings aim to 
> reduce the number of repeated questions as well as allow the community
> to review and update the answers. The latest version of the complete
> perlfaq is at http://faq.perl.org .
> 
> --------------------------------------------------------------------
> 
> 8.17: How can I measure time under a second?
> 
>     In general, you may not be able to. The Time::HiRes module (available
>     from CPAN, and starting from Perl 5.8 part of the standard distribution)
>     provides this functionality for some systems.
> 
>     If your system supports both the syscall() function in Perl as well as a
>     system call like gettimeofday(2), then you may be able to do something
>     like this:
> 
>             require 'sys/syscall.ph';
> 
>             $TIMEVAL_T = "LL";

Since Time::HiRes can call gettimeofday(2) in a sane manner, wouldn't it
be better to remove the second part of this answer? Perhaps replace it
with a note

    If you can't install Time::HiRes, and you are on a Unixish system,
    you may be able to call gettimeofday(2) directly. See
    L<perlfunc/syscall>.

Ben



------------------------------

Date: Tue, 6 Nov 2007 00:51:27 +0100
From: "Tena" <tena@makniovotht.hr>
Subject: How to get only one character input in perl?
Message-Id: <fgoa9v$r7o$1@localhost.localdomain>

How to get only one character input in perl?




------------------------------

Date: Mon, 05 Nov 2007 23:55:33 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to get only one character input in perl?
Message-Id: <V3OXi.3151$4I.994@trndny03>

Tena wrote:
> How to get only one character input in perl?

Your Question is Asked Frequently. See

    perldoc -q character

"How can I read a single character from a file?  From the keyboard?"

jue 




------------------------------

Date: Mon, 05 Nov 2007 23:55:40 -0000
From:  usenet@DavidFilmer.com
Subject: Re: How to get only one character input in perl?
Message-Id: <1194306940.164181.298000@k35g2000prh.googlegroups.com>

On Nov 5, 3:51 pm, "Tena" <t...@makniovotht.hr> wrote:
> How to get only one character input in perl?

perldoc -q character

   How can I read a single character from a file?  From the keyboard?


--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)



------------------------------

Date: Tue, 6 Nov 2007 01:00:38 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: How to get only one character input in perl?
Message-Id: <pan.2007.11.06.00.00.21@rtij.nl.invlalid>

On Tue, 06 Nov 2007 00:51:27 +0100, Tena wrote:

> How to get only one character input in perl?

perldoc -q 'single character'

HTH,
M4


------------------------------

Date: Mon, 05 Nov 2007 22:28:24 -0500
From: somebody <some@body.com>
Subject: How to handle fields names in comma separated file?
Message-Id: <p6KdnVG5EqTFQrLanZ2dnUVZ_s-pnZ2d@comcast.com>


I have a comma separated file with hundreds of field names.  For the sake
of brevity, let's assume there are only a name, address, city, and state
field.  I currently have the field names defined as scalars in an array
like:

my @fields = (
  my $NAME, 
  my $ADDRESS,
  my $CITY,
  my $STATE
);


This allows me to assign all of the fields to an array element in one
line as with the split function below.  The problem with this is that
the field names are then known only as $fields[0], $fields[1], etc.
Is there a better way to handle field names in a csv file?


while ( <DATA> ) {

  chomp;

  my(@fields) = split /\,/; 

  print "$fields[0]\n";
  print "$fields[1]\n";
  print "$fields[2]\n";
  print "$fields[3]\n";  






------------------------------

Date: Mon, 05 Nov 2007 21:04:42 -0800
From:  rthangam <ramesh.thangamani@gmail.com>
Subject: Re: How to handle fields names in comma separated file?
Message-Id: <1194325482.430736.118410@z24g2000prh.googlegroups.com>


somebody wrote:
> I have a comma separated file with hundreds of field names.  For the sake
> of brevity, let's assume there are only a name, address, city, and state
> field.  I currently have the field names defined as scalars in an array
> like:
>
> my @fields = (
>   my $NAME,
>   my $ADDRESS,
>   my $CITY,
>   my $STATE
> );
>
>
> This allows me to assign all of the fields to an array element in one
> line as with the split function below.  The problem with this is that
> the field names are then known only as $fields[0], $fields[1], etc.
> Is there a better way to handle field names in a csv file?
>
>
> while ( <DATA> ) {
>
>   chomp;
>
>   my(@fields) = split /\,/;
>
>   print "$fields[0]\n";
>   print "$fields[1]\n";
>   print "$fields[2]\n";
>   print "$fields[3]\n";

You can store them in a hash that is better:

like

my %hash;

$hash{NAME} = $fields[0];

etc



------------------------------

Date: Tue, 6 Nov 2007 06:50:58 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How to handle fields names in comma separated file?
Message-Id: <iff505-s21.ln1@osiris.mauzo.dyndns.org>


Quoth somebody <some@body.com>:
> 
> I have a comma separated file with hundreds of field names.  For the sake
> of brevity, let's assume there are only a name, address, city, and state
> field.  I currently have the field names defined as scalars in an array
> like:
>
> my @fields = (
>   my $NAME, 
>   my $ADDRESS,
>   my $CITY,
>   my $STATE
> );

I'm not sure what you think this does, but it almost certainly
doesn't... There is no association between the variables and the
elements of the array after this statement, they just all happen to
contain undef.

> This allows me to assign all of the fields to an array element in one
> line as with the split function below.  The problem with this is that
> the field names are then known only as $fields[0], $fields[1], etc.
> Is there a better way to handle field names in a csv file?
> 
> while ( <DATA> ) {
> 
>   chomp;
> 
>   my(@fields) = split /\,/; 

Comma is not special in a regex, so there's no need to escape it.

You should parse CSV with a module, such as Text::CSV_XS, that knows how
to handle quoting. CSV is remarkably hard to parse correctly for such an
apparently simple format...

If you want access by name, you can use a hash:

my @fields = qw/NAME ADDRESS CITY STATE/;
my %fields = split /,/; # or something better

print $fields{NAME};

>   print "$fields[0]\n";

If you set $\ you don't need all those "\n"s. If you're printing
multi-line data it's better to use a heredoc.

Ben



------------------------------

Date: Mon, 05 Nov 2007 23:24:59 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Least Squares
Message-Id: <Xns99DFBB5672DDFasu1cornelledu@127.0.0.1>

"alexxx.magni@gmail.com" <alexxx.magni@gmail.com> wrote in 
news:1194290793.569055.310260@o38g2000hse.googlegroups.com:

> I need to perform a huge number of Least Squares Fits to my data,
> using probably something like a+b*Atan(c-d*x) as the fitting function.
> Can you suggest me the fastest package on CPAN, according to you?

First off, if you can't reduce that functional form to a form that is 
linear in parameters, you are going to need to resort to numerical 
optimization.

Second, I would be more inclined to open a pipe to R or Octave (I have no 
idea if they can do this particular estimation) for any serious statistics.

Finally, you do not mention what you mean by 'fast'. 

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>



------------------------------

Date: Mon, 05 Nov 2007 23:59:20 -0800
From:  "alexxx.magni@gmail.com" <alexxx.magni@gmail.com>
Subject: Re: Least Squares
Message-Id: <1194335960.669911.315710@y42g2000hsy.googlegroups.com>

On 6 Nov, 00:24, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
> "alexxx.ma...@gmail.com" <alexxx.ma...@gmail.com> wrote innews:1194290793.569055.310260@o38g2000hse.googlegroups.com:
>
> > I need to perform a huge number of Least Squares Fits to my data,
> > using probably something like a+b*Atan(c-d*x) as the fitting function.
> > Can you suggest me the fastest package on CPAN, according to you?
>
> First off, if you can't reduce that functional form to a form that is
> linear in parameters, you are going to need to resort to numerical
> optimization.

It could be still OK for me - do you know of any module able to do
this?

> Second, I would be more inclined to open a pipe to R or Octave (I have no
> idea if they can do this particular estimation) for any serious statistics.

I'm not an expert on R/Octave, but sometimes I tried linking C and
Mathematica - I dont know if Perl can handle this...

> Finally, you do not mention what you mean by 'fast'.

Well, the project involves the processing of simple PGM images (0..255
graylevels) of an interface swapping the image, turning it from black
to white.
So every pixel of the 691x517 images (300 of them!) will behave in
time (time=1..300) approximately as a step function (thats why I use
Atan) with noise overimposed.
I "simply" need to know, for every pixel, at which time the step
appears, to be able to precisely reconstruct the interface.
 ... that's what I meant by "fast"!


thanks for your help,

  Alessandro



------------------------------

Date: Mon, 5 Nov 2007 23:42:03 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Math Functions in Perl
Message-Id: <pan.2007.11.05.22.41.47@rtij.nl.invlalid>

On Mon, 05 Nov 2007 21:49:38 +0100, Michele Dondi wrote:

> For some reason, pocket calcultators have this habit of calling log_10
> log and log_e ln. In my mathematical writings I just stick with log to
> mean "their" ln. logarithms in any other base (unless explicitly shown)
> are of little mathematical relevance, IMHO.

I use log2 on a nearly daily basis. But then, I'm in computers while I 
could have learned a trade.

M4


------------------------------

Date: Tue, 06 Nov 2007 00:33:19 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Math Functions in Perl
Message-Id: <ot9vi3ts8ba8cpv9djpdv9l1r3ojsbhdqn@4ax.com>

On Mon, 5 Nov 2007 23:42:03 +0100, Martijn Lievaart
<m@rtij.nl.invlalid> wrote:

>> For some reason, pocket calcultators have this habit of calling log_10
>> log and log_e ln. In my mathematical writings I just stick with log to
>> mean "their" ln. logarithms in any other base (unless explicitly shown)
>> are of little mathematical relevance, IMHO.
>
>I use log2 on a nearly daily basis. But then, I'm in computers while I 
>could have learned a trade.

Hehe, in fact I was about to say that, probably along the lines of "a
second, but distant competitor being log_2". In fact information
theory is a respectable mathematical one also in its own respect i.e.
abstractly and regardless of any physical computer...


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: Tue, 6 Nov 2007 05:42:16 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Tue Nov  6 2007
Message-Id: <Jr2L6G.MJ4@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

App-Addex-0.010
http://search.cpan.org/~rjbs/App-Addex-0.010/
generate mail tool configuration from an address book 
----
BusinessHours-1
http://search.cpan.org/~solarant/BusinessHours-1/
An object that calculates business days and hours 
----
CGI-Application-PhotoGallery-0.08
http://search.cpan.org/~bricas/CGI-Application-PhotoGallery-0.08/
module to provide a simple photo gallery 
----
CGI-Application-Search-1.02
http://search.cpan.org/~wonko/CGI-Application-Search-1.02/
Base class for CGI::App Swish-e site engines 
----
CGI-Application-Search-1.03
http://search.cpan.org/~wonko/CGI-Application-Search-1.03/
Base class for CGI::App Swish-e site engines 
----
CGI-Application-Search-1.04
http://search.cpan.org/~wonko/CGI-Application-Search-1.04/
Base class for CGI::App Swish-e site engines 
----
CPAN-1.9204
http://search.cpan.org/~andk/CPAN-1.9204/
query, download and build perl modules from CPAN sites 
----
CPANPLUS-Dist-Mdv-0.2.1
http://search.cpan.org/~jquelin/CPANPLUS-Dist-Mdv-0.2.1/
a cpanplus backend to build mandriva rpms 
----
DateTime-BusinessHours-1.0
http://search.cpan.org/~solarant/DateTime-BusinessHours-1.0/
An object that calculates business days and hours 
----
DateTime-TimeZone-0.6902
http://search.cpan.org/~drolsky/DateTime-TimeZone-0.6902/
Time zone object base class and factory 
----
Devel-Cover-0.62
http://search.cpan.org/~pjcj/Devel-Cover-0.62/
Code coverage metrics for Perl 
----
Devel-Hide-0.0007
http://search.cpan.org/~ferreira/Devel-Hide-0.0007/
Forces the unavailability of specified Perl modules (for testing) 
----
Digest-CRC-0.14
http://search.cpan.org/~olimaul/Digest-CRC-0.14/
Generic CRC functions 
----
Egg-Release-2.26
http://search.cpan.org/~lushe/Egg-Release-2.26/
Version of Egg WEB Application Framework. 
----
Email-MIME-1.861
http://search.cpan.org/~rjbs/Email-MIME-1.861/
Easy MIME message parsing. 
----
Exception-System-0.08
http://search.cpan.org/~dexter/Exception-System-0.08/
The exception class for system or library calls 
----
Fatal-Exception-0.0201
http://search.cpan.org/~dexter/Fatal-Exception-0.0201/
succeed or throw exception 
----
File-MMagic-XS-0.09003
http://search.cpan.org/~dmaki/File-MMagic-XS-0.09003/
Guess File Type With XS (a la mod_mime_magic) 
----
File-Stat-Moose-0.0104
http://search.cpan.org/~dexter/File-Stat-Moose-0.0104/
Status info for a file - Moose-based 
----
Geo-ICAO-0.34
http://search.cpan.org/~jquelin/Geo-ICAO-0.34/
Airport and ICAO codes lookup 
----
HTML-Tag-1.08
http://search.cpan.org/~ebruni/HTML-Tag-1.08/
Another HTML Widget system 
----
HTML-Template-Associate-FormField-0.12
http://search.cpan.org/~lushe/HTML-Template-Associate-FormField-0.12/
----
HTML-Tested-0.31
http://search.cpan.org/~bosu/HTML-Tested-0.31/
Provides HTML widgets with the built-in means of testing. 
----
Imager-0.61
http://search.cpan.org/~tonyc/Imager-0.61/
Perl extension for Generating 24 bit Images 
----
InSilicoSpectro-1.3.6
http://search.cpan.org/~alexmass/InSilicoSpectro-1.3.6/
Open source Perl library for proteomics 
----
JE-0.018
http://search.cpan.org/~sprout/JE-0.018/
Pure-Perl ECMAScript (JavaScript) Engine 
----
LaTeX-Table-0.5.0
http://search.cpan.org/~limaone/LaTeX-Table-0.5.0/
Perl extension for the automatic generation of LaTeX tables. 
----
Language-Befunge-Debugger-0.0.1
http://search.cpan.org/~jquelin/Language-Befunge-Debugger-0.0.1/
a graphical debugger for Language::Befunge 
----
Lingua-EN-Conjugate-0.308
http://search.cpan.org/~rwg/Lingua-EN-Conjugate-0.308/
Conjugation of English verbs 
----
Lingua-EN-Contraction-0.104
http://search.cpan.org/~rwg/Lingua-EN-Contraction-0.104/
Add apostrophes all over the place... 
----
List-Compare-0.34
http://search.cpan.org/~jkeenan/List-Compare-0.34/
Compare elements of two or more lists 
----
Math-Units-PhysicalValue-0.71
http://search.cpan.org/~jettero/Math-Units-PhysicalValue-0.71/
An object oriented interface for handling values with units. 
----
Moose-Tiny-0.0.3
http://search.cpan.org/~perigrin/Moose-Tiny-0.0.3/
Why Should Object::Tiny get all the Fun 
----
Net-Netstat-Wrapper-0.03
http://search.cpan.org/~mcantoni/Net-Netstat-Wrapper-0.03/
Perl module for getting the current tcp open ports 
----
Netscape-Cache-0.46
http://search.cpan.org/~srezic/Netscape-Cache-0.46/
object class for accessing Netscape cache files 
----
Package-Builder-5.01
http://search.cpan.org/~drauoner/Package-Builder-5.01/
The great new Package::Builder! 
----
Package-Builder-5.02
http://search.cpan.org/~drauoner/Package-Builder-5.02/
The great new Package::Builder! 
----
Parse-Marpa-0.001_033
http://search.cpan.org/~jkegl/Parse-Marpa-0.001_033/
Jay Earley's general parsing algorithm with LR(0) precomputation 
----
SNMP-Class-0.05
http://search.cpan.org/~aduitsis/SNMP-Class-0.05/
A convenience class around the NetSNMP perl modules. 
----
SOAP-WSDL-2.00_23
http://search.cpan.org/~mkutter/SOAP-WSDL-2.00_23/
SOAP with WSDL support 
----
Test-Harness-2.99_09
http://search.cpan.org/~andya/Test-Harness-2.99_09/
Run Perl standard test scripts with statistics 
----
Test-Lazy-0.061
http://search.cpan.org/~rkrimen/Test-Lazy-0.061/
A quick and easy way to compose and run tests with useful output. 
----
Test-YAML-Meta-0.06
http://search.cpan.org/~barbie/Test-YAML-Meta-0.06/
Validation of the META.yml file in a distribution. 
----
Text-Match-FastAlternatives-0.05
http://search.cpan.org/~arc/Text-Match-FastAlternatives-0.05/
efficient search for many strings 
----
Tie-Util-0.01
http://search.cpan.org/~sprout/Tie-Util-0.01/
Utility functions for fiddling with tied variables 
----
Time-Duration-Parse-0.03
http://search.cpan.org/~miyagawa/Time-Duration-Parse-0.03/
Parse string that represents time duration 
----
Time-Fuzzy-0.35
http://search.cpan.org/~jquelin/Time-Fuzzy-0.35/
Time read like a human, with some fuzziness 
----
Tk-ContextHelp-0.12
http://search.cpan.org/~srezic/Tk-ContextHelp-0.12/
context-sensitive help with perl/Tk 
----
Tree-Simple-Manager-0.07
http://search.cpan.org/~stevan/Tree-Simple-Manager-0.07/
A class for managing multiple Tree::Simple hierarchies 
----
WAP-wmls-1.11
http://search.cpan.org/~perrad/WAP-wmls-1.11/
----
WWW-UsePerl-Journal-0.19
http://search.cpan.org/~barbie/WWW-UsePerl-Journal-0.19/
A use.perl.org journal tool 
----
WWW-UsePerl-Journal-Thread-0.09
http://search.cpan.org/~barbie/WWW-UsePerl-Journal-Thread-0.09/
Handles the retrieval of UsePerl journal comment threads. 
----
WebService-Backlog-0.01_01
http://search.cpan.org/~yamamoto/WebService-Backlog-0.01_01/
Perl interface to Backlog. 
----
Win32-IAF-0.01
http://search.cpan.org/~pczerkas/Win32-IAF-0.01/
Internet Account File (*.iaf) management for Outlook Express/2003. 
----
XML-Compile-0.57
http://search.cpan.org/~markov/XML-Compile-0.57/
Compilation based XML processing 
----
XML-Compile-SOAP-0.59
http://search.cpan.org/~markov/XML-Compile-SOAP-0.59/
base-class for SOAP implementations 
----
constant-1.12
http://search.cpan.org/~saper/constant-1.12/
Perl pragma to declare constants 
----
lsid-perl-1.1.7
http://search.cpan.org/~ekawas/lsid-perl-1.1.7/


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Tue, 6 Nov 2007 01:06:22 +0100
From: Markus S <youcontrol@hispeed.ch>
Subject: Platypus - Current Working Directory - write files
Message-Id: <472fafff@news1-rz-ap.ethz.ch>

Hi,

Trying to use Platypus to create an app out of a Perl script. Bu I 
can't get the 'Getting Current Working Directory' (ie, cd "$1/.." ) to 
work in a Perl script. My minimal Perl script would look this:

#! /usr/bin/perl

# Create content
$content = "This is a test.";

# Save file
$name = "filename.txt";
$namestr = ">" . $name;
open NEWFILE, $namestr;
	truncate NEWFILE, 1;
	print NEWFILE "$content";
close NEWFILE;

I've tried wrapping the cd into a system call but did not get very far. 
If you have anything you can point me at, I'd be very glad.

Wrapping this with Platypus does not produce any error messages but it 
does not create the file (or I can't find it).

Thanks.

Markus



------------------------------

Date: Mon, 05 Nov 2007 17:30:52 -0800
From:  kens <kenslaterpa@hotmail.com>
Subject: Re: Platypus - Current Working Directory - write files
Message-Id: <1194312652.269274.52500@19g2000hsx.googlegroups.com>

On Nov 5, 7:06 pm, Markus S <youcont...@hispeed.ch> wrote:
> Hi,
>
> Trying to use Platypus to create an app out of a Perl script. Bu I
> can't get the 'Getting Current Working Directory' (ie, cd "$1/.." ) to
> work in a Perl script. My minimal Perl script would look this:
>
> #! /usr/bin/perl

Always include:
use strict;
use warnings;

These will help you in the long run even though you will be forced to
define all variables used.

>
> # Create content
> $content = "This is a test.";
>
> # Save file
> $name = "filename.txt";
> $namestr = ">" . $name;
> open NEWFILE, $namestr;

use the three argument form of open, use lexical filehandles and
handle the error condition.

open my $NEWFILE, '>', $name or die
   "Unable to open $name for output: $!";

>         truncate NEWFILE, 1;
>         print NEWFILE "$content";
> close NEWFILE;
>
> I've tried wrapping the cd into a system call but did not get very far.
> If you have anything you can point me at, I'd be very glad.
>
> Wrapping this with Platypus does not produce any error messages but it
> does not create the file (or I can't find it).
>

I know nothing about Platypus, and you have no 'cd' in your code, so
I'm not certain I understand waht you are saying.

If you are saying you tried the system call in the Perl script, that
will not work as the system call creates a new process and the 'cd'
command will be executed in the new process. If you want to change a
directory in Perl use the 'chdir' function ('perldoc chdir' for
documentation).

> Thanks.
>
> Markus

HTH, Ken




------------------------------

Date: Tue, 06 Nov 2007 02:13:52 GMT
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Platypus - Current Working Directory - write files
Message-Id: <slrnfivj7a.v0j.tadmc@tadmc30.sbcglobal.net>

Markus S <youcontrol@hispeed.ch> wrote:

> Trying to use Platypus 


What is Platypus?


> to create an app out of a Perl script. Bu I 
> can't get the 'Getting Current Working Directory' (ie, cd "$1/.." ) to 
> work in a Perl script.


There is no attempt to change directories in your code.

What did you try already?


> 	print NEWFILE "$content";


   perldoc -q vars

       What’s wrong with always quoting "$vars"?

so,

   print NEWFILE $content;


> I've tried wrapping the cd into a system call but did not get very far. 
> If you have anything you can point me at, I'd be very glad.


   perldoc -f chdir

   perldoc -q change

       I {changed directory, modified my environment} in a perl script.  How
       come the change disappeared when I exited the script?  How do I get my
       changes to be visible?


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Tue, 06 Nov 2007 05:02:53 +0100
From: Larry <dontmewithme@got.it>
Subject: Re: Platypus - Current Working Directory - write files
Message-Id: <dontmewithme-7CF886.05025306112007@news.tin.it>

In article <472fafff@news1-rz-ap.ethz.ch>,
 Markus S <youcontrol@hispeed.ch> wrote:

> Trying to use Platypus to create an app out of a Perl script. Bu I 
> can't get the 'Getting Current Working Directory' (ie, cd "$1/.." ) to 
> work in a Perl script. My minimal Perl script would look this:

in Platypus window:

Script Type: Shell
Script Path: your start.sh

the followin is the start.sh file:

#!/bin/sh
#
# start.sh

cd $1/Contents/Resources/

/usr/bin/perl $1/Contents/Resources/my_perl_script.pl


------------------------------

Date: Tue, 6 Nov 2007 06:40:52 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Platypus - Current Working Directory - write files
Message-Id: <kse505-s21.ln1@osiris.mauzo.dyndns.org>


Quoth Larry <dontmewithme@got.it>:
> In article <472fafff@news1-rz-ap.ethz.ch>,
>  Markus S <youcontrol@hispeed.ch> wrote:
> 
> > Trying to use Platypus to create an app out of a Perl script. Bu I 
> > can't get the 'Getting Current Working Directory' (ie, cd "$1/.." ) to 
> > work in a Perl script. My minimal Perl script would look this:
> 
> in Platypus window:
> 
> Script Type: Shell
> Script Path: your start.sh
> 
> the followin is the start.sh file:
> 
> #!/bin/sh
> #
> # start.sh
> 
> cd $1/Contents/Resources/
> 
> /usr/bin/perl $1/Contents/Resources/my_perl_script.pl

If that works (I've no idea what Platypus is, so I can't comment on
that) then you can do it in Perl instead:

    Script Type: Shell
    Script Path: this perl script:

#!/usr/bin/perl

use strict;
use warnings;

# it's always worth being portable when it's easy...
use File::Spec::Functions;

my $Res = catdir $ARGV[0], qw/Contents Resources/;
chdir $Res or die "can't cd to '$Res': $!";

# carry on...

Ben


------------------------------

Date: Tue, 06 Nov 2007 02:13:52 GMT
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Simple question to experts
Message-Id: <slrnfivinv.v0j.tadmc@tadmc30.sbcglobal.net>

Paul Lalli <mritty@gmail.com> wrote:

> It's my birthday,


Those are good for you.

A federally funded study has shown that people with the most birthdays...

 ...

 ...

 ... live the longest.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 1005
***************************************


home help back first fref pref prev next nref lref last post