Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

crusty_collins

by crusty_collins (Friar)
on May 18, 2005 at 16:37 UTC ( [id://458284]=user: print w/replies, xml ) Need Help??


Posts by crusty_collins
Can you tell what $$$\@ means? in Seekers of Perl Wisdom
2 direct replies — Read more / Contribute
by crusty_collins
on Apr 26, 2008 at 23:42
    Just curious, but what does this mean? I was browsing some code from sourceforge and came across a function that starts like this
    sub extract_seed_page($$$\@){ my ($filepath, $keyword, $percent, $phrase_list_ref) = @_;
Sending email only goes to the local domain ?? in Seekers of Perl Wisdom
1 direct reply — Read more / Contribute
by crusty_collins
on Jun 27, 2007 at 17:00
    Got a strange one. I am trying to send mail to clients when their radio station goes down. It works when the email is within the SMTP server domain but not externally. So if my SMTP server is collins.com and my email is chris@collins.com and I set the TO: field to joe@collins.com everything works fine. If the TO: filed is joe@comcast.net nothing ever gets through. Any bright Ideas?
    sub MailSmtp { my $settings = shift(@_); my $stationNumber = shift(@_); my $from = $settings->{fromEmail}; my $reply = $settings->{replyEmail}; my @to = split(/,/,$settings->{emailGroup}); my $subject; my $user = $settings->{user}; my $pass = $settings->{pass}; my $port; if (exists $settings->{port}) { $port = $settings->{port}; }else{ $port = 25; } my $status = $settings->{ports}->{$stationNumber}->{status}; my $relay = $settings->{smtp}; my $smtp; $subject = $settings->{ports}->{$stationNumber}->{id}; $subject = $subject . " is " . $status; my $message = $settings->{message}; $smtp = Net::SMTP->new($relay,Port => $port,Debug => 0,) ; if (!$smtp) { print "\t--[ Could not connect to the email server\n"; return; } $smtp->auth ( $user, $pass); $smtp->mail($from); # use the sender's address here $smtp->recipient($me); # recipient's address $smtp->data(); # Start the mail # Send the header. for $to (@to) { $smtp->datasend("To: $to\n"); } $smtp->datasend("From: $from\n"); $smtp->datasend("Subject: $subject\n"); $smtp->datasend("Content-type: text/plain\n\n"); # Send the body. $smtp->datasend("$message\n"); $smtp->datasend(" "); my $res = $smtp->dataend(); $smtp->quit; # Close the SMTP connection print "Email was ", $res ? '' : 'un', "successful.\n"; return; }
What is the best XML module to use? in Seekers of Perl Wisdom
4 direct replies — Read more / Contribute
by crusty_collins
on Oct 06, 2005 at 12:24
    O great monks, I have a new project in the planning stages that will need to read and write xml files. The xml will be simple but the files could get fairly large. I have been looking around a bit for info on which module to use... There is a LOT out there. I was thinking about using Xpath. Any suggestions? Thanks for all the advice. A good using twig web page http://www.xml.com/pub/a/2001/03/21/xmltwig.html
#!perl Question in Seekers of Perl Wisdom
5 direct replies — Read more / Contribute
by crusty_collins
on Oct 03, 2005 at 13:58
    Monks, I have a slight problem that I think should be easy to overcome. I have the need to run my scripts with #!perl instead of #!/usr/bin/perl. Problem is that even though I have perl in my path I always get a file not found error. Am I missing something? Collins
How many levels of indirection in a Hash? in Seekers of Perl Wisdom
7 direct replies — Read more / Contribute
by crusty_collins
on Jun 07, 2005 at 15:35
    Monks, I am fighting with a nasty little problem of finding out how many levels a HoHoH has for a particular key. I load a Hash with data from a file using Dumper and eval.
    *rvd*startScript : /binlib/mdi/rv/etc/start_rvd *rvd*daemonPort : 7500 *rvd*rrcp*sendRate*bufferSize : 1000 chilsd03*rvd*daemonPort : 9000
    I need to determine the value of daemonPort and all other variables. If I am running on chilsd03 the value would be 9000 but anywhere else it would be 7500. I refer to this as the scope of the variable being either global or local. I need to scope this further to instance where there can be lines like.
    chilsd03*rvd*OUT*daemonPort : 9000
    So, the problem I am facing is that I need to figure out a good way to "walk" the hash and load up global and local values but keeping the integrity of the instances. Ideally I need to end up with a hash of
    0 'rvd' 1 HASH(0x83d6a40) 'daemonPort' => 7500 'daemonProtocol' => 'tcp' 'httpPort' => 7580 'reliability' => 60 'startScript' => '/binlib/mdi/rv/etc/start_rvd' 'version' => 6.9 4 'IN' 5 HASH(0x83d6b0c) 'daemonPort' => 7500 'daemonProtocol' => 'tcp' 'httpPort' => 8590 'instanceName' => 'IN' 'reliability' => 60 'startScript' => '/binlib/mdi/rv/etc/start_rvd' 'version' => 6.9 6 'instances' 7 ARRAY(0x83d68f0) 0 'rvd' 1 'IN' What I get instead 0 'rvd' 1 HASH(0x83d6938) 'daemonPort' => 7500 'daemonProtocol' => 'tcp' 'httpPort' => 7580 'reliability' => 60 'startScript' => '/binlib/mdi/rv/etc/start_rvd' 'version' => 6.9 2 'rrcp' 3 HASH(0x83d8818) 'daemonPort' => 7500 'daemonProtocol' => 'tcp' 'httpPort' => 7580 'reliability' => 60 'startScript' => '/binlib/mdi/rv/etc/start_rvd' 'transmissionBus' => HASH(0x83d87b8) 'driverName' => 'sink,1' 'numBuffers' => 500 'version' => 6.9 4 'OUT' 5 HASH(0x83d6a7c) 'daemonPort' => 9575 'daemonProtocol' => 'tcp' 'httpPort' => 9590 'instanceName' => 'OUT' 'reliability' => 60 'startScript' => '/binlib/mdi/rv/etc/start_rvd' 'version' => 6.9 10 'instances' 11 ARRAY(0x83d67ac) 0 'rvd' 1 'rrcp' 2 'OUT'
setting envirnment variables from array. in Seekers of Perl Wisdom
5 direct replies — Read more / Contribute
by crusty_collins
on May 20, 2005 at 13:07
    Is it possible to populate an array and then use the values as variables? Example
    my @array = qw(daemon=7500 port=tcp resil=60); foreach my $variable (@array) { print "$variable\n"; # do something to set the variable ($var, $value) = split/=/,$variable; now what? }
    AHHHH The $ENV will work just great! Thanks a lot!
    for $var (keys %$VARS) { $ENV{$var} = $$VARS{$var}; }
    works like a champ!
Parse file to Hash of Hash etc. in Seekers of Perl Wisdom
1 direct reply — Read more / Contribute
by crusty_collins
on May 18, 2005 at 13:41
    Oh wise ones... I have the need to parse a file that lists variables. The file format is something like *rvd*daemonPort : 7500 or hostname*rvd*daemonPort : 7500 or could even extend to hostname*rvd*RTD*daemonPort : 7500. So the variables are scoped either globally or locally. Also, the variables will be unknown to me until I parse the file. So, Parsing the file is not difficult. The issue for me is putting the data into a usable array or hash.
    while( <FILE> ) { @tmp = split(/\*/); SWITCH: { for ($i = 0; $i <= $#tmp; $i++) { if ($tmp[$i]) { # make sure the first value is the key. print "Setting key : $KEY\n", if ($Verbose); $KEY = "$tmp[$i]"; # populate the key with the other values # hostname*rvd*daemonPort : 7500 for ($i; $i <= $#tmp; $i++) { # reached the last var populate the va +lue if ( $tmp[$i] =~ /^(\w+)\s+\:\s+([A-Z. +0-9_\/])/ig) { $Vars{$KEY}{$tmp[$i - 1]}{$1} => $2; print "$tmp[$i]"; }else{ $Vars{$KEY}{$tmp[$i]}; } } last SWITCH; } } } } # while <file>
    Obviously this is not going to work correctly. The real problem is getting a hash that looks like this $hash{rvd}{RTD}{daemonPort} => 7500; without knowing how deep I am going to go. Any ideas out there?
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-24 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found