SEARCH YOUR SOLUTION HERE  

Tie a file handle to a variable

Hi how can I tie a file handle to a variable (probably tie is not the right perl terminology in this case) Basically I want that everything that is written to a file is copied into a variable as well. ...

Posted On: Monday 26th of November 2012 09:01:39 PM Total Views:  355
View Complete with Replies




Related Messages:

help with module naming: filehandle-tie for size-limited/rotating logfile   (136 Views)
I'm about to upload a module, the filehandle-tie for size-limited logs. I did not find existing module in cpan, so I wrote one. Please help me to select the right module name. I am thinking about name Tie::SizeLimitedLog or Tie::RotatingLog. The closest relative is the existing Tie::LogFile (except that Tie::LogFile does not have the size-limiting (rotating) functionality). Which name shall I choose
beginner question on use of Frontier::Client   (247 Views)
I'm attempting to write one of my first perl programs. It is to interact with an internal web service. I'm having something basic going wrong: use Frontier::Client ; # Parameter: # login_id # # Output: # login_id of manager my @supervisor_info; $server = Frontier::Client->new('url' => 'http://serverort/' ); foreach my $empno (@ARGV) { @supervisor_info = Frontier::Client->call('GetInfoByEmpNo', $empno); if ( $#supervisor_info != 0 ) { print "found $empno\n"; } else { print "Unable to locate supervisor for $empno\n"; } ; } As you can see, I'm not trying to do anything with the data yet - in fact, not even looking at the data yet. Just trying to get the basic skeleton working, so that I know, moving on, that the basics are working. Of course, I have a real server and port URL in the new call. And the method name comes from the documentation that the web service have provided. The error I get is: Can't use string ("Frontier::Client") as a HASH ref while "strict refs" in use at /usr/local/perl5/lib/site_perl/5.8.4/Frontier/Client.pm line 53. (where that is the path to the pm file). I appear to be missing something obvious. Given that I have not written many perl programs, it is probably something embarassingly simple. I was wondering if anyone could provide me a kind nudge in the right direction
Namespace Recommendation for Abuse Reporting Utilities Module   (112 Views)
, I've been working on a module for one of my own projects and a few friends suggested that it would be useful for other projects as well. I'm not quite sure where it should fit in namespace wise though. Some of the functions already implemented in the module: get_asn_info - takes an IP, returns a list containing following info about the BGP announcement for the address: ASN, Network, CIDR netmask get_soa_contact - takes an IP, returns the SOA contact email address for the /24 reverse zone the address is in get_ipwi_contacts - takes an IP, returns a list of unique email addresses found in the whois information for the IP get_dnsbl_listing - takes an IP and an DNSBL zone, returns the listing text if the IP is listed or undef get_abusenet_contact - takes a domain, returns the Abuse.net listed contact address(es) Plus a few other more trivial functions. I also have a few functions yet to implement. My purpose for this module is a spam reporting script I'm working on so I've named it SpamUtils. In CPAN this would probably be Mail::SpamUtils but this module would be useful for other forms of abuse as well so perhaps something along the lines of Net::AbuseUtils There is a Net::Abuse but it's purpose is the automated processing of inbound abuse reports. I would appreciate any feedback you may have on namespace as well as features you would be interested in having in such a module. Michael
Global symbol "%Properties" requires explicit package name   (135 Views)
* mike wrote in comp.lang.perl.misc: >I have declared my %Properties but I get the following when I execute: > >Global symbol "%Properties" requires explicit package name at test.pl >line 62. >Do I have to make some declaration within the sub When checking whether your variables have been declared prior to their use, perl checks how they occur in the source code, it ignores how the program would be executed. You have to declare %Properties before any use of it can be seen in the source code. -- Bjrn Hhrmann mailto:bjoern@hoehrmann.de http://bjoern.hoehrmann.de Weinh. Str. 22 Telefon: +49(0)621/4309674 http://www.bjoernsworld.de 68309 Mannheim PGP Pub. KeyID: 0xA4357E78 http://www.websitedev.de/
FAQ 4.62 Why don't my tied hashes make the defined/exists distinction?   (131 Views)
This is an excerpt from the latest version perlfaq4.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 . -------------------------------------------------------------------- 4.62: Why don't my tied hashes make the defined/exists distinction This depends on the tied hash's implementation of EXISTS(). For example, there isn't the concept of undef with hashes that are tied to DBM* files. It also means that exists() and defined() do the same thing with a DBM* file, and what they end up doing is not what they do with ordinary hashes. -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
2 issues with "tie"   (93 Views)
I seem to be running into some issues with tie in perl 5.8.8 with the defined-or patch from the FreeBSD ports. I use : use NDBM_File; use Fcntl; I open up my file as : tie (%fdb,'NDBM_File',"file.victims",O_RDWR|O_CREAT,0777) ||die $!; I write to it as $fdb{$_}="TUC"; I close it as : untie %fdb; Seems pretty basic. But I've got 2 issues. 1) If $_="Fred", and the program iterates and does $fdb{'Fred'}="TUC"; , if I immediately start another program up to read "Fred" from the file, it claims it doesn't exist. As if it hasn't sync'd. As soon as I do the "untie %fdb;", then the data becomes available. Is there a way that as soon as I $fdb{'Fred'}="TUC"; it becomes accessible 2) I also have the issue that if I'm running my program, and I hit CNTRL-C to stop it, none of the values I've $fdb{$_}="TUC"; end up getting and staying set. So the next time the program runs, and checks to see if its already in the data store, it says its not and re- executes the command. Is there some way that once its set its "committed" per se
funzy.com http://geocities.com/it_super_manager/   (125 Views)
funzy.com http://geocities.com/it_super_manager/
FAQ 4.62 Why don't my tied hashes make the defined/exists distinction?   (130 Views)
This is an excerpt from the latest version perlfaq4.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 . -------------------------------------------------------------------- 4.62: Why don't my tied hashes make the defined/exists distinction This depends on the tied hash's implementation of EXISTS(). For example, there isn't the concept of undef with hashes that are tied to DBM* files. It also means that exists() and defined() do the same thing with a DBM* file, and what they end up doing is not what they do with ordinary hashes. -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
Odd DBM::Deep behavior "cannot store tied value" using literal key name   (117 Views)
Hi all, I am trying to create a test script for some work I'm trying to do with Data::Compare using DBM:eep, but the test code is acting flaky and I'm not sure why. In a previous (and working) script, I have a DBM:eep hash keyed using IP addresses. Inside the hash is an array that contains several values including an array reference and a hash reference. This works fine. The test script is a different story. Here's the code: ------------------------------- #!/perl/bin/perl use strict; use warnings; use Data::Compare; use DBM:eep; my $database = &OpenDB("test.db"); my %testhash = ( 'bob' => 23, 'alice' => 20 ); my @old = ("00-99-48-AF-46-43", "W117", 1, 1197390385, \%testhash); my @same = ("00-99-48-AF-46-43", "W117", 1, 1197390385, \%testhash); my %newhash = ( 'bob' => 23, 'alice' => 24 ); my @new = ("00-99-48-AF-46-43", "W117", 1, 1197390385, \%newhash); my $ip1 = "144.1"; my $ip2 = "145.2"; my $ip3 = "146.3"; $database->{$ip1} = \@old; # Uncomment the line directly below to generate error # $database->{$ip2} = \@same; # $database->{$ip3} = \@new; my @test_old = @{$database->{$ip1}}; # my @test_same = @{$database->{$ip2}}; # my @test_new = @{$database->{$ip3}}; sub OpenDB { # Argument(s): A string containing the database filename to be used. # Returned: A scalar reference holding the database object. # Globals: None. my ($filename) = @_; my $db = DBM:eep->new( file => $filename, locking => 1, autoflush => 1 ); # Test: see if removing this increases speed return($db); } ------------------------------- The above code works as-is, but if I uncomment the line(s) above (marked with a comment), I get the error: DBM:eep: Cannot store a tied value. Why is that
a newbie encounters difficulties in using module   (141 Views)
I'm testing the codes obtained from internet: use Imager; use Imager::Plot; $plot = Imager::Plot->new(Width => 550, Height => 350, GlobalFont => 'ImUgly.ttf'); my @X = 0..100; my @Y = map { sin($_/10) } @X; my @Z = map { 1+cos($_/10) ...
$$$$$$$www.200836.com , September 2000, Sydney -- Information meetingbetween the IOC and the Candidate Cities.   (122 Views)
$$$$$$$$$ www.200836.com--- why we buy Peking 2008 Olympic Games-- souvenirs 1 low price 2 best quality-- licensed products by Peking Organizing Committee 3 many products to choose 4 most precious--limited circulation 1 our website www.200836 was aimed at that all ...
how do i tie a reference to a hash   (114 Views)
I'm trying to tie a hash that is returned from a DBI method called fetchrow_hashref. I want to do is override the FETCH method to validate my key names. But fetchrow_hashref returns a reference to a hash, not ...
How to tie with YAML but also have flock support?   (145 Views)
Which modules support flock with tie to YAML Is there a way Tie::YAML supports flock...
tie - any alternatives?   (165 Views)
I am researching tie as a means to pass huge complex data structure ( an array of hash references ) between scripts ( and not textify the hash refs ) but I apparently don't have tie installed. Is there ...
decode_entities possible bug?   (209 Views)
decode_entities does not appear to decode this text The sequence &#8226 is left untouched. Is this correct/expected behavior, a bug, or what
Redhat 9.0 ftp Incompatabilities?   (88 Views)
the first question has nothing to do with Perl, can anyone tell me why: 1. When I ftp a file from RH 9.0 to AIX, regardless of transfer mode (binary or ASCII), the resultant file always has "^M"s appended ...
Redhat 9.0 ftp Incompatabilities?   (69 Views)
the first question has nothing to do with Perl, can anyone tell me why: 1. When I ftp a file from RH 9.0 to AIX, regardless of transfer mode (binary or ASCII), the resultant file always has "^M"s appended ...
[ANNOUNCE] MathML::Entities::Approximated (take II)   (89 Views)
Announcing the Perl Package MathML::Entities::Approximated (version 0.20) [Re-announced with complete details this time] -- quote -- A subclass of MathML::Entities that supplies ASCII-approximate characters for XHTML+MathML Named Entities. XHTML+MathML named entities in the argument of name2approximated() are replaced by the ...
Windows amenities   (105 Views)
I've found an example online that shows how to handle Systray behaviour in Windows, so that's not too much of a problem. What I -do- need to know is how to make a Tk app disappear from the Alt-Tab task ...
scalar(%tied_hash)   (115 Views)
I'm creating a tied hash, and evaluating it in a scalar context. Like a standard hash, I'd like it to yield 0 if empty, and non-zero if populated. Ideally, I'd like it to yield the number of elements in the ...