[24034] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6231 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 8 03:05:35 2004

Date: Mon, 8 Mar 2004 00:05:06 -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           Mon, 8 Mar 2004     Volume: 10 Number: 6231

Today's topics:
        [newbie] Filehandles and physical files (David)
    Re: [newbie] Filehandles and physical files <tadmc@augustmail.com>
    Re: [newbie] Filehandles and physical files <beable+unsenet@beable.com.invalid>
        all .pm file end with "1;". why? <ckacka@163.com>
    Re: all .pm file end with "1;". why? <komsbomb@hotmail.com>
        Excel sheet opening Win32OLE <someone@ti.com>
        hex conversion after unpack (woodywit)
    Re: HOW TO CHECK URL?? <Joe.Smith@inwap.com>
        Ignoring an element in a list (David)
    Re: Ignoring an element in a list <tadmc@augustmail.com>
    Re: Ignoring an element in a list <tadmc@augustmail.com>
    Re: Ignoring an element in a list <beable+unsenet@beable.com.invalid>
    Re: Ignoring an element in a list <beable+unsenet@beable.com.invalid>
        more efficient way of updating a file? (mike)
        printf (kielhd)
    Re: String Search containing a '/' character <tadmc@augustmail.com>
        teaching myself perl - stumped on this one! <mjpliv@hfx.eastlink.ca>
    Re: teaching myself perl - stumped on this one! <tadmc@augustmail.com>
    Re: teaching myself perl - stumped on this one! <Me@myco.com>
    Re: Unwanted newline or eol between fields (David Efflandt)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 7 Mar 2004 20:13:02 -0800
From: davidol@hushmail.com (David)
Subject: [newbie] Filehandles and physical files
Message-Id: <3bef037b.0403072013.6a672a35@posting.google.com>

This bit of code ftp gets() the contents of all non-empty files into a
filehandle TEMP.  Can it be rewritten so that it doesn't actually use
a  physical file?  Should I care about this?

@fileList = $ftp->ls($remoteDir)
    or die "Can't get a list of files in $remoteDir: $!";

open TEMP, "> $tempFile" or die "Can't create $tempFile: $!";

foreach (@fileList) {
  next if $ftp->size($_) == 0;
  $ftp->get($_, *TEMP)
      or warn "Can't fetch $_ : $!\n";
}

open TEMP, "< $tempFile" or die "Can't open $tempFile: $!";

while (<TEMP>) {
  print "$_";
}


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

Date: Sun, 7 Mar 2004 22:59:12 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: [newbie] Filehandles and physical files
Message-Id: <slrnc4nvd0.vv5.tadmc@magna.augustmail.com>

David <davidol@hushmail.com> wrote:

>   print "$_";


That is a useless use of double quotes.

   print $_;
or
   print;

would be better.


See this Perl FAQ:

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


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 08 Mar 2004 06:18:33 GMT
From: Beable van Polasm <beable+unsenet@beable.com.invalid>
Subject: Re: [newbie] Filehandles and physical files
Message-Id: <gksmgjuanp.fsf@dingo.beable.com>

davidol@hushmail.com (David) writes:

> This bit of code ftp gets() the contents of all non-empty files into
> a filehandle TEMP.  Can it be rewritten so that it doesn't actually
> use a physical file?  Should I care about this?

How can you ask other people what you should care about? Don't you
know what you care about? Why do you post code which doesn't actually
compile? For example:

> @fileList = $ftp->ls($remoteDir)
>     or die "Can't get a list of files in $remoteDir: $!";

What is $ftp? Now I could guess that $ftp is an object of type
Net::FTP, but obviously the Perl compiler can't guess that. What
you are doing is asking too much. For people to help you, they 
have to rewrite your code snippets into a working program, and
then work out what your problem is from your rather sketchy 
description. Did you try reading the posting guidelines before
you posted?

http://groups.google.com/groups?selm=HY6dnZVjW6EjpdXdRVn-vw%40august.net

If you are using Net::FTP, then you can easily read the documentation
for that module by typing in "perldoc Net::FTP" into a command prompt
window, or by doing a websearch:

http://www.google.com/search?q=perldoc+net%3A%3Aftp

If you aren't using Net::FTP, then it is your own fault that I have no
idea what you're doing, because my ESP::MindReading module is only
working sporadically.

Summary: If you're a newbie, read the posting guidelines first! Read
the FAQ first! Read the documentation for the module you're using
first! Once you've done that (and done what it says in the posting
guidelines), THEN post. But make sure you post a short program which
demonstrates what your problem is.
 


-- 
  "Driving ME nuts" = "driving MY nuts"! I get it now! -- John Burrage 
                              http://beable.org


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

Date: Mon, 8 Mar 2004 14:05:06 +0800
From: "ckacka" <ckacka@163.com>
Subject: all .pm file end with "1;". why?
Message-Id: <c2h2ee$1t23kg$1@ID-224383.news.uni-berlin.de>

thanks.




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

Date: Mon, 8 Mar 2004 14:09:49 +0800
From: "Koms Bomb" <komsbomb@hotmail.com>
Subject: Re: all .pm file end with "1;". why?
Message-Id: <c2h2m0$1sepc2$1@ID-165313.news.uni-berlin.de>

"ckacka" <ckacka@163.com> wrote in message
news:c2h2ee$1t23kg$1@ID-224383.news.uni-berlin.de...
> thanks.
>

It's the module's return value and must be non-zero.
If the module return 0, Perl will give out a error message.


--
Koms Bomb

*****Pardon my poor English*****
---------------------
My TASM homepage, resource for assembly. Tools, articles, links.
http://komsbomb.ols-lab.com




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

Date: Mon, 8 Mar 2004 09:06:09 +0530
From: "Abhishek Shankar" <someone@ti.com>
Subject: Excel sheet opening Win32OLE
Message-Id: <c2gpne$oqu$1@home.itg.ti.com>

Hi All

I opened an Excel file using the Perl Win32 OLE saved in an earlier version
of Excel in Excel XP. When I try to close it even without doing any changes
I see that it asks if I wish to save the changes made which I realize is
because of recalculating formulas. I want to know if there is a way of
closing by discarding changes or opening read-only.

Thanx in advance
Abhishek





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

Date: 7 Mar 2004 18:41:38 -0800
From: markwitczak@yahoo.com (woodywit)
Subject: hex conversion after unpack
Message-Id: <88c9f169.0403071841.2df69a02@posting.google.com>

Can someone please explain to me the inner workings of converting a
hex value to decimal?  I understand converting integer data types but
what stops me in my tracks is trying to convert a double or float
type.  Below is a sample record.

Record layout: 104 bytes  (2 - 4 byte integers followed by 12 - 8 byte
doubles)

The first column is the result of unpack("H*",$buf).
The second column is the result of unpack("i2 d12",$buf).

00000000                      0
00000383                      899
40c742ff75f285cc              11909.9957869676
40c742faaaaaaaab              11909.9583333333
40946e171b6ed2ff              1307.52256558574
40b1a9365b21c34c              4521.21232806223
c0b1c35642c7032b             -4547.33695644214
c01e0bb154602f10             -7.51141864621219
3faa8901d08e75bb              0.0518265311322738
c000da13a4ddaf6b             -2.10648278047113
3fa8080bedda31ab              0.0469363906714507
0000000000000000              0
0000000000000000              0
0000000000000000              0

So for example how does one get 11909.9957869676 decimal from
40c742ff75f285cc hex.  Also -4547.33695644214 decimal from
c0b1c35642c7032b.

The binary data record was generated by a 'C' program on a flavor of
Unix.
Let me know if I need to provide more information to fully answer my
question.
Thanks.


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

Date: Mon, 08 Mar 2004 02:22:57 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: HOW TO CHECK URL??
Message-Id: <5OQ2c.200990$uV3.815702@attbi_s51>

news.hinet.net wrote:
> HTTP://123.22.1.33     TRUE
> HTTP://123.22.1.333   FAIL
> http://123.22.1 fail

That last one should not fail.
http://64.236.4116/ is a valid URL.  Try it!

> ftp://abc.efg.net  true
> ftp://abc.efg.nnn  fail

Today ".nnn" is not valid, but that could change tomorrow.
Your script will have to go visit a database of current
Global top-level-domains to be accurate.


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

Date: 7 Mar 2004 21:35:41 -0800
From: davidol@hushmail.com (David)
Subject: Ignoring an element in a list
Message-Id: <3bef037b.0403072135.85ee263@posting.google.com>

Hi all,

I want to ignore the elements A and E, but when I print a
representation of the array (of hashes), the second undef _isn't_
being ignored.  Am I approaching this the right way?

my @table;
my @attrs = qw( A, undef, C, D, undef, F, H, I, J, K, L );

while (<FILE>) {
  chomp;
  my %rec;
  @rec{@attrs} = split(/\|/);
  push @table, \%rec;
}

print Dumper(\@table);

$VAR1 = [
          {
            'J,' => '20040305',
            'K,' => 'Y',
            'F,' => '29780103',
            'H,' => '    20140.00',
            'undef,' => '20040305/S/000016',
            'D,' => '20040305/S/000015',
            'I,' => '      671840.19',
            'C,' => 'BVP',
            'L' => '                              ',
            'A,' => 'CBA         '
          },
          {
            'J,' => '99991231',
            'K,' => 'Y',
            'F,' => '23122997',
            'H,' => '   -31000.00',
            'undef,' => '20040305/S/000447',
            'D,' => '20040305/S/000446',
            'I,' => '     -334614.00',
            'C,' => 'LVC',
            'L' => '                              ',
            'A,' => 'LLC         '
          }
        ];


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

Date: Sun, 7 Mar 2004 23:44:50 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Ignoring an element in a list
Message-Id: <slrnc4o22i.sb.tadmc@magna.augustmail.com>

David <davidol@hushmail.com> wrote:

> my @attrs = qw( A, undef, C, D, undef, F, H, I, J, K, L );


You should always enable warnings when developing Perl code:

   use warnings;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 7 Mar 2004 23:48:10 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Ignoring an element in a list
Message-Id: <slrnc4o28q.sb.tadmc@magna.augustmail.com>

David <davidol@hushmail.com> wrote:

> I want to ignore the elements A and E, but when I print a


Don't you mean B and E ?


> representation of the array (of hashes), the second undef _isn't_


There are no undef values in your program!

There are strings whose value is "undef," though...


> being ignored.  Am I approaching this the right way?


No.


> my @table;
> my @attrs = qw( A, undef, C, D, undef, F, H, I, J, K, L );


   my @attrs = qw( A   C D   F H I J K L );


> while (<FILE>) {
>   chomp;
>   my %rec;
>   @rec{@attrs} = split(/\|/);
>   push @table, \%rec;
> }


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 08 Mar 2004 06:00:59 GMT
From: Beable van Polasm <beable+unsenet@beable.com.invalid>
Subject: Re: Ignoring an element in a list
Message-Id: <v9wu5vubck.fsf@dingo.beable.com>

davidol@hushmail.com (David) writes:

> Hi all,
> 
> I want to ignore the elements A and E, but when I print a
> representation of the array (of hashes), the second undef _isn't_
> being ignored.  Am I approaching this the right way?


You have some missing lines right here:

use strict;
use warnings;
use Data::Dumper;
 
> my @table;
> my @attrs = qw( A, undef, C, D, undef, F, H, I, J, K, L );

If you had added those lines, you would have received a warning about
the above line. Also, this appears to be trying to ignore "B" and "E",
unlike your stated desire.

How about this? I had to bodgy up some data, since you didn't provide
any.

#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;

my @table;
my @attrs = ("A" .. "L");

while (<DATA>) {
  chomp;
  my %rec;
  @rec{@attrs} = split(/\|/);
  delete $rec{A};
  delete $rec{E};
  push @table, \%rec;
}

print Dumper(\@table);

__DATA__
a|b|c|d|e|f|g|h|i|j|k|l
a|b|c|d|e|f|g|h|i|j|k|l
a|b|c|d|e|f|g|h|i|j|k|l

__END__

-- 
  "Driving ME nuts" = "driving MY nuts"! I get it now! -- John Burrage 
                              http://beable.org


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

Date: Mon, 08 Mar 2004 06:27:23 GMT
From: Beable van Polasm <beable+unsenet@beable.com.invalid>
Subject: Re: Ignoring an element in a list
Message-Id: <0wk71vua4a.fsf@dingo.beable.com>

Tad McClellan <tadmc@augustmail.com> writes:

> David <davidol@hushmail.com> wrote:
> 
> > my @table;
> > my @attrs = qw( A, undef, C, D, undef, F, H, I, J, K, L );
> 
> 
>    my @attrs = qw( A   C D   F H I J K L );

Errr, huh? What do you expect that to do? Won't that just call "B",
"C", and so on?



-- 
  "Driving ME nuts" = "driving MY nuts"! I get it now! -- John Burrage 
                              http://beable.org


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

Date: 7 Mar 2004 23:37:31 -0800
From: s99999999s2003@yahoo.com (mike)
Subject: more efficient way of updating a file?
Message-Id: <dfd17ef4.0403072337.5e0246eb@posting.google.com>

hi

i have made a text file called status.out which contains just "0 0 0 0
0".
In my perl script, i would like to update this status.out file with a
"1" by position.
I wrote a subroutine "updatestatus" that goes like this:

sub updatestatus {
	$stat = $_[0];chomp($stat); 	
	open (STATOUT, ">status.temp") or die "Cannot open status.temp for
writing\n";
	open (STAT , "< status.out") or die "Cannot open status.out for
reading\n";
	while ($status = <STAT>)
	{
		chomp($status);
		($status1, $status2, $status3, $status4, $status5) = split(' ',
$status );
	}

	if ($stat == 1)
	{	
		print STATOUT "1 $status2 $status3 $status4 $status5"	;

	}
	if ($stat == 2)
	{
		print STATOUT "$status1 1 $status3 $status4 $status5"	;
	}

	if ($stat == 3)
	{
		print STATOUT "$status1 $status2 1 $status4 $status5"	;
	}

	if ($stat == 4)
	{
		print STATOUT "$status1 $status2 $status3 1 $status5"	;
	}

	if ($stat == 5)
	{
		print STATOUT "$status1 $status2 $status3 $status4 1"	;
	}
	close(STAT);
	close(STATOUT);
	rename "$HOMEDIR\\status.temp" , "$HOMEDIR\\status.out";

	
} # end sub

In main, for example i would call it like updatestatus(1) to update
the first 0 in status.out.

Is there a more efficient way of doing this??? I find that the
subroutine is quite "longwinded"....
thanks


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

Date: 7 Mar 2004 23:52:51 -0800
From: kielhd@freenet.de (kielhd)
Subject: printf
Message-Id: <10a4173d.0403072352.bf03b7e@posting.google.com>

Hi NG,
ich muß Variablen mit mehr als 50 Zeichen Länge in einem Script
verarbeiten.
U. a. muß ich diese Variable auch via printf ausgeben, aber nciht die
gesamte Veriable, sondern nur die ersten 30 Zeichen.
Natürlich bietet Perl viele Möglichkeiten die Variable entsprechend zu
kürzen und dann auszugeben - dies kommt in meinem konkreten Fall aber
nicht in Frage.

Frage: Gibt es eine Option von printf, die nur die ersten 30 Zeichen
einer 50 Zeichen langen Variable ausgibt?

Tia, Henning


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

Date: Sun, 7 Mar 2004 18:53:19 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: String Search containing a '/' character
Message-Id: <slrnc4ngvv.vpe.tadmc@magna.augustmail.com>

Bumble <bumble@what.the.heck> wrote:

> I've tried a few things but nothing
> is working?


Show them to us and we will help you fix them.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 8 Mar 2004 00:12:01 -0400
From: "Martin Livingston" <mjpliv@hfx.eastlink.ca>
Subject: teaching myself perl - stumped on this one!
Message-Id: <fmS2c.2716$kc2.53815@nnrp1.uunet.ca>

Hi,

I bought a book ( PERL and CGI For the World Wide Web - Elizabeth Castro )
learn the basics. I have put together a dozen or so working scripts but this
one has me stumped.

This is a "real world" exercise. I am putting together a "cookbook" for a
friend. She fills in a form with the recipe details and selects a image file
to appear on the finished web page. When she "submits" the form it returns a
copy of the preview page with the image in place where the image file is
stored in a temporary location on my server. Up to this point everything
works just fine.

If she is happy with the preview page, she "submits" this page to be stored
on the server. The html gets written correctly to the server but the image
file only creates the file name without any data in the permanent images
directory. However, the script deletes the old file properly.

Here is the first portion of the script (with the absolute paths blanked
out). I am sure I am just using the FILEHANDLES incorrectly and would
appreciate any help available out there. I used comment lines to explain
what I am trying to do.

Thanks
Martin L.

#!/usr/bin/perl
use CGI ':standard';

#import the data from the hidden fields from the recipe preview page

$catagory=param("catagory");
$name=param("name");
$description=param("description");
$source=param("source");
$origin=param("origin");
$ingredients=param("ingredients");
$method=param("method");
$service=param("service");
$picture=param("picture");
$filename= param("filename");
$imgfilename =  param("imgfilename");

#build the meta tags for the website search engine

$meta = $catagory . " " . $name . " " . $description . " " . $source . " " .
$origin;

#see if picture file was uploaded

if   ($picture)    {

#get image from temporary image directory

open (TEMPORARY, "</xxx/xxx/x/xx/xx/xxxxx/web/nugget/temp/$imgfilename");

$temp_img=(TEMPORARY);

close (TEMPORARY);

#delete temporary image file

unlink ("/xxx/xxx/x/xx/xx/xxxxx/web/nugget/temp/$imgfilename");

#copy image file to the cookbook images directory

open (IMAGEFILE,
">>/xxx/xxx/x/xx/xx/xxxxx/web/nugget/cookbook/images/$imgfilename");

print IMAGEFILE "$temp_img";

close (IMAGEFILE);

  }

#Copy html to the appropriate folder in the cookbook directory

open (PAGEFILE,
">/xxx/xxx/x/xx/xx/xxxxx/web/nugget/cookbook/$catagory/$filename");
print PAGEFILE qq(<html>\n<head>\n<title>$name</title>\n</head>\n<body>\n);
print PAGEFILE qq(<META NAME=description CONTENT=$description>\n);
print PAGEFILE qq(<META NAME=keywords CONTENT= $meta>\n);
print PAGEFILE qq(<body bgcolor="#e6e6fa" TOPMARGIN=5 LEFTMARGIN=2
MARGINHEIGHT=0 MARGINWIDTH=2>\n);
print PAGEFILE qq(<table  width=600 align=center CELLPADDING=0 border=0
CELLSPACING=0>\n);




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

Date: Sun, 7 Mar 2004 22:46:45 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: teaching myself perl - stumped on this one!
Message-Id: <slrnc4null.vv5.tadmc@magna.augustmail.com>

Martin Livingston <mjpliv@hfx.eastlink.ca> wrote:

> The html gets written correctly to the server but the image
> file only creates the file name without any data in the permanent images
> directory. 

> Here is the first portion of the script (with the absolute paths blanked
> out). I am sure I am just using the FILEHANDLES incorrectly and would
> appreciate any help available out there.


Read about the $/ variable in perlvar.pod, and about binmode()
in perlfunc.pod.


> #!/usr/bin/perl

You should ask for all the help you can get:

   use warnings;
   use strict;


> $meta = $catagory . " " . $name . " " . $description . " " . $source . " " .
> $origin;


   my $meta = "$catagory $name $description $source $origin";
                   ^
                   ^ sic


Much easier to see what's going on, don't you think?


> open (TEMPORARY, "</xxx/xxx/x/xx/xx/xxxxx/web/nugget/temp/$imgfilename");


You should always, yes *always*, check the return value from open():

   open (TMPIMAGE, "</xxx/xxx/x/xx/xx/xxxxx/web/nugget/temp/$imgfilename")
      or die "could not open .../$imgfilename  $!";


TEMPORARY is a pretty useless choice of name.


> $temp_img=(TEMPORARY);


You use <angle brakets> for reading from a filehandle, not (parenthesis).

If you use the <input operator> in scalar context like that, you
may leave part of the file unread...


> open (IMAGEFILE,
> ">>/xxx/xxx/x/xx/xx/xxxxx/web/nugget/cookbook/images/$imgfilename");


Why are you open()ing for append rather than for write?

Have you turned binmode() on?

Check the return value from open().


> print IMAGEFILE "$temp_img";
                  ^         ^
                  ^         ^ A useless use of double quotes


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


> open (PAGEFILE,
> ">/xxx/xxx/x/xx/xx/xxxxx/web/nugget/cookbook/$catagory/$filename");
> print PAGEFILE qq(<html>\n<head>\n<title>$name</title>\n</head>\n<body>\n);
                                                                   ^^^^^^
> print PAGEFILE qq(<META NAME=description CONTENT=$description>\n);
> print PAGEFILE qq(<META NAME=keywords CONTENT= $meta>\n);
> print PAGEFILE qq(<body bgcolor="#e6e6fa" TOPMARGIN=5 LEFTMARGIN=2
                    ^^^^^

How many <body> elements are you supposed to have in an HTML document?


> MARGINHEIGHT=0 MARGINWIDTH=2>\n);
> print PAGEFILE qq(<table  width=600 align=center CELLPADDING=0 border=0
> CELLSPACING=0>\n);


Use a here-doc instead of a bazillion print()s:

print PAGEFILE <<ENDHTML;
<html>
<head>
<title>$name</title>
</head>
<body>
<META NAME=description CONTENT=$description>
<META NAME=keywords CONTENT= $meta>
<body bgcolor="#e6e6fa" TOPMARGIN=5 LEFTMARGIN=2 MARGINHEIGHT=0 MARGINWIDTH=2>
<table  width=600 align=center CELLPADDING=0 border=0 CELLSPACING=0>
ENDHTML


Much easier to see what's going on, don't you think?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 08 Mar 2004 10:40:40 +0530
From: Abhinav <Me@myco.com>
Subject: Re: teaching myself perl - stumped on this one!
Message-Id: <KlT2c.3$ql6.157@news.oracle.com>

Hi Martin,

Martin Livingston wrote:
> Hi,
> 
> I bought a book ( PERL and CGI For the World Wide Web - Elizabeth Castro )
> learn the basics. I have put together a dozen or so working scripts but this
> one has me stumped.
> 
> This is a "real world" exercise. I am putting together a "cookbook" for a
> friend. She fills in a form with the recipe details and selects a image file
> to appear on the finished web page. When she "submits" the form it returns a
> copy of the preview page with the image in place where the image file is
> stored in a temporary location on my server. Up to this point everything
> works just fine.
> 
> If she is happy with the preview page, she "submits" this page to be stored
> on the server. The html gets written correctly to the server but the image
> file only creates the file name without any data in the permanent images
> directory. However, the script deletes the old file properly.
> 
> Here is the first portion of the script (with the absolute paths blanked
> out). I am sure I am just using the FILEHANDLES incorrectly and would
> appreciate any help available out there. I used comment lines to explain
> what I am trying to do.
> 
> Thanks
> Martin L.
> 
> #!/usr/bin/perl
> use CGI ':standard';
> 
> #import the data from the hidden fields from the recipe preview page
> 
> $catagory=param("catagory");
> $name=param("name");
> $description=param("description");
> $source=param("source");
> $origin=param("origin");
> $ingredients=param("ingredients");
> $method=param("method");
> $service=param("service");
> $picture=param("picture");
> $filename= param("filename");
> $imgfilename =  param("imgfilename");
> 
> #build the meta tags for the website search engine
> 
> $meta = $catagory . " " . $name . " " . $description . " " . $source . " " .
> $origin;
> 
> #see if picture file was uploaded
> 
> if   ($picture)    {
> 
> #get image from temporary image directory
> 
> open (TEMPORARY, "</xxx/xxx/x/xx/xx/xxxxx/web/nugget/temp/$imgfilename");
> 
> $temp_img=(TEMPORARY);
> 
> close (TEMPORARY);
> 
> #delete temporary image file
> 
> unlink ("/xxx/xxx/x/xx/xx/xxxxx/web/nugget/temp/$imgfilename");
> 
> #copy image file to the cookbook images directory
> 
> open (IMAGEFILE,
> ">>/xxx/xxx/x/xx/xx/xxxxx/web/nugget/cookbook/images/$imgfilename");
> 

This cold be a red herring (and Im nerw to perl too ! ) but shouldn't 
the above FILEHANDLE be opened with ">" instead of  ">>" ?
> print IMAGEFILE "$temp_img";
> 
> close (IMAGEFILE);
> 
>   }
> 
> #Copy html to the appropriate folder in the cookbook directory
> 
> open (PAGEFILE,
> ">/xxx/xxx/x/xx/xx/xxxxx/web/nugget/cookbook/$catagory/$filename");
> print PAGEFILE qq(<html>\n<head>\n<title>$name</title>\n</head>\n<body>\n);
> print PAGEFILE qq(<META NAME=description CONTENT=$description>\n);
> print PAGEFILE qq(<META NAME=keywords CONTENT= $meta>\n);
> print PAGEFILE qq(<body bgcolor="#e6e6fa" TOPMARGIN=5 LEFTMARGIN=2
> MARGINHEIGHT=0 MARGINWIDTH=2>\n);
> print PAGEFILE qq(<table  width=600 align=center CELLPADDING=0 border=0
> CELLSPACING=0>\n);
> 
> 
Please let me know if thats the problem or I've pointed out a no-go .. :)

Regards
Abhinav



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

Date: Mon, 8 Mar 2004 04:11:41 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Unwanted newline or eol between fields
Message-Id: <slrnc4nsjs.58r.efflandt@typhoon.xnet.com>

On 5 Mar 2004 13:37:55 -0800, Suzie Wilks <wazopst@yahoo.com> wrote:
> This seems so simple, but it's driving me crazy.
> 
> I have a file that looks a bit like this:
> 
>  -0.15     -0.15     -0.20
>  -0.20     -0.20     -0.15
>  -0.15     -0.15     -0.15
> 
> 
>          0.002
>                    0.007
>                              0.038
> 
> But I'd like it to be:
> 
> -0.15     -0.15     -0.20
>  -0.20     -0.20     -0.15
>  -0.15     -0.15     -0.15
>  0.002    0.007     0.038
> 
> (Empty lines between lines are ok. ) I guess I'm supposed to get rid
> of a newline if the next line starts with whitespace, but my regexps
> just aren't doing it. (Or get rid of a newline if it's followed by
> whitespace?)

Newlines vary with the OS (or data source).  So perhaps you are stripping 
linefeeds and forgetting about hidden carriage returns or vice versa.  

"\n" eq "\015\012" in DOS/Win (or web form textarea), "\012" in Unix,
"\015" in Mac (but not sure about OSX which is Unix like).

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/


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

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 V10 Issue 6231
***************************************


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