I need help here
Hi, I am very new to PERL and I need a program to do following task. Can u help me pls. I have a file with following contents. 454 NV_DS_DEFAULT_BAUDRATE_I 455 NV_DIAG_DEFAULT_BAUDRATE_I 516 NV_WCDMA_RX_LIN_VS_TEMP_I I am expecting out put like NV_DS_DEFAULT_BAUDRATE_I 454 NV_DIAG_DEFAULT_BAUDRATE_I 455 NV_WCDMA_RX_LIN_VS_TEMP_I 516 Basically it is interchanging of columns. Looking forward for your help. Sreedhar Reddy T. Sr. Engineer. Business Objects, Ness Technologies India Ltd.
Re: implementing links on a system command output
Derek Smith/Staff/OhioH ealth To beginners-cgi@perl.org 10/12/2005 05:52 cc PM Subject implementing links on a system command output I have written a CGI Perl program that allows my users to view relevant data. The data is produced by a Unix application command and I have told it to write to a intranet page that looks like: |--| | ( ) | |--|All-Clients |--| | ( ) | |--|Backup-Tapes |--| | ( ) | |--|PACS-Fuji |--| | (*) | |--|Heartlab |--| | ( ) | |--|StreamLine-Health |--| | ( ) | |--|Archiver-Status |--| | ( ) | |--|Tape-Drive-Status |--| | ( ) | |--|Tape-Capacity fs_heartlab.1 sort:path media: sg Volumes: H01190 H01191 H01192 H01193 Total space available: 74.0G What I want to do now is create a link using CGI Perl for each H string that will pull a different data set either on a new page or on the same page embedded. Originally I just created another radio button for the new data set, but there will be 6 different views (6 different strings) and I already have 7 buttons (minus the Tape-Capacity button) and I do not want to button out myself or the users. I looked in the CGI Programming with Perl and saw an entry in there on page 269 referencing access.conf and in access.conf you enter a line with Action Tracker /cgi/track.cgi Can anyone help? thx derek Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams *** Can anyone respond please -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: implementing links on a system command output
On Friday October 14 2005 11:21 am, [EMAIL PROTECTED] wrote: Derek Smith/Staff/OhioH ealth To beginners-cgi@perl.org 10/12/2005 05:52 cc PM Subject implementing links on a system command output I have written a CGI Perl program that allows my users to view relevant data. The data is produced by a Unix application command and I have told it to write to a intranet page that looks like: |--| | ( ) | |--|All-Clients |--| | ( ) | |--|Backup-Tapes |--| | ( ) | |--|PACS-Fuji |--| | (*) | |--|Heartlab |--| | ( ) | |--|StreamLine-Health |--| | ( ) | |--|Archiver-Status |--| | ( ) | |--|Tape-Drive-Status |--| | ( ) | |--|Tape-Capacity fs_heartlab.1 sort:path media: sg Volumes: H01190 H01191 H01192 H01193 Total space available: 74.0G What I want to do now is create a link using CGI Perl for each H string that will pull a different data set either on a new page or on the same page embedded. Originally I just created another radio button for the new data set, but there will be 6 different views (6 different strings) and I already have 7 buttons (minus the Tape-Capacity button) and I do not want to button out myself or the users. I looked in the CGI Programming with Perl and saw an entry in there on page 269 referencing access.conf and in access.conf you enter a line with Action Tracker /cgi/track.cgi Can anyone help? thx derek Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams *** Can anyone respond please I'm not getting your problem ... The page you referenced in that book refers to setting up the Apache web server to handle state saving extra path info. basicaly your linking a requested url to a cgi script. at the server level. have fun , me I'd just make each string produced into a clickable link that would produce another page directly. Greg -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: implementing links on a system command output
On Fri, 14 Oct 2005 [EMAIL PROTECTED] wrote: I have written a CGI Perl program that allows my users to view relevant data. The data is produced by a Unix application command and I have told it to write to a intranet page that looks like: What it looks like is irrelevant. The raw HTML is a little bit relevant, but the really relevant thing is the data that gets sent to the script and the results that are expected to be returned from the script. What I want to do now is create a link using CGI Perl for each H string that will pull a different data set either on a new page or on the same page embedded. Originally I just created another radio button for the new data set, but there will be 6 different views (6 different strings) and I already have 7 buttons (minus the Tape-Capacity button) and I do not want to button out myself or the users. I looked in the CGI Programming with Perl and saw an entry in there on page 269 referencing access.conf and in access.conf you enter a line with Action Tracker /cgi/track.cgi Can anyone help? I'm sorry, I'm confused by the question. You seem to want help organizing how data is presented to and retrieved from the user of your web application, but then you're asking a CGI list how to go about doing advanced Apache web server configuration. How was the access.conf suggestion supposed to help solve this problem? IF the answer to your problem is to start mucking around with Apache directives -- and so far I'm not convinced that it is -- then putting those directives in access.conf is outdated advice anyway. Modern Apache administration tends to have people put everything in httpd.conf so that there's one file to look in; some people break things into separate conf files that httpd.conf includes, but this generally isn't how it's done by people just getting started with Apache administration now. In any case, it isn't clear to me how this was supposed to solve your problem to begin with. What were you hoping would happen if you changed the behavior of /cgi/track.cgi in Apache? I think you're better off just concentrating on your HTML and CGI code for now, and leave mucking with the web server for later. Reduce the problem to a flow of desired inputs and outputs. The inputs are generally going to be forms in plain HTML documents or as generated by the output from CGI scripts; the outputs will generally be generated from CGI scripts, though in some cases could be static HTML, too. You may want to sketch things out on paper rather than just blindly start coding things. If some part of the input system is doing too much or is too confusing for users or maintainers, then break it apart as needed. You seem to be asking general systems design questions without giving enough material to clarify what the system is doing now or how it is supposed to be working differently in the future. This is only tangentally a CGI question; your first priority here seems to be to sort out exactly how this is all supposed to be interoperating in the first place. Once you have a clearer sense of that, implementing the specific components of the system should get easier for you. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: implementing links on a system command output
On 10/14/05, Chris Devers [EMAIL PROTECTED] wrote: On Fri, 14 Oct 2005 [EMAIL PROTECTED] wrote: I have written a CGI Perl program that allows my users to view relevant data. The data is produced by a Unix application command and I have told it to write to a intranet page that looks like: What it looks like is irrelevant. The raw HTML is a little bit relevant, but the really relevant thing is the data that gets sent to the script and the results that are expected to be returned from the script. What I want to do now is create a link using CGI Perl for each H string that will pull a different data set either on a new page or on the same page embedded. Originally I just created another radio button for the new data set, but there will be 6 different views (6 different strings) and I already have 7 buttons (minus the Tape-Capacity button) and I do not want to button out myself or the users. I looked in the CGI Programming with Perl and saw an entry in there on page 269 referencing access.conf and in access.conf you enter a line with Action Tracker /cgi/track.cgi Can anyone help? I'm sorry, I'm confused by the question. You seem to want help organizing how data is presented to and retrieved from the user of your web application, but then you're asking a CGI list how to go about doing advanced Apache web server configuration. How was the access.conf suggestion supposed to help solve this problem? IF the answer to your problem is to start mucking around with Apache directives -- and so far I'm not convinced that it is -- then putting those directives in access.conf is outdated advice anyway. Modern Apache administration tends to have people put everything in httpd.conf so that there's one file to look in; some people break things into separate conf files that httpd.conf includes, but this generally isn't how it's done by people just getting started with Apache administration now. In any case, it isn't clear to me how this was supposed to solve your problem to begin with. What were you hoping would happen if you changed the behavior of /cgi/track.cgi in Apache? I think you're better off just concentrating on your HTML and CGI code for now, and leave mucking with the web server for later. Reduce the problem to a flow of desired inputs and outputs. The inputs are generally going to be forms in plain HTML documents or as generated by the output from CGI scripts; the outputs will generally be generated from CGI scripts, though in some cases could be static HTML, too. You may want to sketch things out on paper rather than just blindly start coding things. If some part of the input system is doing too much or is too confusing for users or maintainers, then break it apart as needed. You seem to be asking general systems design questions without giving enough material to clarify what the system is doing now or how it is supposed to be working differently in the future. This is only tangentally a CGI question; your first priority here seems to be to sort out exactly how this is all supposed to be interoperating in the first place. Once you have a clearer sense of that, implementing the specific components of the system should get easier for you. -- Chris Devers And at the risk of sounding more Chris than Chris on this thread: What have you tried? Where did it go wrong? Where's your code? I have to say, I'm not getting this either. Is your question about getting CGI.pm to generate dynamic content based on system command output? Or is your question simply how to declutter a page full of radio buttons? Or is your question something else entirely? Whichever it is, giving some specific code you're having trouble with will get you a better, more useful answer faster, if only because it makes what you're trying to do clearer. But then you should really know that by now. --jay -- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!
Re: implementing links on a system command output
Jay Savage [EMAIL PROTECTED] l.com To beginners-cgi@perl.org 10/14/2005 11:56 cc AM Subject Re: implementing links on a system command output On 10/14/05, Chris Devers [EMAIL PROTECTED] wrote: On Fri, 14 Oct 2005 [EMAIL PROTECTED] wrote: I have written a CGI Perl program that allows my users to view relevant data. The data is produced by a Unix application command and I have told it to write to a intranet page that looks like: What it looks like is irrelevant. The raw HTML is a little bit relevant, but the really relevant thing is the data that gets sent to the script and the results that are expected to be returned from the script. What I want to do now is create a link using CGI Perl for each H string that will pull a different data set either on a new page or on the same page embedded. Originally I just created another radio button for the new data set, but there will be 6 different views (6 different strings) and I already have 7 buttons (minus the Tape-Capacity button) and I do not want to button out myself or the users. I looked in the CGI Programming with Perl and saw an entry in there on page 269 referencing access.conf and in access.conf you enter a line with Action Tracker /cgi/track.cgi Can anyone help? I'm sorry, I'm confused by the question. You seem to want help organizing how data is presented to and retrieved from the user of your web application, but then you're asking a CGI list how to go about doing advanced Apache web server configuration. How was the access.conf suggestion supposed to help solve this problem? IF the answer to your problem is to start mucking around with Apache directives -- and so far I'm not convinced that it is -- then putting those directives in access.conf is outdated advice anyway. Modern Apache administration tends to have people put everything in httpd.conf so that there's one file to look in; some people break things into separate conf files that httpd.conf includes, but this generally isn't how it's done by people just getting started with Apache administration now. In any case, it isn't clear to me how this was supposed to solve your problem to begin with. What were you hoping would happen if you changed the behavior of /cgi/track.cgi in Apache? I think you're better off just concentrating on your HTML and CGI code for now, and leave mucking with the web server for later. Reduce the problem to a flow of desired inputs and outputs. The inputs are generally going to be forms in plain HTML documents or as generated by the output from CGI scripts; the outputs will generally be generated from CGI scripts, though in some cases could be static HTML, too. You may want to sketch things out on paper rather than just blindly start coding things. If some part of the input system is doing too much or is too confusing for users or maintainers, then break it apart as needed. You seem to be asking general systems design questions without giving enough material to clarify what the system is doing now or how it is supposed to be working differently in the future. This is only tangentally a CGI question; your first priority here seems to be to sort out exactly how this is all supposed to be interoperating in the first place. Once you have a clearer sense of that, implementing the specific components of the system should get easier for you. -- Chris Devers And at the risk of sounding more Chris than Chris on this thread: What have you tried? Where did it go wrong? Where's your code? I have to say, I'm not getting this either. Is your question about getting CGI.pm to generate dynamic content based on system command output? Or is your question simply how to declutter a page full of radio buttons? Or is your question something else entirely? Whichever it is, giving some specific code you're having trouble with will get you a
Re: implementing links on a system command output
On Friday October 14 2005 12:07 pm, [EMAIL PROTECTED] wrote: Jay Savage [EMAIL PROTECTED] l.com To beginners-cgi@perl.org 10/14/2005 11:56 cc AM Subject Re: implementing links on a system command output On 10/14/05, Chris Devers [EMAIL PROTECTED] wrote: On Fri, 14 Oct 2005 [EMAIL PROTECTED] wrote: I have written a CGI Perl program that allows my users to view relevant data. The data is produced by a Unix application command and I have told it to write to a intranet page that looks like: What it looks like is irrelevant. The raw HTML is a little bit relevant, but the really relevant thing is the data that gets sent to the script and the results that are expected to be returned from the script. What I want to do now is create a link using CGI Perl for each H string that will pull a different data set either on a new page or on the same page embedded. Originally I just created another radio button for the new data set, but there will be 6 different views (6 different strings) and I already have 7 buttons (minus the Tape-Capacity button) and I do not want to button out myself or the users. I looked in the CGI Programming with Perl and saw an entry in there on page 269 referencing access.conf and in access.conf you enter a line with Action Tracker /cgi/track.cgi Can anyone help? I'm sorry, I'm confused by the question. You seem to want help organizing how data is presented to and retrieved from the user of your web application, but then you're asking a CGI list how to go about doing advanced Apache web server configuration. How was the access.conf suggestion supposed to help solve this problem? IF the answer to your problem is to start mucking around with Apache directives -- and so far I'm not convinced that it is -- then putting those directives in access.conf is outdated advice anyway. Modern Apache administration tends to have people put everything in httpd.conf so that there's one file to look in; some people break things into separate conf files that httpd.conf includes, but this generally isn't how it's done by people just getting started with Apache administration now. In any case, it isn't clear to me how this was supposed to solve your problem to begin with. What were you hoping would happen if you changed the behavior of /cgi/track.cgi in Apache? I think you're better off just concentrating on your HTML and CGI code for now, and leave mucking with the web server for later. Reduce the problem to a flow of desired inputs and outputs. The inputs are generally going to be forms in plain HTML documents or as generated by the output from CGI scripts; the outputs will generally be generated from CGI scripts, though in some cases could be static HTML, too. You may want to sketch things out on paper rather than just blindly start coding things. If some part of the input system is doing too much or is too confusing for users or maintainers, then break it apart as needed. You seem to be asking general systems design questions without giving enough material to clarify what the system is doing now or how it is supposed to be working differently in the future. This is only tangentally a CGI question; your first priority here seems to be to sort out exactly how this is all supposed to be interoperating in the first place. Once you have a clearer sense of that, implementing the specific components of the system should get easier for you. -- Chris Devers And at the risk of sounding more Chris than Chris on this thread: What have you tried? Where did it go wrong? Where's your code? I have to say, I'm not getting this either. Is your question about getting CGI.pm to generate dynamic content based on system command output? Or is your question simply how to declutter a page full of radio buttons? Or is your question something else entirely? Whichever it is, giving some specific code you're having trouble with will get you a better, more useful answer faster, if only because it makes what you're trying to do clearer. But then you should really know that by now. --jay *** ok I apologize for the Apache access.conf file question, my confusion which is the whole problem. I have no new code b/c in my CGI book I cannot find anything that would give me a kickstart on generating code other that using the common A HREF tag. what I want is exactly what Greg stated: me I'd just make each string produced into a clickable link that
Re: implementing links on a system command output
Greg Jetter [EMAIL PROTECTED] n.com To beginners-cgi@perl.org 10/14/2005 02:46 cc PM Subject Re: implementing links on a system command output On Friday October 14 2005 12:07 pm, [EMAIL PROTECTED] wrote: Jay Savage [EMAIL PROTECTED] l.com To beginners-cgi@perl.org 10/14/2005 11:56 cc AM Subject Re: implementing links on a system command output On 10/14/05, Chris Devers [EMAIL PROTECTED] wrote: On Fri, 14 Oct 2005 [EMAIL PROTECTED] wrote: I have written a CGI Perl program that allows my users to view relevant data. The data is produced by a Unix application command and I have told it to write to a intranet page that looks like: What it looks like is irrelevant. The raw HTML is a little bit relevant, but the really relevant thing is the data that gets sent to the script and the results that are expected to be returned from the script. What I want to do now is create a link using CGI Perl for each H string that will pull a different data set either on a new page or on the same page embedded. Originally I just created another radio button for the new data set, but there will be 6 different views (6 different strings) and I already have 7 buttons (minus the Tape-Capacity button) and I do not want to button out myself or the users. I looked in the CGI Programming with Perl and saw an entry in there on page 269 referencing access.conf and in access.conf you enter a line with Action Tracker /cgi/track.cgi Can anyone help? I'm sorry, I'm confused by the question. You seem to want help organizing how data is presented to and retrieved from the user of your web application, but then you're asking a CGI list how to go about doing advanced Apache web server configuration. How was the access.conf suggestion supposed to help solve this problem? IF the answer to your problem is to start mucking around with Apache directives -- and so far I'm not convinced that it is -- then putting those directives in access.conf is outdated advice anyway. Modern Apache administration tends to have people put everything in httpd.conf so that there's one file to look in; some people break things into separate conf files that httpd.conf includes, but this generally isn't how it's done by people just getting started with Apache administration now. In any case, it isn't clear to me how this was supposed to solve your problem to begin with. What were you hoping would happen if you changed the behavior of /cgi/track.cgi in Apache? I think you're better off just concentrating on your HTML and CGI code for now, and leave mucking with the web server for later. Reduce the problem to a flow of desired inputs and outputs. The inputs are generally going to be forms in plain HTML documents or as generated by the output from CGI scripts; the outputs will generally be generated from CGI scripts, though in some cases could be static HTML, too. You may want to sketch things out on paper rather than just blindly start coding things. If some part of the input system is doing too much or is too confusing for users or maintainers, then break it apart as needed. You seem to be asking general systems design questions without giving enough material to clarify what the system is doing now or how it is supposed to be working differently in the future. This is only tangentally a CGI question; your first priority here seems to be to sort out exactly how this is all supposed to be interoperating in the first place. Once you have a clearer sense of that, implementing the specific components of the system should get easier for you. -- Chris Devers And at the risk of
Getting started on standalone Windows machine
Hi all, I have perl cgi installed successfully on my windows machine. I would like to write a perl cgi program and display it in the browser on my own Windows XP machine. To this end, I followed instructions in L. Stein's book and created a registry ScriptMap called .pl of type REG_SZ with value 'C:\perl\bin\perl.exe %s %s'. The value is the correct one for my system. However, when I open a .pl cgi file (known to work, because I can open it OK with the DZSoft editor) in the browser, the perl interpreter is not called and all I get is the text file displayed in the browser window. Is it possible to view the file in a browser on my system? Or must I have a web page on the server across campus and ftp the files there every time I want to do something? Thanks Mary -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: I need help here
On Oct 14, 2005, at 7:22 AM, Sreedhar reddy wrote: Hi, I am very new to PERL and I need a program to do following task. Can u help me pls. I have a file with following contents. 454 NV_DS_DEFAULT_BAUDRATE_I 455 NV_DIAG_DEFAULT_BAUDRATE_I 516 NV_WCDMA_RX_LIN_VS_TEMP_I I am expecting out put like NV_DS_DEFAULT_BAUDRATE_I 454 NV_DIAG_DEFAULT_BAUDRATE_I 455 NV_WCDMA_RX_LIN_VS_TEMP_I 516 Basically it is interchanging of columns. Looking forward for your help. This should help get you started code #!/usr/bin/perl use strict; my $output; my @record_list = ('454 NV_DS_DEFAULT_BAUDRATE_I', '455 NV_DIAG_DEFAULT_BAUDRATE_I', '516 NV_WCDMA_RX_LIN_VS_TEMP_I'); for my $items(@record_list) { my ($number, $name) = split(/ /, $items); $output .= $name $number\n; } print $output; /code Kindest Regards, -- Bill Stephenson 417-546-8390 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
ENV(Y)?
Hi there! I'd like to get a list of enviromentvariables from the *NIX-system. I'd like it in the format... ENV1=x1 ENv2=x2 ENV3=x3 and so on... I think I have to use ENV-command. (http://perldoc.perl.org/Env.html) Is that right? I don't understand how I get this kind of listing. Please put me in right direction.. I tried to use print ENV% but I get this kind of output: HOSTfriggAUDIODEV/tmp/SUNWut/dev/utaudio/8dtstart_sessionlogfile/dev/nullDTSCREENSAVERLISTStartDtscreenBlankXMBINDDIR/usr/dt/lib/bindingsUTAUDIODEV/tmp/SUNWut/dev/utaudio/8AB_CARDCATALOG/usr/dt/share/answerbooks/C/ab_cardcatalogLC_ALLCDTLOGINDISPLAYCLASSSunRayOSTY I envy you how can solve this... :-) /G http://www.varupiraten.se/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: ENV(Y)?
Hi Gustav - At 2005-10-13, 23:13:33 you wrote: Hi there! I'd like to get a list of enviromentvariables from the *NIX-system. I'd like it in the format... ENV1=x1 ENv2=x2 ENV3=x3 and so on... I think I have to use ENV-command. (http://perldoc.perl.org/Env.html) Is that right? I don't understand how I get this kind of listing. Please put me in right direction.. I tried to use print ENV% but I get this kind of output: HOSTfriggAUDIODEV/tmp/SUNWut/dev/utaudio/8dtstart_sessionlogfile/dev/nullDTSCREENSAVERLISTStartDtscreenBlankXMBINDDIR/usr/dt/lib/bindingsUTAUDIODEV/tmp/SUNWut/dev/utaudio/8AB_CARDCATALOG/usr/dt/share/answerbooks/C/ab_cardcatalogLC_ALLCDTLOGINDISPLAYCLASSSunRayOSTY I envy you how can solve this... :-) You're almost there. %ENV is a hash, do you can do something like this: print $_=$ENV{$_}\n for sort keys %ENV; Or, with more keystrokes: for my $var( sort keys %ENV ) { print $var=$ENV{$var}\n; } Read up on hashes good luck. /G Aloha = Beau; [EMAIL PROTECTED] 2005-10-13 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: ENV(Y)?
Hi! Thanx a LOT!!! /G http://www.varupiraten.se/ Hi Gustav - At 2005-10-13, 23:13:33 you wrote: Hi there! I'd like to get a list of enviromentvariables from the *NIX-system. I'd like it in the format... ENV1=x1 ENv2=x2 ENV3=x3 and so on... I think I have to use ENV-command. (http://perldoc.perl.org/Env.html) Is that right? I don't understand how I get this kind of listing. Please put me in right direction.. I tried to use print ENV% but I get this kind of output: HOSTfriggAUDIODEV/tmp/SUNWut/dev/utaudio/8dtstart_sessionlogfile/dev/nullDTSCREENSAVERLISTStartDtscreenBlankXMBINDDIR/usr/dt/lib/bindingsUTAUDIODEV/tmp/SUNWut/dev/utaudio/8AB_CARDCATALOG/usr/dt/share/answerbooks/C/ab_cardcatalogLC_ALLCDTLOGINDISPLAYCLASSSunRayOSTY I envy you how can solve this... :-) You're almost there. %ENV is a hash, do you can do something like this: print $_=$ENV{$_}\n for sort keys %ENV; Or, with more keystrokes: for my $var( sort keys %ENV ) { print $var=$ENV{$var}\n; } Read up on hashes good luck. /G Aloha = Beau; [EMAIL PROTECTED] 2005-10-13 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
using XS for calling exported methods from a DLL
Hi Is there a way to call exported methods from a DLL without using win32::API. Has anyone tried calling an exported function from C DLL in a Perl Program using XS. I have a C DLL's source file and its header file and using h2xs D:\DLLProjects\simpledll3h2xs -n ext2 simpledll3.h Writing ext2/ext2.pm Writing ext2/ext2.xs Writing ext2/Makefile.PL Writing ext2/README Writing ext2/test.pl Writing ext2/Changes Writing ext2/MANIFEST D:\DLLProjects\simpledll3cd ext2 D:\DLLProjects\simpledll3\ext2perl makefile.pl Checking if your kit is complete... Looks good Writing Makefile for ext2 D:\DLLProjects\simpledll3\ext2nmake Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. C:\Perl\bin\perl.exe -Ic:\Perl\lib -Ic:\Perl\lib C:\Perl\lib\ExtUtils/xs ubpp -typemap C:\Perl\lib\ExtUtils\typemap ext2.xs ext2.xsc C:\Perl\bin\pe rl.exe -Ic:\Perl\lib -Ic:\Perl\lib -MExtUtils::Command -e mv ext2.xsc ext2.c cl -c -nologo -O1 -MD -Zi -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAV E_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX - O1 -MD -Zi -DNDEBUG-DVERSION=\0.01\ -DXS_VERSION=\0.01\ -IC:\Perl\lib\ CORE ext2.c ext2.c cl -c -nologo -O1 -MD -Zi -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAV E_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX - O1 -MD -Zi -DNDEBUG-DVERSION=\0.01\ -DXS_VERSION=\0.01\ -IC:\Perl\lib\ CORE simpledll3.cpp simpledll3.cpp Running Mkbootstrap for ext2 () C:\Perl\bin\perl.exe -Ic:\Perl\lib -Ic:\Perl\lib -MExtUtils::Command -e chmod 644 ext2.bs link -out:blib\arch\auto\ext2\ext2.dll -dll -nologo -nodefaultlib -debug -opt:ref,icf -libpath:c:\Perl\lib\CORE -machine:x86 ext2.obj simpledll3.obj C:\Perl\lib\CORE\perl56.lib C:\Program Files\Microsoft Visual Studio\VC98\Li b\oldnames.lib C:\Program Files\Microsoft Visual Studio\VC98\Lib\kernel32.lib C:\Program Files\Microsoft Visual Studio\VC98\Lib\user32.lib C:\Program File s\Microsoft Visual Studio\VC98\Lib\gdi32.lib C:\Program Files\Microsoft Visual Studio\VC98\Lib\winspool.lib C:\Program Files\Microsoft Visual Studio\VC98\L ib\comdlg32.lib C:\Program Files\Microsoft Visual Studio\VC98\Lib\advapi32.lib C:\Program Files\Microsoft Visual Studio\VC98\Lib\shell32.lib C:\Program Fi les\Microsoft Visual Studio\VC98\Lib\ole32.lib C:\Program Files\Microsoft Visu al Studio\VC98\Lib\oleaut32.lib C:\Program Files\Microsoft Visual Studio\VC98\ Lib\netapi32.lib C:\Program Files\Microsoft Visual Studio\VC98\Lib\uuid.lib C:\Program Files\Microsoft Visual Studio\VC98\Lib\wsock32.lib C:\Program Files \Microsoft Visual Studio\VC98\Lib\mpr.lib C:\Program Files\Microsoft Visual St udio\VC98\Lib\winmm.lib C:\Program Files\Microsoft Visual Studio\VC98\Lib\ver sion.lib C:\Program Files\Microsoft Visual Studio\VC98\Lib\odbc32.lib C:\Pro gram Files\Microsoft Visual Studio\VC98\Lib\odbccp32.lib C:\Program Files\Micr osoft Visual Studio\VC98\Lib\msvcrt.lib -def:ext2.def Creating library blib\arch\auto\ext2\ext2.lib and object blib\arch\auto\ext2\ ext2.exp ext2.obj : error LNK2001: unresolved external symbol _num blib\arch\auto\ext2\ext2.dll : fatal error LNK1120: 1 unresolved externals NMAKE : fatal error U1077: 'C:\WINNT\system32\cmd.exe' : return code '0x460' Stop. where num is the exported method which I have written in teh file SimpleDLL3.cpp int _stdcall num(int x) { return x+1; } I have written the XSUB in ext2.xs file as shown below: int num(x) int x Why does it give an error for _num or for that matter any exported function name. Any help would be greatly appreciated. Thanks, Sam. _ A Camera Sells every 2 Minutes on eBay.Get Your's at a Great Price Now! http://adfarm.mediaplex.com/ad/ck/4686-26272-10936-699?ck=Cameras -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Space proplem
Hi There; i have this problem of space in my program. The program requires a user to send in Either GU1 or TR1. When they send GU1 or TR1 it accepts it and that is fine. But My concern is; if they send GU 1 or TR 1(Leaving spaces before the number) then the program doesn't accept. It goes straight to the else statement. Please check the code, i'm a begginer in programming please someone help me.. This is just part of the code; #!/usr/bin/perl -w use DBI; $dsn= "dbi:mysql:db_manofthematch:localhost";my $user= "mysql";my $password = "mysql123";$dbh = DBI-connect($dsn,$user,$password); ##GET ARGS ##$msg = $ARGV[1];$source = $ARGV[0]; $msg =~ s/\"/'/igx; $time = localtime();open (OUTFILE ,"C:\\logs\\man.txt");print OUTFILE "$time\t$source\t$msg\n";close(OUTFILE); $found = 0; GU if (($msg=~ /gu1/i) ($msg !~ /gu1[0123456789]+/i)){$vote = 'gu1';$found = 1;} else {print ".Erro.";}$dbh-disconnect;exit; Please help me...
Re: ENV(Y)?
Hi! Just a quick question. Can I set or unset an enviromentvariable through this Hash? I just need a yes ... :-) If No, please give explanation... /G http://www.varupiraten.se/ Hi! Thanx a LOT!!! /G http://www.varupiraten.se/ Hi Gustav - At 2005-10-13, 23:13:33 you wrote: Hi there! I'd like to get a list of enviromentvariables from the *NIX-system. I'd like it in the format... ENV1=x1 ENv2=x2 ENV3=x3 and so on... I think I have to use ENV-command. (http://perldoc.perl.org/Env.html) Is that right? I don't understand how I get this kind of listing. Please put me in right direction.. I tried to use print ENV% but I get this kind of output: HOSTfriggAUDIODEV/tmp/SUNWut/dev/utaudio/8dtstart_sessionlogfile/dev/nullDTSCREENSAVERLISTStartDtscreenBlankXMBINDDIR/usr/dt/lib/bindingsUTAUDIODEV/tmp/SUNWut/dev/utaudio/8AB_CARDCATALOG/usr/dt/share/answerbooks/C/ab_cardcatalogLC_ALLCDTLOGINDISPLAYCLASSSunRayOSTY I envy you how can solve this... :-) You're almost there. %ENV is a hash, do you can do something like this: print $_=$ENV{$_}\n for sort keys %ENV; Or, with more keystrokes: for my $var( sort keys %ENV ) { print $var=$ENV{$var}\n; } Read up on hashes good luck. /G Aloha = Beau; [EMAIL PROTECTED] 2005-10-13 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Re: ENV(Y)?
Hi gustav - At 2005-10-13, 23:42:22 you wrote: Hi! Just a quick question. Can I set or unset an enviromentvariable through this Hash? I just need a yes ... :-) If No, please give explanation... Not really. If you do something like: $ENV{SOMEVAR} = 'somevalue'; SOMEVAR will be available to you in your program and any programs you spawn ( with 'system' or backtics). But after your perl script ends, SOMEVAR is lost. This is because the system provides you with a new shell - with the envirnoment inherited from the caller - for the duration of the script; the evironment and its modifications are lost when the script ends. On 'nix, you can play with the 'source' operator: '.', which instructs the shell to run the command following the '.' operator in the same shell (I'm talking bash - not sure about other shells). /G http://www.varupiraten.se/ Hi! Thanx a LOT!!! /G http://www.varupiraten.se/ Hi Gustav - At 2005-10-13, 23:13:33 you wrote: Hi there! I'd like to get a list of enviromentvariables from the *NIX-system. I'd like it in the format... ENV1=x1 ENv2=x2 ENV3=x3 and so on... I think I have to use ENV-command. (http://perldoc.perl.org/Env.html) Is that right? I don't understand how I get this kind of listing. Please put me in right direction.. I tried to use print ENV% but I get this kind of output: HOSTfriggAUDIODEV/tmp/SUNWut/dev/utaudio/8dtstart_sessionlogfile/dev/nullDTSCREENSAVERLISTStartDtscreenBlankXMBINDDIR/usr/dt/lib/bindingsUTAUDIODEV/tmp/SUNWut/dev/utaudio/8AB_CARDCATALOG/usr/dt/share/answerbooks/C/ab_cardcatalogLC_ALLCDTLOGINDISPLAYCLASSSunRayOSTY I envy you how can solve this... :-) You're almost there. %ENV is a hash, do you can do something like this: print $_=$ENV{$_}\n for sort keys %ENV; Or, with more keystrokes: for my $var( sort keys %ENV ) { print $var=$ENV{$var}\n; } Read up on hashes good luck. /G Aloha = Beau; [EMAIL PROTECTED] 2005-10-13 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.12.0/132 - Release Date: 10/13/2005 Aloha = Beau; [EMAIL PROTECTED] 2005-10-13 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: using XS for calling exported methods from a DLL
Hi Sam- At 2005-10-14, 00:05:10 you wrote: Hi Is there a way to call exported methods from a DLL without using win32::API. Has anyone tried calling an exported function from C DLL in a Perl Program using XS. [snipped] YES! First, your error is caused because you need an 'export' library from the dll you are trying to access. If you have one. whip in into your module tree's root and change Makefile.PL to use it ( library line ), and your make should work. WARNING: 'make clean' deletes *.lib, so you have to modify the clean routne ( see Make::Maker docs ). But there is s dynamic way to call dll's ( that's why they are called DynamicLinkLibraies :) ). In your XS code, you can use the old 'LoadLibrary' and 'GetProcAddress' Win32 functions. ( be sure your dll is in your current directory or in the PATH for this to work. ) I'm sorry, but the easiest way to show this is to post a working example ( rather long ) - please bare with me! This is the XS file for a Windows Parallel Port driver. The dll it uses is ppdrv.dll which has two functions: void _stdcall pp_out( int port_addr, int data ); int _stdcall pp_in ( int port_addr ); Here is the XS which accesses them: #define PERL_NO_GET_CONTEXT /* we want efficiency */ #include EXTERN.h #include perl.h #include XSUB.h #include ppport.h #define WIN32_LEAN_AND_MEAN #include windows.h static void ppdrv_init_dll( pTHX_ U32* pp_in_addr, U32* pp_out_addr ) { HMODULE h; int ( _stdcall *pp_in )( int ); void ( _stdcall *pp_out )( int, int ); h = LoadLibrary( ppdrv.dll ); if( h == NULL ) Perl_croak(aTHX_ Unable to find 'ppdrv.dll' ); pp_in = ( int ( _stdcall * )( int ) )GetProcAddress( h, pp_in ); if( pp_in == NULL ) Perl_croak(aTHX_ Unable to find 'pp_in' in 'ppdrv.dll' ); pp_out = ( void ( _stdcall * )( int, int ) )GetProcAddress( h, pp_out ); if( pp_out == NULL ) Perl_croak(aTHX_ Unable to find 'pp_out' in 'ppdrv.dll' ); *pp_in_addr = ( U32 ) pp_in; *pp_out_addr = ( U32 ) pp_out; } static int ppdrv_read( pTHX_ U32 func_addr, int base, int offset ) { int ( _stdcall *pp_in )( int ) = ( int ( _stdcall * )( int ) )func_addr; return pp_in( base + offset ); } static void ppdrv_write( pTHX_ U32 func_addr, int base, int offset, int val ) { void ( _stdcall *pp_out )( int, int ) = ( void ( _stdcall * )( int, int ) )func_addr; pp_out( base + offset, val ); } MODULE = Device::ParallelPort::drv::win32_ppdrv PACKAGE = Device::ParallelPort::drv::win32_ppdrv PROTOTYPES: ENABLE void ppdrv_init_dll() PREINIT: U32 pp_in_addr; U32 pp_out_addr; PPCODE: ppdrv_init_dll( aTHX_ pp_in_addr, pp_out_addr ); EXTEND( SP, 2 ); PUSHs( sv_2mortal( newSVuv( pp_in_addr ) ) ); PUSHs( sv_2mortal( newSVuv( pp_out_addr ) ) ); int ppdrv_read( pp_in_addr, base, offset ) INPUT: U32 pp_in_addr int base int offset CODE: RETVAL = ppdrv_read( aTHX_ pp_in_addr, base, offset ); OUTPUT: RETVAL void ppdrv_write( pp_out_addr, base, offset, val ) INPUT: U32 pp_out_addr int base int offset int val CODE: ppdrv_write( aTHX_ pp_out_addr, base, offset, val ); The perl code in the .pm module gets the two functions addresses during initialization as follows: my( $in, $out ) = ppdrv_init_dll(); $this-{FUNCADDR} = { IN = $in, OUT = $out, }; Later the functions be called with: ppdrv_write( $this-{FUNCADDR}{OUT}, $this-{DATA}{BASE}, $byte, $val ); and ppdrv_read( $this-{FUNCADDR}{IN}, $this-{DATA}{BASE}, $byte ); If you want the complete module to copy/study/etc., let me know and I will send it to you off-list. Aloha = Beau; [EMAIL PROTECTED] 2005-10-14 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Space proplem
Hi Martha, Although I do not understand exactly what it is that you want, the following could help ... #1# $msg =~ s/\/'/igx; #2# if (($msg=~ /gu1/i) ($msg !~ /gu1[0123456789]+/i)) First remove line #1#. I guess you did an attempt to remove quotes here, that weren't even there (you can see if you print $msg). Then change line #2# to: if($msg =~ /gu ?1/i) Then a single space is allowed, if you would like to allow more whitespace there (any number of tabs or spaces), you could also do if($msg =~ /gu[ \t]*1/i) Maybe you should also extend your code to check that there are any arguments (you assume $ARGV[1] exists). For obtaining program arguments, I like to use Getopt, see one of these links: http://www.cs.mcgill.ca/~abatko/computers/programming/perl/howto/getopts/ http://aplawrence.com/Unix/perlgetopts.html Hope that helps. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
I need help here
Hi, I am very new to PERL and I need a program to do following task. Can u help me pls. I have a file with following contents. 454 NV_DS_DEFAULT_BAUDRATE_I 455 NV_DIAG_DEFAULT_BAUDRATE_I 516 NV_WCDMA_RX_LIN_VS_TEMP_I I am expecting out put like NV_DS_DEFAULT_BAUDRATE_I 454 NV_DIAG_DEFAULT_BAUDRATE_I 455 NV_WCDMA_RX_LIN_VS_TEMP_I 516 Basically it is interchanging of columns. Looking forward for your help. Sreedhar Reddy T. Sr. Engineer. Business Objects, Ness Technologies India Ltd.
Re: Re: ENV(Y)?
Hi again! I've been looking around... And one thing I don't get. You tell me that SOMEVAR will be available to you in your program and any programs you spawn( with 'system' or backtics). But after your perl script ends, SOMEVAR is lost) and this seems to be correct when I test my program, but I get confused when I read about it on the net... http://www.devdaily.com/perl/edu/articles/pl020002/pl020002.shtml http://www.linux.com/howtos/Path-3.shtml If I like to set an environmentvariable permanently from my program? Isn't that possible in Perl? /G http://www.varupiraten.se/ Hi gustav - At 2005-10-13, 23:42:22 you wrote: Hi! Just a quick question. Can I set or unset an enviromentvariable through this Hash? I just need a yes ... :-) If No, please give explanation... Not really. If you do something like: $ENV{SOMEVAR} = 'somevalue'; SOMEVAR will be available to you in your program and any programs you spawn ( with 'system' or backtics). But after your perl script ends, SOMEVAR is lost. This is because the system provides you with a new shell - with the envirnoment inherited from the caller - for the duration of the script; the evironment and its modifications are lost when the script ends. On 'nix, you can play with the 'source' operator: '.', which instructs the shell to run the command following the '.' operator in the same shell (I'm talking bash - not sure about other shells). /G http://www.varupiraten.se/ Hi! Thanx a LOT!!! /G http://www.varupiraten.se/ Hi Gustav - At 2005-10-13, 23:13:33 you wrote: Hi there! I'd like to get a list of enviromentvariables from the *NIX-system. I'd like it in the format... ENV1=x1 ENv2=x2 ENV3=x3 and so on... I think I have to use ENV-command. (http://perldoc.perl.org/Env.html) Is that right? I don't understand how I get this kind of listing. Please put me in right direction.. I tried to use print ENV% but I get this kind of output: HOSTfriggAUDIODEV/tmp/SUNWut/dev/utaudio/8dtstart_sessionlogfile/dev/nullDTSCREENSAVERLISTStartDtscreenBlankXMBINDDIR/usr/dt/lib/bindingsUTAUDIODEV/tmp/SUNWut/dev/utaudio/8AB_CARDCATALOG/usr/dt/share/answerbooks/C/ab_cardcatalogLC_ALLCDTLOGINDISPLAYCLASSSunRayOSTY I envy you how can solve this... :-) You're almost there. %ENV is a hash, do you can do something like this: print $_=$ENV{$_}\n for sort keys %ENV; Or, with more keystrokes: for my $var( sort keys %ENV ) { print $var=$ENV{$var}\n; } Read up on hashes good luck. /G Aloha = Beau; [EMAIL PROTECTED] 2005-10-13 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.12.0/132 - Release Date: 10/13/2005 Aloha = Beau; [EMAIL PROTECTED] 2005-10-13 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Thank you for your answer. And yesterday i was write from Nahid`s email address
If you want to discuss Beginners Perl, send your messages to the beginners@perl.org list address. I am a subscriber and will see your response there, as will dozens of other helpful people. On Fri, 14 Oct 2005 [EMAIL PROTECTED] wrote: My name is Ulfet. Yesterday i was written from Nahid`s email address. So, i need to write script in PERL languiage on UNIX OS. Exactly Unix AIX (for IBM). So, i found some scripts, and me wrote some scirpt. But there are some problems. Firstly let me tell you that what i found that scripts does not work. And i get it as text and want to send you. But also i want to send you scripts which i have written. If you have samples of code you need help with, send it to the list, not to me directly. And if you want help, it is best to send clear questions with samples of code that you do not understand, or do not work the way you expect them to. Just sending a big set of programs usually doesn't get much help. And just now, i want to explain that i need a script which must be write in PERL for OS Unix AIX. That script have to take XML file and convert it to text. Shortly, that script have to take only without tags words. Example: this is a xml file and its content below nameUlfet/name age24/age I need to take Ulfet and 24. Great. That can be done. Show us what you've tried and we can try to help. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: I need help here
On Fri, 14 Oct 2005, Sreedhar reddy wrote: I am very new to PERL and I need a program to do following task. Can [you] help me [please][question-mark] I have a file with following contents. 454 NV_DS_DEFAULT_BAUDRATE_I 455 NV_DIAG_DEFAULT_BAUDRATE_I 516 NV_WCDMA_RX_LIN_VS_TEMP_I I am expecting out put like NV_DS_DEFAULT_BAUDRATE_I 454 NV_DIAG_DEFAULT_BAUDRATE_I 455 NV_WCDMA_RX_LIN_VS_TEMP_I 516 Basically it is interchanging of columns. Looking forward for your help. Yes, this is possible. Have you tried anything so far? You sent your message to beginners@perl.org and beginners-cgi@perl.org, but not [EMAIL PROTECTED] On the lists you wrote to, you need to take the effort to write at least some code, which we can then help you with. Here's a hint, but it's intentionally incomplete: sub swap_columns { my ( $first, $second ) = @_; return ( $second, $first ); } You should be able to apply that to each line of input to generate each line of output. There's lots of other ways to go about this as well though, and if you provide some code we can help you work through it. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Re: Re: ENV(Y)?
Hi Custav - At 2005-10-14, 02:23:59 you wrote: Hi again! I've been looking around... And one thing I don't get. You tell me that SOMEVAR will be available to you in your program and any programs you spawn( with 'system' or backtics). But after your perl script ends, SOMEVAR is lost) and this seems to be correct when I test my program, but I get confused when I read about it on the net... http://www.devdaily.com/perl/edu/articles/pl020002/pl020002.shtml http://www.linux.com/howtos/Path-3.shtml If I like to set an environmentvariable permanently from my program? Isn't that possible in Perl? As far as I know, No. It's the way shells work...sorry. Someone please correct me if I am wrong. /G http://www.varupiraten.se/ [snipped] Aloha = Beau; [EMAIL PROTECTED] 2005-10-14 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Re: Re: ENV(Y)?
AHA!! Ok, thanx! Now I understand it better... :-) /G http://www.varupiraten.se/ Hi Custav - At 2005-10-14, 02:23:59 you wrote: Hi again! I've been looking around... And one thing I don't get. You tell me that SOMEVAR will be available to you in your program and any programs you spawn( with 'system' or backtics). But after your perl script ends, SOMEVAR is lost) and this seems to be correct when I test my program, but I get confused when I read about it on the net... http://www.devdaily.com/perl/edu/articles/pl020002/pl020002.shtml http://www.linux.com/howtos/Path-3.shtml If I like to set an environmentvariable permanently from my program? Isn't that possible in Perl? As far as I know, No. It's the way shells work...sorry. Someone please correct me if I am wrong. /G http://www.varupiraten.se/ [snipped] Aloha = Beau; [EMAIL PROTECTED] 2005-10-14 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Perl for Windows xp
http://www.activestate.com/store/languages/register.plex?id=ActivePerl Try here friend Armando Gomez Guajardo Process Engineer Work Ph 956 547 6438 Beeper956 768 4070 -Original Message- From: Jenny Chen [mailto:[EMAIL PROTECTED] Sent: Thursday, October 13, 2005 6:11 PM To: beginners@perl.org Subject: Perl for Windows xp Hi All, Can someone tell me where can I download perl for Window XP? Thanks. Jenny -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: I need help here
Hi Chris... I tried like this... INPUT = fopen(filename); OUTPUT -- I opend another file here to write output while(INPUT) { chomp @_; @strings = split(@_, ); print OUTPUT strings[1] + strings[0]; } But I got error msg...Can u modify this program if it is correct??? -Original Message- From: Chris Devers [mailto:[EMAIL PROTECTED] Sent: Friday, October 14, 2005 6:06 PM To: Sreedhar reddy Cc: beginners@perl.org Subject: Re: I need help here On Fri, 14 Oct 2005, Sreedhar reddy wrote: I am very new to PERL and I need a program to do following task. Can [you] help me [please][question-mark] I have a file with following contents. 454 NV_DS_DEFAULT_BAUDRATE_I 455 NV_DIAG_DEFAULT_BAUDRATE_I 516 NV_WCDMA_RX_LIN_VS_TEMP_I I am expecting out put like NV_DS_DEFAULT_BAUDRATE_I 454 NV_DIAG_DEFAULT_BAUDRATE_I 455 NV_WCDMA_RX_LIN_VS_TEMP_I 516 Basically it is interchanging of columns. Looking forward for your help. Yes, this is possible. Have you tried anything so far? You sent your message to beginners@perl.org and beginners-cgi@perl.org, but not [EMAIL PROTECTED] On the lists you wrote to, you need to take the effort to write at least some code, which we can then help you with. Here's a hint, but it's intentionally incomplete: sub swap_columns { my ( $first, $second ) = @_; return ( $second, $first ); } You should be able to apply that to each line of input to generate each line of output. There's lots of other ways to go about this as well though, and if you provide some code we can help you work through it. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: I need help here
Chris- Can u suggest good links to gain good knowledge in PERL... Thanks, Sridhar Reddy -Original Message- From: Chris Devers [mailto:[EMAIL PROTECTED] Sent: Friday, October 14, 2005 6:06 PM To: Sreedhar reddy Cc: beginners@perl.org Subject: Re: I need help here On Fri, 14 Oct 2005, Sreedhar reddy wrote: I am very new to PERL and I need a program to do following task. Can [you] help me [please][question-mark] I have a file with following contents. 454 NV_DS_DEFAULT_BAUDRATE_I 455 NV_DIAG_DEFAULT_BAUDRATE_I 516 NV_WCDMA_RX_LIN_VS_TEMP_I I am expecting out put like NV_DS_DEFAULT_BAUDRATE_I 454 NV_DIAG_DEFAULT_BAUDRATE_I 455 NV_WCDMA_RX_LIN_VS_TEMP_I 516 Basically it is interchanging of columns. Looking forward for your help. Yes, this is possible. Have you tried anything so far? You sent your message to beginners@perl.org and beginners-cgi@perl.org, but not [EMAIL PROTECTED] On the lists you wrote to, you need to take the effort to write at least some code, which we can then help you with. Here's a hint, but it's intentionally incomplete: sub swap_columns { my ( $first, $second ) = @_; return ( $second, $first ); } You should be able to apply that to each line of input to generate each line of output. There's lots of other ways to go about this as well though, and if you provide some code we can help you work through it. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: I need help here
You accidentally replied just to me, not to the list. Please don't do that. Send all messages to the list and I will read them there, along with all the other helpful list subscribers. On Fri, 14 Oct 2005, Sreedhar reddy wrote: I tried like this... INPUT = fopen(filename); OUTPUT -- I opened another file here to write output while(INPUT) { chomp @_; @strings = split(@_, ); print OUTPUT strings[1] + strings[0]; } But I got error [message]...Can [you] modify this program if it is correct??? If it's correct, it doesn't need to be modified, does it? :-) If you want help with your errors, you need to *tell us what the error message was*! Is the text above literally what you wrote? If so, it can't work -- INPUT isn't a valid variable name (it needs to have a 'sigil', like $, @, or %) and the OUTPUT -- I... line just looks like a comment. I assume that isn't really your code, is it? Please show the list exactly what you're doing and what's happening when you try to do it: what the exact statements are to declare your input and output files are, what the while{} loop is (this appears complete, but I want to be sure), and what the error message was. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Space problem
Hi All, I received some response to my problem but unfortunately my problem isn't solved, I'm still struggling.. Thank you all for your contribution Here is a better short code for the program which gives a clear picture of what I'm trying to ask help for. use DBI; $dsn= "dbi:mysql:db_martha:localhost"; my $user= "mysql"; my $password = "mysql123"; $dbh = DBI-connect($dsn,$user,$password); ##GET ARGS # $msg = $ARGV[1]; $source = $ARGV[0]; $msg =~ s/\"/' /igx; $time = localtime(); open (OUTFILE ,"C:\\logs\\martha.txt"); print OUTFILE "$time\t$source\t$msg\n"; close(OUTFILE); $found = 0; ## GU # if (($msg =~ /gu1/i) ($msg !~ /gu1[0123456789]+/i)) { $vote = 'gu1'; $found = 1; } elsif (($msg =~ /gu2/i) ($msg !~ /gu2[0123456789]+/i)) { $vote = 'gu2'; $found = 1; } . .some more elseif statements here . elsif (($msg =~ /gu10/i) ($msg !~ /gu10[0123456789]+/i)) { $vote = 'gu10'; $found = 1; } elsif (($msg =~ /gu11/i) ($msg !~ /gu11[0123456789]+/i)) { $vote = 'gu11'; $found = 1; } if ($found == 1) { $statement = "insert into t_count (time_in, sender, code) values (now(),'$source','$msg')"; #insert into a database $sth= $dbh-prepare("$statement"); $sth-execute; print "You entered $vote .\n"; } else { print "Error message or anythingfor testing"; } $dbh-disconnect; exit; ###EndHere## from the above code, the program acceptsGU1 to GU11but not GU 1(space before no), when i send GU 1, it jumps to the else statement. I want the program to ignorethe space.. I thoughtby putting xon the line ($msg =~ s/\"/' /igx;) will ignore the space but it doesn't Your suggestion/help are highly appreciated... Help me please
Identifying or finding paragraphs
Question: How do you find a paragraph break in perl? Synopsis: In a string I need to find the paragraph breaks and replace it with a ^P. Here is my code. #!/usr/bin/perl -w use strict; use Text::Wrap; $my text = 'This is the FIRST paragraph. This is the SECOND paragraph.'; print wrap(\t,^P,$text); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Identifying or finding paragraphs
On Oct 14, 2005, at 16:13, Dave Adams wrote: Question: How do you find a paragraph break in perl? Synopsis: In a string I need to find the paragraph breaks and replace it with a ^P. Here is my code. How are paragraphs delimited? Can you give an example with a couple of paragraphs and the output you'd like to get? -- fxn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Space problem
Martha kavishe ha scritto: Hi All, I received some response to my problem but unfortunately my problem isn't solved, I'm still struggling.. Thank you all for your contribution Here is a better short code for the program which gives a clear picture of what I'm trying to ask help for. use DBI; $dsn= dbi:mysql:db_martha:localhost; my $user= mysql; my $password = mysql123; $dbh = DBI-connect($dsn,$user,$password); ##GET ARGS # $msg = $ARGV[1]; $source = $ARGV[0]; $msg =~ s/\/' /igx; $time = localtime(); open (OUTFILE ,C:\\logs\\martha.txt); print OUTFILE $time\t$source\t$msg\n; close(OUTFILE); $found = 0; ## GU # if (($msg =~ /gu1/i) ($msg !~ /gu1[0123456789]+/i)) { $vote = 'gu1'; $found = 1; } elsif (($msg =~ /gu2/i) ($msg !~ /gu2[0123456789]+/i)) { $vote = 'gu2'; $found = 1; } . .some more elseif statements here . elsif (($msg =~ /gu10/i) ($msg !~ /gu10[0123456789]+/i)) { $vote = 'gu10'; $found = 1; } elsif (($msg =~ /gu11/i) ($msg !~ /gu11[0123456789]+/i)) { $vote = 'gu11'; $found = 1; } if ($found == 1) { $statement = insert into t_count (time_in, sender, code) values (now(),'$source','$msg'); #insert into a database $sth= $dbh-prepare($statement); $sth-execute; print You entered $vote .\n; } else { print Error message or anythingfor testing; } $dbh-disconnect; exit; ###EndHere## from the above code, the program accepts GU1 to GU11 but not GU 1(space before no), when i send GU 1, it jumps to the else statement. I want the program to ignore the space.. Are you sure you are calling the script using GU 1 ? If you don't use quotes your program will see GU and 1 as separate arguments. This is because the shell treats space as argument separator. I thought by putting x on the line ($msg =~ s/\/' /igx;) will ignore the space but it doesn't Your suggestion/help are highly appreciated... Help me please -- Marcello Romani Developer Spin s.r.l. Reggio Emilia http://www.spinsoft.it -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Identifying or finding paragraphs
How paragraphs are delimited is actually my question. In otherwords, when perl reads in my string, can it identify where the paragraphs breaks are? In my example, $text was created in wordpad where 'This is the FIRST paragraph' and 'This is the SECOND paragraph' are seperated by a paragraph break. My desired output is: This is the FIRST paragraph^PThis is the SECOND paragraph Thank you for your interest and your efforts to help me out. Very much appreciated. DA On 10/14/05, Xavier Noria [EMAIL PROTECTED] wrote: On Oct 14, 2005, at 16:13, Dave Adams wrote: Question: How do you find a paragraph break in perl? Synopsis: In a string I need to find the paragraph breaks and replace it with a ^P. Here is my code. How are paragraphs delimited? Can you give an example with a couple of paragraphs and the output you'd like to get? -- fxn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Identifying or finding paragraphs
On Fri, 14 Oct 2005, Dave Adams wrote: How paragraphs are delimited is actually my question. In otherwords, when perl reads in my string, can it identify where the paragraphs breaks are? In my example, $text was created in wordpad where 'This is the FIRST paragraph' and 'This is the SECOND paragraph' are seperated by a paragraph break. My desired output is: This is the FIRST paragraph^PThis is the SECOND paragraph Thank you for your interest and your efforts to help me out. Very much appreciated. What's a paragraph break? I'm familiar with newlines or line breaks (\n), and I'm familiar with carriage returns (\r), but I'm not aware of an ASCII paragraph break. I *have* seen -- and in fact am using to type this very message -- a convention where two or more newlines delineate paragraph boundaries. If that fits what you're working on, then you could maybe match /\n\s*\n/ or something like that, matching a new line, zero or more spaces (I assume they wouldn't matter), then another newline. If you want to extend that to the case of the two or more newlines, as here, then you need to extend the regex. This might work: /\n\s*\n+/ But that doesn't properly check for spaces after the first newline. If that matters, you'll have to tweak it a bit further. Make sense? -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Identifying or finding paragraphs
Please remove my email address from your list, thanks Tom On 10/14/05, Chris Devers [EMAIL PROTECTED] wrote: On Fri, 14 Oct 2005, Dave Adams wrote: How paragraphs are delimited is actually my question. In otherwords, when perl reads in my string, can it identify where the paragraphs breaks are? In my example, $text was created in wordpad where 'This is the FIRST paragraph' and 'This is the SECOND paragraph' are seperated by a paragraph break. My desired output is: This is the FIRST paragraph^PThis is the SECOND paragraph Thank you for your interest and your efforts to help me out. Very much appreciated. What's a paragraph break? I'm familiar with newlines or line breaks (\n), and I'm familiar with carriage returns (\r), but I'm not aware of an ASCII paragraph break. I *have* seen -- and in fact am using to type this very message -- a convention where two or more newlines delineate paragraph boundaries. If that fits what you're working on, then you could maybe match /\n\s*\n/ or something like that, matching a new line, zero or more spaces (I assume they wouldn't matter), then another newline. If you want to extend that to the case of the two or more newlines, as here, then you need to extend the regex. This might work: /\n\s*\n+/ But that doesn't properly check for spaces after the first newline. If that matters, you'll have to tweak it a bit further. Make sense? -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- Thomas J. Hughes, DoD (CIV) Information Computer Telecommunciations Specialist Level - 6 Naval Surface Warfare Center Joint Interoperability Test Center (JITC) COMM: (301) 274-0160 CELL: (240) 210-0277 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Thank you for your answer. And yesterday i was write from Nahid`s email address
Please remove my email address from your list, thanks Tom On 10/14/05, Chris Devers [EMAIL PROTECTED] wrote: If you want to discuss Beginners Perl, send your messages to the beginners@perl.org list address. I am a subscriber and will see your response there, as will dozens of other helpful people. On Fri, 14 Oct 2005 [EMAIL PROTECTED] wrote: My name is Ulfet. Yesterday i was written from Nahid`s email address. So, i need to write script in PERL languiage on UNIX OS. Exactly Unix AIX (for IBM). So, i found some scripts, and me wrote some scirpt. But there are some problems. Firstly let me tell you that what i found that scripts does not work. And i get it as text and want to send you. But also i want to send you scripts which i have written. If you have samples of code you need help with, send it to the list, not to me directly. And if you want help, it is best to send clear questions with samples of code that you do not understand, or do not work the way you expect them to. Just sending a big set of programs usually doesn't get much help. And just now, i want to explain that i need a script which must be write in PERL for OS Unix AIX. That script have to take XML file and convert it to text. Shortly, that script have to take only without tags words. Example: this is a xml file and its content below nameUlfet/name age24/age I need to take Ulfet and 24. Great. That can be done. Show us what you've tried and we can try to help. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- Thomas J. Hughes, DoD (CIV) Information Computer Telecommunciations Specialist Level - 6 Naval Surface Warfare Center Joint Interoperability Test Center (JITC) COMM: (301) 274-0160 CELL: (240) 210-0277 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Space problem
Martha kavishe am Freitag, 14. Oktober 2005 15.47: Hi All, Hi Martha Marcello already explained that the shell uses spaces to separate arguments, e.g. # my_prog gu 1 passes gu and 1 in @ARGV to the prog, while # my_prog gu 1 will pass only gu 1 (without quotes; these are handled by the shell). Apart from that, your program could be formulated much shorter. When I understand right, you want your program accept arguments of the form string gu, then optionally space(s), then a number between 1 and 11. I received some response to my problem but unfortunately my problem isn't solved, I'm still struggling.. Thank you all for your contribution Here is a better short code for the program which gives a clear picture of what I'm trying to ask help for. # *always* start your code with use strict; use warnings; # this will enforce you declaring your variables below, e.g. $dsn. use DBI; $dsn= dbi:mysql:db_martha:localhost; my $user= mysql; my $password = mysql123; $dbh = DBI-connect($dsn,$user,$password); ##GET ARGS # $msg = $ARGV[1]; $source = $ARGV[0]; In Perl, $ARGV[0] contains the first argument, not the program name. $msg =~ s/\/' /igx; $time = localtime(); open (OUTFILE ,C:\\logs\\martha.txt); # *always* check: open (OUTFILE ,C:\\logs\\martha.txt) or die blabla: $!; print OUTFILE $time\t$source\t$msg\n; close(OUTFILE); # dito $found = 0; ## GU # # The following if-else-forest can be transformed to: my ($number)=$msg=~/^\s*gu\s*(\d{1,2})\s*$/i; # (this allows also spaces before and after) # since 'gu' is the only allowd string, you don't have to catch it # into a variable. if ($number = 11) { my $vote='gu'.$number; # no do the db stuff } # to avoid using a hardcoded constand string, you could also define it at # the begin of the program. if (($msg =~ /gu1/i) ($msg !~ /gu1[0123456789]+/i)) { $vote = 'gu1'; $found = 1; } elsif (($msg =~ /gu2/i) ($msg !~ /gu2[0123456789]+/i)) { $vote = 'gu2'; $found = 1; } . .some more elseif statements here . elsif (($msg =~ /gu10/i) ($msg !~ /gu10[0123456789]+/i)) { $vote = 'gu10'; $found = 1; } elsif (($msg =~ /gu11/i) ($msg !~ /gu11[0123456789]+/i)) { $vote = 'gu11'; $found = 1; } if ($found == 1) { $statement = insert into t_count (time_in, sender, code) values (now(),'$source','$msg'); #insert into a database $sth= $dbh-prepare($statement); $sth-execute; print You entered $vote .\n; } else { print Error message or anythingfor testing; } $dbh-disconnect; # also check result of operation here exit; # exit is not needed ###EndHere## from the above code, the program accepts GU1 to GU11 but not GU 1(space before no), when i send GU 1, it jumps to the else statement. I want the program to ignore the space.. I thought by putting x on the line ($msg =~ s/\/' /igx;) will ignore the space but it doesn't Your suggestion/help are highly appreciated... Help me please hth, joe -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: using XS for calling exported methods from a DLL
- Original Message - Sent: Friday, October 14, 2005 12:24 PM If you want the complete module to copy/study/etc., let me know and I will send it to you off-list. Aloha = Beau; [EMAIL PROTECTED] 2005-10-14 Please send it to me also. I am trying to use a function from a dll. It has a single entry point. the C prototype : char * foo( char * string); I have tried to use Win32::API::Prototype but to no avail. I have googled to find examples on how to use Win32:API with functions that return a pointer to a string. All examples were for functions that return void, int, long etc. but no pointer. Hopefully I might use XS to accomplish what I want..it will be a learning curve since I have yet to use XS. Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Re: ENV(Y)?
Hi! I got your mail from the Perl-malinglist. You have to unscribe from that list manually yourself. Best regards /G http://www.varupiraten.se/ - Original Message - From: Thomas J Hughes [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, October 14, 2005 6:19 PM Subject: Re: Re: ENV(Y)? Please remove my email address from your list, thanks Tom On 10/14/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi again! I've been looking around... And one thing I don't get. You tell me that SOMEVAR will be available to you in your program and any programs you spawn( with 'system' or backtics). But after your perl script ends, SOMEVAR is lost) and this seems to be correct when I test my program, but I get confused when I read about it on the net... http://www.devdaily.com/perl/edu/articles/pl020002/pl020002.shtml http://www.linux.com/howtos/Path-3.shtml If I like to set an environmentvariable permanently from my program? Isn't that possible in Perl? /G http://www.varupiraten.se/ Hi gustav - At 2005-10-13, 23:42:22 you wrote: Hi! Just a quick question. Can I set or unset an enviromentvariable through this Hash? I just need a yes ... :-) If No, please give explanation... Not really. If you do something like: $ENV{SOMEVAR} = 'somevalue'; SOMEVAR will be available to you in your program and any programs you spawn ( with 'system' or backtics). But after your perl script ends, SOMEVAR is lost. This is because the system provides you with a new shell - with the envirnoment inherited from the caller - for the duration of the script; the evironment and its modifications are lost when the script ends. On 'nix, you can play with the 'source' operator: '.', which instructs the shell to run the command following the '.' operator in the same shell (I'm talking bash - not sure about other shells). /G http://www.varupiraten.se/ Hi! Thanx a LOT!!! /G http://www.varupiraten.se/ Hi Gustav - At 2005-10-13, 23:13:33 you wrote: Hi there! I'd like to get a list of enviromentvariables from the *NIX-system. I'd like it in the format... ENV1=x1 ENv2=x2 ENV3=x3 and so on... I think I have to use ENV-command. (http://perldoc.perl.org/Env.html) Is that right? I don't understand how I get this kind of listing. Please put me in right direction.. I tried to use print ENV% but I get this kind of output: HOSTfriggAUDIODEV/tmp/SUNWut/dev/utaudio/8dtstart_sessionlogfile/dev/nullDTSCREENSAVERLISTStartDtscreenBlankXMBINDDIR/usr/dt/lib/bindingsUTAUDIODEV/tmp/SUNWut/dev/utaudio/8AB_CARDCATALOG/usr/dt/share/answerbooks/C/ab_cardcatalogLC_ALLCDTLOGINDISPLAYCLASSSunRayOSTY I envy you how can solve this... :-) You're almost there. %ENV is a hash, do you can do something like this: print $_=$ENV{$_}\n for sort keys %ENV; Or, with more keystrokes: for my $var( sort keys %ENV ) { print $var=$ENV{$var}\n; } Read up on hashes good luck. /G Aloha = Beau; [EMAIL PROTECTED] 2005-10-13 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.12.0/132 - Release Date: 10/13/2005 Aloha = Beau; [EMAIL PROTECTED] 2005-10-13 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- Thomas J. Hughes, DoD (CIV) Information Computer Telecommunciations Specialist Level - 6 Naval Surface Warfare Center Joint Interoperability Test Center (JITC) COMM: (301) 274-0160 CELL: (240) 210-0277 -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.12.0/132 - Release Date: 2005-10-13 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Re: ENV(Y)?
Tom to unsubscribe send a blank email to these address [EMAIL PROTECTED] Cheers Armando Gomez Guajardo Process Engineer Work Ph 956 547 6438 Beeper956 768 4070 -Original Message- From: Gustav Wiberg [mailto:[EMAIL PROTECTED] Sent: Friday, October 14, 2005 12:28 PM To: Thomas J Hughes Cc: beginners@perl.org Subject: Re: Re: ENV(Y)? Hi! I got your mail from the Perl-malinglist. You have to unscribe from that list manually yourself. Best regards /G http://www.varupiraten.se/ - Original Message - From: Thomas J Hughes [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, October 14, 2005 6:19 PM Subject: Re: Re: ENV(Y)? Please remove my email address from your list, thanks Tom On 10/14/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi again! I've been looking around... And one thing I don't get. You tell me that SOMEVAR will be available to you in your program and any programs you spawn( with 'system' or backtics). But after your perl script ends, SOMEVAR is lost) and this seems to be correct when I test my program, but I get confused when I read about it on the net... http://www.devdaily.com/perl/edu/articles/pl020002/pl020002.shtml http://www.linux.com/howtos/Path-3.shtml If I like to set an environmentvariable permanently from my program? Isn't that possible in Perl? /G http://www.varupiraten.se/ Hi gustav - At 2005-10-13, 23:42:22 you wrote: Hi! Just a quick question. Can I set or unset an enviromentvariable through this Hash? I just need a yes ... :-) If No, please give explanation... Not really. If you do something like: $ENV{SOMEVAR} = 'somevalue'; SOMEVAR will be available to you in your program and any programs you spawn ( with 'system' or backtics). But after your perl script ends, SOMEVAR is lost. This is because the system provides you with a new shell - with the envirnoment inherited from the caller - for the duration of the script; the evironment and its modifications are lost when the script ends. On 'nix, you can play with the 'source' operator: '.', which instructs the shell to run the command following the '.' operator in the same shell (I'm talking bash - not sure about other shells). /G http://www.varupiraten.se/ Hi! Thanx a LOT!!! /G http://www.varupiraten.se/ Hi Gustav - At 2005-10-13, 23:13:33 you wrote: Hi there! I'd like to get a list of enviromentvariables from the *NIX-system. I'd like it in the format... ENV1=x1 ENv2=x2 ENV3=x3 and so on... I think I have to use ENV-command. (http://perldoc.perl.org/Env.html) Is that right? I don't understand how I get this kind of listing. Please put me in right direction.. I tried to use print ENV% but I get this kind of output: HOSTfriggAUDIODEV/tmp/SUNWut/dev/utaudio/8dtstart_sessionlogfile/de v/nullDTSCREENSAVERLISTStartDtscreenBlankXMBINDDIR/usr/dt/lib/bindingsUT AUDIODEV/tmp/SUNWut/dev/utaudio/8AB_CARDCATALOG/usr/dt/share/answerbooks /C/ab_cardcatalogLC_ALLCDTLOGINDISPLAYCLASSSunRayOSTY I envy you how can solve this... :-) You're almost there. %ENV is a hash, do you can do something like this: print $_=$ENV{$_}\n for sort keys %ENV; Or, with more keystrokes: for my $var( sort keys %ENV ) { print $var=$ENV{$var}\n; } Read up on hashes good luck. /G Aloha = Beau; [EMAIL PROTECTED] 2005-10-13 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.12.0/132 - Release Date: 10/13/2005 Aloha = Beau; [EMAIL PROTECTED] 2005-10-13 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- Thomas J. Hughes, DoD (CIV) Information Computer Telecommunciations Specialist Level - 6 Naval Surface Warfare Center Joint Interoperability Test Center (JITC) COMM: (301) 274-0160 CELL: (240) 210-0277 -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.12.0/132 - Release Date: 2005-10-13 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Quering Msql database from perl
hello, If i am running perl and i want to qury the Msql Database records how do that from perl. HERE ARE CLUES: DATABASE NAME: DOOM TABLE NAME: T_MAIN RECORDS:VOTE VOTES RECORD TO QUERY:VOTES PROCEDURE: WHERE A VALUE UNDER VOTES IS GREATER THAN THE REST PROCEDURE: ALSO RETURN THE VOTE CODE WHERE THAT VALUE IS +++ | vote | votes | +++ | EE| 0 | | GG| 0 | +++ HERE IS MY TRY. use DBI; $dsn= dbi:mysql:db_doom:localhost; my $user= mysql; my $password = mysql123; $dbh = DBI-connect($dsn,$user,$password); ##GET ARGS ## $msg = $ARGV[1]; $source = $ARGV[0]; $msg =~ s/\/' /ig; $time = localtime(); $msg = $ARGV[1]; $source = $ARGV[0]; $msg =~ s/\/' /ig; $time = localtime(); open (OUTFILE ,C:\\logs\\who.txt); print OUTFILE $time\t$source\t$msg\n; close(OUTFILE); $found = 0; if ($msg =~ /WHO/i) { $found = 1; } if ($found == 1) { $dbh = DBI-connect($dsn,$user,$password); $statement = select msg from t_main where votes = (this is where Iam stuck) greater than others $sth = $dbh-prepare($statement); $sth-execute; $message = $sth-fetchrow_array; $sth-finish; print Thank you, $vote got $vote votes as the highest points.\n; } else { print Sorry. check spelling and send again.\n; } $dbh-disconnect; exit;
Repetead values
Hi. My trouble is with a value duplicated value on a nested foreach, these are my variables: %names=( 1='NA' 2='NCW' 3='NE' 4='S' 5='SE' 6='SP' ); %hash{'2005-09-19'}{'1'}{'56'}=788; %hash{'2005-09-19'}{'1'}{'43'}=540; %hash{'2005-09-19'}{'6'}{'23'}=321; %hash{'2005-09-19'}{'3'}{'10'}=975; And I want an output like this: 2005-09-19 - NA - 56 - 788 2005-09-19 - NA - 43 - 540 2005-09-19 - NCW - 0 - 0 2005-09-19 - NE - 10 - 975 2005-09-19 - S - 0 - 0 2005-09-19 - SE - 0 - 0 2005-09-19 - SP - 23 - 321 I do it by this way: my %final; my $match = 0; foreach my $date(sort keys %hash) { foreach my $num_name(sort {$a = $b}(keys %{$hash{$date}}) ) { foreach my $names(sort {$a = $b}(keys %names) ) { if ($num_name == $names) { $match = 1; foreach my $values(sort {$a = $b}(keys %{$hash{$date}{$num_state}}) ) { $final{$date}{$names{$names}}{$values}=$hash{$date}{$num_state}{$values}; } #end values } #end if else {$match = 0;} }end names if ($match == 0){ $final{$date}{$names{$names}}{0}=0; }#end if }end num_name }end date However this is what I get: 2005-09-19 - NA - 0 - 0 - Repeated value :( 2005-09-19 - NA - 56 - 788 2005-09-19 - NA - 43 - 540 2005-09-19 - NCW - 0 - 0 2005-09-19 - NE - 10 - 975 2005-09-19 - S - 0 - 0 2005-09-19 - SE - 0 - 0 2005-09-19 - SP - 23 - 321 I hope someone help me please. Regards and thanks !!!. -- ___ Get your free email from http://mymail.bsdmail.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Quering Msql database from perl
On Oct 14, K.Moeng said: $dsn= dbi:mysql:db_doom:localhost; So it's a mysql table, not an Msql table. $statement = select msg from t_main where votes = (this is where Iam stuck) greater than others This is an SQL question rather than a Perl question, but I will answer it for you. In the future, please determine the appropriate list for your questions. $statement = q{ SELECT * FROM some_table ORDER BY votes DESC LIMIT 1 }; That will get you one row back, the row with the highest votes. -- Jeff japhy Pinyan% How can we ever be the sold short or RPI Acacia Brother #734% the cheated, we who for every service http://www.perlmonks.org/ % have long ago been overpaid? http://princeton.pm.org/ %-- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
non-ascii characters?
Does anyone know how I can search for non-ascii characters in a text file? --charlie -- Charles Farinella Appropriate Solutions, Inc. (www.AppropriateSolutions.com) [EMAIL PROTECTED] 603.924.6079 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Quering Msql database from perl
Sign up for the dbi-users list. http://dbi.perl.org/support/ -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED] Sent: Friday, October 14, 2005 12:13 PM To: K.Moeng Cc: beginners@perl.org Subject: Re: Quering Msql database from perl snip This is an SQL question rather than a Perl question, but I will answer it for you. In the future, please determine the appropriate list for your questions. snip -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
regd. validation the delimiter(of flat file) is not present in databse..........
Hi Perlers Could you please tell me how to check a particular character is not present in the each element of array in one go ...I mean not going to eamine each and every element of the arraymeans by loop method. I dont want to use the for or while loop methods for validating ... By loop method I think we can simply do by this method my @array = ('word','woad','wobd'); foreach my $i (0 ..$#array){ if ($i !~ /r/ ){ print The test passed entry is $_ \n; } else{ print The failed element is $i \n; } But I am looking for alternative of this method...instead of looking for each and every element...can we do st. away...in one go.. or if we can do my some dbi moduleby writing any sql..(as I don't have much idea for query language so I dont know whether this thing can be done by tht or not) I want this thing in this manner as I have to make sure the particular character (better say the delimiter which I am using in my flat file is not present there,in database, already ). I think I have cleared each n everything if still some confusion just let me know...all the suggestions r most welcome. Mayank Ahuja Team Member Tata Consultancy Services Limited Ph:- 044-5816 Cell:- 9283199460 Mailto: [EMAIL PROTECTED] Website: http://www.tcs.com Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you
XML::XPath query
Hello, Could someone help point out how to use scalar within Xpath query? I need to use $script in the query but it returns nothing. I am somewhat confused about the interpolation in this case. Thanks, Isarin use XML::XPath; my $xp = XML::XPath-new(filename = '/dssweb/prog/navi/links.xml'); my $script = /cgi-bin/rates/showrate; my $nodeset = $xp-findnodes('/navigator/nav_group/[EMAIL PROTECTED] = $script] | /navigator/nav_group/nav/[EMAIL PROTECTED] = $script]');
Re: non-ascii characters?
On Oct 14, Charles Farinella said: Does anyone know how I can search for non-ascii characters in a text file? By non-ASCII, do you mean characters high-bit ASCII or Unicode? -- Jeff japhy Pinyan% How can we ever be the sold short or RPI Acacia Brother #734% the cheated, we who for every service http://www.perlmonks.org/ % have long ago been overpaid? http://princeton.pm.org/ %-- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: XML::XPath query
On Oct 14, H S said: Could someone help point out how to use scalar within Xpath query? I need to use $script in the query but it returns nothing. I am somewhat confused about the interpolation in this case. use XML::XPath; my $xp = XML::XPath-new(filename = '/dssweb/prog/navi/links.xml'); my $script = /cgi-bin/rates/showrate; my $nodeset = $xp-findnodes('/navigator/nav_group/[EMAIL PROTECTED] = $script] | /navigator/nav_group/nav/[EMAIL PROTECTED] = $script]'); Variables won't expand in single quotes, and putting double quotes INSIDE single quotes won't help either. You'll have to use double-quotes around the entire string and escape whatever shouldn't be interpolated: $xp-findnodes(/navigator/nav_group/[EMAIL PROTECTED] = '$script']); Try that. I don't see anything explaining the syntax of an XML path, so I don't really know what *I'm* doing. -- Jeff japhy Pinyan% How can we ever be the sold short or RPI Acacia Brother #734% the cheated, we who for every service http://www.perlmonks.org/ % have long ago been overpaid? http://princeton.pm.org/ %-- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: non-ascii characters?
On Fri, 2005-10-14 at 15:34, Jeff 'japhy' Pinyan wrote: On Oct 14, Charles Farinella said: Does anyone know how I can search for non-ascii characters in a text file? By non-ASCII, do you mean characters high-bit ASCII or Unicode? h, I'm already in over my head. I'm trying to import a bunch of data from a Postgresql dump into a newer version of Postgresql and it's giving me this error: invalid byte sequence for encoding UNICODE: 0xd564 They are characters that look like this: ^0 (at least some of them) My boss says oh just write a Perl script that replaces all the non-ascii characters with spaces! So that's where I'm at. Thanks, --charlie -- Charles Farinella Appropriate Solutions, Inc. (www.AppropriateSolutions.com) [EMAIL PROTECTED] 603.924.6079 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Re: using XS for calling exported methods from a DLL
- Original Message - From: Beau E. Cox [EMAIL PROTECTED] To: Bernard Kenik [EMAIL PROTECTED] Cc: Beginners Perl beginners@perl.org Sent: Friday, October 14, 2005 1:29 PM Subject: Re: Re: using XS for calling exported methods from a DLL Hi Bernard et. al. - At 2005-10-14, 07:01:39 you wrote: Attached. WARNING: no documentation (that's why it's not on CPAN). For your use, look at the XS file to see how the dll is accessed with LoadLibrary and the functions are located with GetProcAddress. This _should_ work for functions with any return type. Then see the .pm file for using the XS. will do as you suggested. You may want to look at Device::ParallelPort's documentation also if you get lost in the .pm code - this is a driver for that module. The actual dll ( w/source ) is in subdir ppdrv. do you mean that I need the source to the dll that I want to use? Thank you for your prompt reply. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
How do I create async child process?
Is there a vendor neutral way to create an asynchronous child process in perl? I know the back quotes create a synchronous one but I want multiple asynch child processes. Thanks, Siegfried -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Repetead values
Rafael Morales wrote: Hi. Hello, My trouble is with a value duplicated value on a nested foreach, these are my variables: %names=( 1='NA' 2='NCW' 3='NE' 4='S' 5='SE' 6='SP' ); %hash{'2005-09-19'}{'1'}{'56'}=788; %hash{'2005-09-19'}{'1'}{'43'}=540; %hash{'2005-09-19'}{'6'}{'23'}=321; %hash{'2005-09-19'}{'3'}{'10'}=975; And I want an output like this: 2005-09-19 - NA - 56 - 788 2005-09-19 - NA - 43 - 540 2005-09-19 - NCW - 0 - 0 2005-09-19 - NE - 10 - 975 2005-09-19 - S - 0 - 0 2005-09-19 - SE - 0 - 0 2005-09-19 - SP - 23 - 321 I do it by this way: my %final; my $match = 0; foreach my $date(sort keys %hash) { foreach my $num_name(sort {$a = $b}(keys %{$hash{$date}}) ) { foreach my $names(sort {$a = $b}(keys %names) ) { if ($num_name == $names) { $match = 1; foreach my $values(sort {$a = $b}(keys %{$hash{$date}{$num_state}}) ) { $final{$date}{$names{$names}}{$values}=$hash{$date}{$num_state}{$values}; } #end values } #end if else {$match = 0;} }end names if ($match == 0){ $final{$date}{$names{$names}}{0}=0; }#end if }end num_name }end date However this is what I get: 2005-09-19 - NA - 0 - 0 - Repeated value :( 2005-09-19 - NA - 56 - 788 2005-09-19 - NA - 43 - 540 2005-09-19 - NCW - 0 - 0 2005-09-19 - NE - 10 - 975 2005-09-19 - S - 0 - 0 2005-09-19 - SE - 0 - 0 2005-09-19 - SP - 23 - 321 It looks like you want something like: for my $date ( keys %hash ) { for my $num_name ( keys %{ $hash{ $date } } ) { if ( exists $names{ $num_name } ) { $hash{ $date }{ $names{ $num_name } } = delete $hash{ $date }{ $num_name }; } } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
remainder function
Hi, Is there a remainder function, since I need to check if a number is divisible by another? Thank you all. best, -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: remainder function
On Oct 15, 2005, at 0:02, ZHAO, BING wrote: Hi, Is there a remainder function, since I need to check if a number is divisible by another? Yes, the modulus operator: print $n is divisible by $m if $n % $m == 0; -- fxn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: I need help here
Sreedhar reddy wrote: Hi, Hello, I am very new to PERL and I need a program to do following task. Can u help me pls. I have a file with following contents. 454 NV_DS_DEFAULT_BAUDRATE_I 455 NV_DIAG_DEFAULT_BAUDRATE_I 516 NV_WCDMA_RX_LIN_VS_TEMP_I I am expecting out put like NV_DS_DEFAULT_BAUDRATE_I 454 NV_DIAG_DEFAULT_BAUDRATE_I 455 NV_WCDMA_RX_LIN_VS_TEMP_I 516 Basically it is interchanging of columns. Looking forward for your help. perl -i.bak -lane'print join , reverse @F' yourfile John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Thank you for your answer. And yesterday i was write from Nahid`s email address
Thankuyu very mush for your asnwer. So i will on monday write the question and will try what i want and what i need.
Re: Repetead values
Yes it works but I also need to print the files with values with '0', and your code just prints the files that have values different of '0', for example when I use your code I got this: 2005-09-19 - NA - 56 - 788 2005-09-19 - NA - 43 - 540 2005-09-19 - NE - 10 - 975 2005-09-19 - SP - 23 - 321 But I need these too: 2005-09-19 - NCW - 0 - 0 2005-09-19 - S - 0 - 0 2005-09-19 - SE - 0 - 0 How can I get them all ??? Thanks for your help John :). - Original Message - From: John W. Krahn [EMAIL PROTECTED] To: Perl Beginners beginners@perl.org Subject: Re: Repetead values Date: Fri, 14 Oct 2005 14:39:16 -0700 Rafael Morales wrote: Hi. Hello, My trouble is with a value duplicated value on a nested foreach, these are my variables: %names=( 1='NA' 2='NCW' 3='NE' 4='S' 5='SE' 6='SP' ); %hash{'2005-09-19'}{'1'}{'56'}=788; %hash{'2005-09-19'}{'1'}{'43'}=540; %hash{'2005-09-19'}{'6'}{'23'}=321; %hash{'2005-09-19'}{'3'}{'10'}=975; And I want an output like this: 2005-09-19 - NA - 56 - 788 2005-09-19 - NA - 43 - 540 2005-09-19 - NCW - 0 - 0 2005-09-19 - NE - 10 - 975 2005-09-19 - S - 0 - 0 2005-09-19 - SE - 0 - 0 2005-09-19 - SP - 23 - 321 I do it by this way: my %final; my $match = 0; foreach my $date(sort keys %hash) { foreach my $num_name(sort {$a = $b}(keys %{$hash{$date}}) ) { foreach my $names(sort {$a = $b}(keys %names) ) { if ($num_name == $names) { $match = 1; foreach my $values(sort {$a = $b}(keys %{$hash{$date}{$num_state}}) ) { $final{$date}{$names{$names}}{$values}=$hash{$date}{$num_state}{$values}; } #end values } #end if else {$match = 0;} }end names if ($match == 0){ $final{$date}{$names{$names}}{0}=0; }#end if }end num_name }end date However this is what I get: 2005-09-19 - NA - 0 - 0 - Repeated value :( 2005-09-19 - NA - 56 - 788 2005-09-19 - NA - 43 - 540 2005-09-19 - NCW - 0 - 0 2005-09-19 - NE - 10 - 975 2005-09-19 - S - 0 - 0 2005-09-19 - SE - 0 - 0 2005-09-19 - SP - 23 - 321 It looks like you want something like: for my $date ( keys %hash ) { for my $num_name ( keys %{ $hash{ $date } } ) { if ( exists $names{ $num_name } ) { $hash{ $date }{ $names{ $num_name } } = delete $hash{ $date }{ $num_name }; } } } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- ___ Get your free email from http://mymail.bsdmail.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Writing a mail filter...
I am wanting to write a mail filter which will allow me to use a score sheet and a configuration file to filter mail into specific folders. This would be accomplished in conjunction with procmail, and possibly formail. The program would have to take the message and scan it for certain paterns, and then output a slightly modified message (the addition of a header, possibly the editing of the subject line and/or the body). The changing of the message can be done externally using I believe formail. This program would accept the incoming message from stdin and send out through stdout. There would be at least one related program which would also scan a message coming from stdin, but instead be used to update the database for the handling of incoming messages. The database would likely be 1 line per reccord with a colon seperating fields (I see a problem with this, there is a potential for breaking the databse, will resolve that in the debuging/development phase, TSV would I believe work, though I've not used TSVs before). Any input would be apreciated. I currently have Perl 5.8.7 installed on the machine this is intended to run on. I know that a lot of the components, and maybe even a program doing exactly what I want are/is available. I will use apropriate modules to accomplish what I need, but I want a certain part of it to be my code. I have written similar programs in the past, but it has been a while. The training of the database could take a while, but I doubt it will take all that long. This program is more advanced than any that I've done in the past, and will probably require the use of a number of different tools to accomplish it. Jessica -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
add timer to program
Hello, My perl script requires to invoke external program, however this external program sometimes take forever to complete. The external program accessing /dev/ircomm0 and whenever the IR client was hang or out of range, this program try to search forever making the calling program seems to hang. Unfortunately, perl needs to be run unatended, scheduled using cron. My question is, how do I add a timer, so whenever external script did not return results after x seconds just abort the program. snippet: my @results = `$sms_bin $options --msg=@sms_msg --number=$rcpt_number 21`; --- -- --beast -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: I need help here
INPUT = fopen(filename); OUTPUT -- I opened another file here to write output These two lines r just to say how I'm proceeding... The err msg which I got is... Can't modify constant item in scalar assignment at test_script.pl line 1, near ); syntax error at test_script.pl line 13, near strings[ Execution of test_script.pl aborted due to compilation errors. Can u tell me wht is meant by this ? Thanks, Sridhar -Original Message- From: Chris Devers [mailto:[EMAIL PROTECTED] Sent: Friday, October 14, 2005 6:59 PM To: Sreedhar reddy Cc: beginners@perl.org Subject: RE: I need help here You accidentally replied just to me, not to the list. Please don't do that. Send all messages to the list and I will read them there, along with all the other helpful list subscribers. On Fri, 14 Oct 2005, Sreedhar reddy wrote: I tried like this... INPUT = fopen(filename); OUTPUT -- I opened another file here to write output while(INPUT) { chomp @_; @strings = split(@_, ); print OUTPUT strings[1] + strings[0]; } But I got error [message]...Can [you] modify this program if it is correct??? If it's correct, it doesn't need to be modified, does it? :-) If you want help with your errors, you need to *tell us what the error message was*! Is the text above literally what you wrote? If so, it can't work -- INPUT isn't a valid variable name (it needs to have a 'sigil', like $, @, or %) and the OUTPUT -- I... line just looks like a comment. I assume that isn't really your code, is it? Please show the list exactly what you're doing and what's happening when you try to do it: what the exact statements are to declare your input and output files are, what the while{} loop is (this appears complete, but I want to be sure), and what the error message was. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: I need help here
Finally I finished this program like this... $inputfile= shift; $outputfile = shift; open(FILE1,$inputfile); @lines=FILE1; close(FILE1); open(FILE2,$outputfile); foreach $line (@lines) { if($line =~ m/(\d+) ([a-z,A-Z,_,0-9]+)/) /* to write this line I have taken lot of time as I know basics in Regular Expressions */ { print FILE2 $2 $1\n; } } close(FILE2); print \n Thanks to all who helped me to solve this problem... -Original Message- From: Chris Devers [mailto:[EMAIL PROTECTED] Sent: Friday, October 14, 2005 6:59 PM To: Sreedhar reddy Cc: beginners@perl.org Subject: RE: I need help here You accidentally replied just to me, not to the list. Please don't do that. Send all messages to the list and I will read them there, along with all the other helpful list subscribers. On Fri, 14 Oct 2005, Sreedhar reddy wrote: I tried like this... INPUT = fopen(filename); OUTPUT -- I opened another file here to write output while(INPUT) { chomp @_; @strings = split(@_, ); print OUTPUT strings[1] + strings[0]; } But I got error [message]...Can [you] modify this program if it is correct??? If it's correct, it doesn't need to be modified, does it? :-) If you want help with your errors, you need to *tell us what the error message was*! Is the text above literally what you wrote? If so, it can't work -- INPUT isn't a valid variable name (it needs to have a 'sigil', like $, @, or %) and the OUTPUT -- I... line just looks like a comment. I assume that isn't really your code, is it? Please show the list exactly what you're doing and what's happening when you try to do it: what the exact statements are to declare your input and output files are, what the while{} loop is (this appears complete, but I want to be sure), and what the error message was. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: I need help here
Sreedhar reddy mailto:[EMAIL PROTECTED] wrote: : Finally I finished this program like this... [snip] A working perl script should not be your only concern when just learning the language. It is equally, no, more important that you learn how to write your code well. Show us your entire working script. I think you are using some very poor techniques, but we need to see everything to see just what help you need. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Repetead values
Rafael Morales wrote: Yes it works but I also need to print the files with values with '0', and your code just prints the files that have values different of '0', for example when I use your code I got this: 2005-09-19 - NA - 56 - 788 2005-09-19 - NA - 43 - 540 2005-09-19 - NE - 10 - 975 2005-09-19 - SP - 23 - 321 But I need these too: 2005-09-19 - NCW - 0 - 0 2005-09-19 - S - 0 - 0 2005-09-19 - SE - 0 - 0 How can I get them all ??? I don't know. I don't know what your data looks like or how you are parsing it or what the contents of %hash really are. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: I need help here
Sreedhar reddy wrote: Finally I finished this program like this... You should have these two lines at the beginning of your program: use warnings; use strict; as they will help you find some mistakes and enforce better coding practices. $inputfile= shift; $outputfile = shift; open(FILE1,$inputfile); You should *ALWAYS* verify that the file was opened coreectly. open FILE1, '', $inputfile or die Cannot open $inputfile: $!; @lines=FILE1; There is no good reason to read all the lines into memory as you only need to process one line at a time. close(FILE1); open(FILE2,$outputfile); You should *ALWAYS* verify that the file was opened coreectly. open FILE2, '', $outputfile or die Cannot open $outputfile: $!; foreach $line (@lines) { if($line =~ m/(\d+) ([a-z,A-Z,_,0-9]+)/) /* to write Perl provides the escape sequence \w that represents the character class [a-zA-Z0-9_] so your regular expression could be written /(\d+) ([\w,]+)/ although I didn't see any commas in your data so you probably really want /(\d+) (\w+)/. Also perl doesn't understand /* C style comments */. this line I have taken lot of time as I know basics in Regular Expressions */ { print FILE2 $2 $1\n; } } close(FILE2); print \n John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response