Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

globref to plain text

by Bass-Fighter (Beadle)
on Jan 09, 2009 at 09:34 UTC ( [id://735130]=perlquestion: print w/replies, xml ) Need Help??

Bass-Fighter has asked for the wisdom of the Perl Monks concerning the following question:

hi monks, here is a question for you

I got a program here, and I want to change something in it, but I don't know how... here is a sub of the code:

sub open_log_mail { open my $info, ">c_a.txt"; if ($cc ne 0){ print $info "$cc"; } my $a=@filename; my $n=0; for (my $l=0; $l<$a; $l++){ if ($filename[$n] ne 0){ print $info "$filename[$n]\n"; $filename[$n]=0; } $n++; } close $info; open $info, "<c_a.txt"; print $info; $dbh->do("INSERT INTO items_mma(item, businesstype, direction, destina +tion, nature, role, relcode, project, title, subject, keywords, comme +nts, created, creator, changed, changer, signature, size, status) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", unde +f, ($openvalue, '1', $openvalue, 'MES', $openvalue, '1', $openvalue, +'1', $openvalue, $subject, $openvalue, $info, "$Month-$Day-$Year", 'M +MA', "$Month-$Day-$Year", '1', '1', '1', '1')) or die ("kan niet toev +oegen!"); close $info; }
if I have an E-mail with several attachments and a cc... now I want to have those into $info... at the moment I get a globref, but I want to have there just plain text. but I don't know how, who knows?

ohw and there are 2 places where I look variable ne to 0... I've made the scarlar 0 if it was undifined. that is the reason that I've that in my code

Replies are listed 'Best First'.
Re: globref to plain text
by Corion (Patriarch) on Jan 09, 2009 at 09:40 UTC

    Do you want to read from the file c_a.txt, then?

    Maybe you just want the diamond operator (or File::Slurp):

    my $filename = 'c_a.txt'; open my $fh, '<', $filename or die "Couldn't open '$filename': $!"; print for <$fh>;
      yes, first I write it to c_a.txt and after everything that must be in 1 of the colums of the database is write to c_a.txt. after that I want to get all the text that is stored into c_a.txt send to something that can placed into the colum of the database

        I'm sorry, but I don't understand what you're doing there and why. It would maybe help me help you better if you could tell me the big picture view of things, that is, what goal you are trying to achieve with this program. If all you want to do is accumulate data and then store it in the database, maybe an array is what you want, or possibly just a scalar to which you append new information as it becomes available. See the join function for how to convert an array to a scalar.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://735130]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-29 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found