RE: configure a switch via ssh with a perl program
Hi Lee You can use Net::SSH2 or Net::SSH::Perl to log into your switches and run any commands you need to. I actually use Net::SSH2 for this...There are a lot of examples around. You just need to do something like this... This code is only an example. my $ssh2 = Net::SSH2->new(); $ssh2->connect( $YOURSERVERHERE); # can be ip or fqdn or just the device name is if it has an entry in dns $ssh2->auth_password($USERNAME_TO_SWITCH, $PASSWORD); $channel = $ssh2->channel(); $channel->exec($YOUR_CMD_HERE); while ($channel->read($buf, $buflen)) { $result .=$buf; } Then you have to parse what you get back. Here is a link to stack overflow with an example to using Net::SSH::Perl which looks a bit easier. http://stackoverflow.com/questions/16594963/perl-ssh-into-device Trac -Original Message- From: lee [mailto:l...@yagibdah.de] Sent: Tuesday, July 12, 2016 7:33 PM To: beginners@perl.org Subject: Re: configure a switch via ssh with a perl program Shekarwrites: > Hi Lee, > > If you can login to your switch via ssh, run required commands on the > switch and exit out, you should be able to simulate the same via > Net::OpenSSH or Net::SSH::Perl Yes, that's what I was thinking. Only it takes time to program, that's a problem. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Rsync options not recognized by system function
Hello All: My rsync options are not being recognized in the system function. I tried escaping the asterisks and single quotes to no avail. Also, I do not want to install any rsync modules. Your help will be much appreciated. Thanks. my $RSYNC_OPTS=' -auvr --include='*/' --exclude='*' '; my $RSYNC=/usr/bin/rsync; system($RSYNC, $RSYNC_OPTS, $host:/Blah/blah/Blue/$host_env/$cluster, /tmp/$host); -- Ezra Taylor
RE: Find duplicates in an array
I needed to find all the duplicate values in an array and their count of occurences. Any help would be appreciated . You could use a hash: use strict; use warnings; my @animals = (cat,dog,wombat,cat,monkey,cat,monkey); my %howmany; foreach my $critter (@animals) { $howmany{$critter}++; } foreach my $key (keys %howmany) { print $key $howmany{$key}\n; } If you only want cases with count 1 then put an if around the print. Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Please remove all references in mail archive
Hello, I am reggie kogulan. Please remove all references in beginners.perl.org. Back in 2003, I was subscribing to this list and I stopped it. I did post many messages. I want them to be removed. Because, I did not have idea, you will be posting everything on the internet. Google is able to find me. Please remove every link to my name in the mail-archive.com as soon as possible otherwise, I would have to take legal actions. www.mail-archive.com/beginners@perl.org/msg44490.html
RE: Monitoring multiple child processes
On some systems, waitpid may return something rather than a child pid or -1. This would happen when the wait was interrupted by something other than a child death. Most likely, it would be zero. The return status, $?, is a 16-bit word of three packed values. See `perldoc perlvar` and search for /\$\?/. It should be set to a non-zero value by the child if the child does not terminate successfully. Most UNIX commands do this; most user-written scripts do not. Also, Windows ignores the return value and always returns zero. $? should not change unless a child process died. Ahhh, I see. I think I understand now. Thankyou for your help and explanations. Andy Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Monitoring multiple child processes
Hello I have a script that, much like the Little Old Lady who lived in a shoe, has so many children it's not sure what to do. Basically, the script does some stuff, then kicks off multiple copies of an external process that all run in parallel. It then has to wait until all of them have completed (successfully) then carry on with the next bit. What I've cobbled together so far (i.e. swiped of the web then modified...) use strict; use warnings; # Do some stuff here for (my $i=1; $i =$num_processes; $i++) { defined(my $pid = fork) or die( Cannot fork : $!\n); # Put all the pids into an aray if ($pid) { push @pids, $pid; } else { exec external giggery pokery } } foreach my $child_pid (@pids) { waitpid($child_pid, 0); unless( 0==$? ) { die (Oh No! An external process has failed!!\n); } } # Do the next bit here It seems to work with a simplified test script, but I', worried I've done something stupid in there and the whole thing will explode when exposed to the live environment. Does this look sensible and/or is there a better way of doing this? And help/suggestions/criticisms gratefully received. Cheers Andy Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: Monitoring multiple child processes
my $kid = waitpid($child_pid, 0); redo if $kid != $child_pid; # So goes back to start of loop from here unless( 0==$? ) # And never performs this test { die (Oh No! An external process has failed!!\n); } } That makes most sense to me but I'm not sure how to test if my assumption is correct. (I'd have to somehow get the system to return a pid/status for a different process) In general, you will want to test for errors as soon as possible. If you get an error, how do you know waitpid will ever work correctly again? OK, I'm clearly being dense here then. My understanding was that the $? contained the status of the pid returned by waidpid. If waitpid returned a pid from some other process (i.e. not one of my children) that had failed (i.e return status other than 0) then wouldn't my test abort the script when it wouldn't need to (as the process that failed wasn't one of my children) before it got to the redo? Or have I firmly grasped the wrong end of the stick? Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Filesize limit for Perl on UNIX
Hello We have a perl script that (essentially) concatenates a number of files into one. The process is more or less the following Open output file Foreach input file Open each input file write to output file close input file Close output file. The output file has cut off after hitting 2Gb. The most likely candidate for this is the filesystem (we're investigating this as I type this), but it occurred to us it might also be a perl thing. Is there a 2GB filesize limit for perl? - we're running on verion 5.6. Cheers Andy Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: Write Excel and Open file from CGI
--Hello List, -- --I have a DOS batch file which has perl script that runs at the end. The --perl --script fetches information from different files and database and generates --an excel file. Is there a way I can open the excel from CGI and display on --screen? -- -- --Thanks -- --Vau # Print HTTP header information at top of page print 'Content-type: application/vnd.ms-excel; name='.$filename.''.\n; print Content-Transfer-Encoding: text; \n; print 'Content-Disposition: inline; filename='.$filename.''.\n; print 'Content-Description: msexcel;' . \n\n; # Print file content print $file_contents\n; Output that via CGI and the browser should open an inline excel spreadsheet. Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: Sleep
Hi, How could I introduce a Sleep in Perl? Is there any specific function for that? regards, -ramesh Yes. It's called sleep sleep n - will sleep for n seconds (miss off the number and it'll sleep until interrupted) Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: How hard is it to learn this langauge?
I came to Perl with no real programming experience (I'd looked at C and Java a bit, but never used them and messed around with simple BASIC at school). I was given the task of modifying a load of Perl code, so I went out and bought the Learning Perl book (By Randal L. Schwartz Tom Christiansen) and took it from there. Taught me everything I needed to know (for the work I was doing) and I was able to start changing code within days. It wasn't much longer before I was creating new code of my own either. So, if a dullard like me with no previous experience can pick it up quickly, anyone who's done programming before should have no problems. -Original Message- From: Blazer [mailto:evanstroh...@yahoo.co.uk] Sent: 07 February 2009 23:05 To: beginners@perl.org Subject: How hard is it to learn this langauge? I have limited experience of programming in C C++ - I cant claim to know either of these well, but i do try to keep building on what i know, when i can. I just kept reading that Perl was a very easy language to learn. Is this true or is it propaganda??? All I know is Larry Wall created it! Is it possible to get to grips with this language fast - like in two or three months? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Converting a string to a filehandle
Hello I'm processing a file of test data that looks something like: FH1,data1,data2,data3,...etc FH2,data1,data2,data3,...etc FH1,data1,data2,data3,...etc Each line split into an array and processed. The first element (FH1, FH2, etc) is the name of the filehandle the output should be printed to. I'm trying to do something like: use strict; use warnings; open (FH1, file1); open (FH2, file2); open (INPUT, inputfile); while (INPUT) { ...split line ...process data ...create output my $FH = $split_line[0] print $FH $output\n; } But I get the error: Can't use string (FH1) as a symbol ref while strict refs in use at my_script.pl line 387, INPUT line 1. I can get round it without too much difficulty with an if statement, but I was wondering if there was a simple way to turn a string into a filehandle. I've tried various things like: my $FH = \*$split_line[0]; or print \*$FH $output\n; or changing the data to hold \*FH1 in the first field. All to no avail. The closest thing I've found is the following from the perldocs website: $fh = SOME_FH; # bareword is strict-subs hostile $fh = SOME_FH; # strict-refs hostile; same package only $fh = *SOME_FH; # typeglob $fh = \*SOME_FH; # ref to typeglob (bless-able) $fh = *SOME_FH{IO}; # blessed IO::Handle from *SOME_FH typeglob But I don't think that answers my question (or if it does, I'm too dumb to see that answer...) Can anyone point me in the right direction? Cheers Andy Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Neater way to declare variables
Hello I have a script that is (at one point) reading through a file. The file is processed line by line and each line split into an array like so: while ($TESTFILE) { my $cur_line=$_; chomp ($cur_line); my @split_line = split( /$t_delim/, $cur_line ); # In a number of places, I have code that looks like the following. my $default_type; if( $split_line[0] eq DEFAULT_INPUT ) { $default_type = INPUT; } if ( $split_line[0] eq DEFAULT_OUTPUT ) { $default_type = OUTPUT; } # processing continues... # more stuff here # blah blah blah # etc. etc. } This works OK, but I'm trying to avoid declaring variables seperately from assigning them (wherever possible), and trying to keep the size of the script down without losing human legibility. Is there a neater/cleverer way of doing this? Cheers Andy Taylor Andrew Taylor | Capgemini | Telford ASPIRE Data Warehouse Support T : +44 (0)1952 430684 | www.capgemini.com http://www.capgemini.com/ Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
RE: String concatination.
Try: print abc${string}zyx\n; or print abc.$string.zyx\n; Cheers Andy -Original Message- From: Sureshkumar M (HCL Financial Services) [mailto:[EMAIL PROTECTED] Sent: 10 November 2008 15:34 To: beginners@perl.org Subject: String concatination. Hi all, I have a string like below. $string=ABCD; While printing , I have to include some extra strings in prefix and suffix of the stringlike below... abcABCDxyz how do I do this.? actually I tried like below.. print abc$sting\xyz; But It's not coming as like I expected(abcABCDxyz) Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Tracking which elements from an array have been matched.
Hello I have an array of records. I need to search this array for a particular record (or records) based on a record id. This is simple enough (e.g. using the grep function) @found = grep {/$rec_id/} @array; However, I also need to keep a track of which records in the array have been 'found' (so I can later identify any records that haven't). This would be pretty simple with a loop, something like: for ($i=0; $i @data; $i++) { if ($array[$i] =~ /$rec_id/) { push (@found, $array[$i]) ; $found_recs{$i} = TRUE; } } But this seems quite inefficient, and I'm sure there must be a better way of doing this. This is part of a larger script that is becoming quite large so I'm trying to be more efficient (and to improve my coding). Can anyone offer any suggestions. Cheers Andy Taylor Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.
RE: Tracking which elements from an array have been matched.
On Wed, 2008-10-29 at 16:29 +, Taylor, Andrew (ASPIRE) wrote: I have an array of records. I need to search this array for a particular record (or records) based on a record id. This is simple enough (e.g. using the grep function) @found = grep {/$rec_id/} @array; However, I also need to keep a track of which records in the array have been 'found' (so I can later identify any records that haven't). @contains_id = grep {/$rec_id/} @array; @not_contains_id = grep { $_ !~ /$rec_id/ } @array; Thanks, This would work for a single iteration, but this search would need to be performed multiple times (with different record IDs). An id is fed in, the relevant records retrieved and processed, then the next id is fed in, and so on. It's after the loop has finished (i.e. all the expected record IDs have been checked) that I need to be able to determine which records weren't matched by any of the supplied record IDs. Cheers Andy Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Serial Ports
Hello all, I have a robot that sends data over a serial connection and I'd like to use Perl/Linux to listen to the Serial Port and record the data. Can anyone suggest the best package to do this? I need to be able to set Baud rates and such too. I'm looking at Device::SerialPort, but is that the best way to go about this? Thanks. -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Trying to add hyperlink
On Thu, June 22, 2006 09:25, chen li wrote: --- Prabu [EMAIL PROTECTED] wrote: Hello, Hope this is your need... #!/usr/bin/perl -w use warnings ; use CGI qw/:standard/; print header, start_html(Stsd ILO Links), h1(Stsd ILO Links) ; print table({-border=undef,,-width='75%', -height='70%'}, caption(strong('Web Page Under construction?')), Tr({-align=CENTER,-valign=TOP}, [ th(['','A HREF=#Network Switch/A','A HREF=#Bay 1/A','A HREF=#Bay 2/A','A HREF=#Bay 3/A' ,'A HREF=#Network Switch/A' ]), th('A HREF=#Enclosure 1/A').td(['A HREF=#Bl20p G2/A','A HREF=#yes/A','A HREF=#yes/A']), th('A HREF=#Enclosure 2/A').td(['A HREF=#no/A','A HREF=#no/A','A HREF=#yes/A']) ] ) ); end_html(); Hi all, How to convert the format above into an OOP style when adding a hyperlink? I am afraid many people might have typo if they follow the format above. THis might help: http://search.cpan.org/src/LDS/CGI.pm-3.08/cgi_docs.html -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
HTML to Text
Hello all, I have an HTML file that I need to extract the text data from. What modules do I need to be able to do this? I was looking at HTML::Parser but it doesn't make any sense and probably not what I'm looking for. my simple input file will look like this: HTML HEAD TITLEBin Server/TITLE /HEAD BODY pData that I need/p pData that I need/p /BODY /HTML I want the output to just be lines of Data that I need stored in a string, that I can work on each line one at a time, or in an array or something like that would be great. Any suggestions? Thanks. -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: HTML to Text
On Tue, May 2, 2006 13:45, Russ Foster wrote: -Original Message- HTML HEAD TITLEBin Server/TITLE /HEAD BODY pData that I need/p pData that I need/p /BODY /HTML I want the output to just be lines of Data that I need stored in a string, that I can work on each line one at a time, or in an array or something like that would be great. I would first strip out everything from the start to BODY, then everything from /BODY to the end... $test2convert =~ s/^.*\BODY\// ; $test2convert =~ s/\\/BODY\.*$// ; Remove any existing newlines... $test2convert =~ s/\n// ; Are you sure that the paragraph tags are always paired up? If so, you could always strip out the ps and substitute the /p with \n . If you don't have control over the input, then this would be a big assumption to make. But it might give you ideas to start with based on how complex the data is... Very useful. Thanks. -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: HTML to Text
On Tue, May 2, 2006 12:55, Randal L. Schwartz wrote: Scott == Scott Taylor [EMAIL PROTECTED] writes: Scott my simple input file will look like this: Scott HTML Scott HEAD Scott TITLEBin Server/TITLE Scott /HEAD Scott BODY Scott pData that I need/p Scott pData that I need/p Scott /BODY Scott /HTML Scott I want the output to just be lines of Data that I need stored in a Scott string, that I can work on each line one at a time, or in an array or Scott something like that would be great. Your specification is incomplete. It is simple, not incomplete. What if it says: pData that I bneed/b/p Do you want b in your response? Or stripped? Or that part of it not included? I don't care. And why is p interesting to you, but not title? those are both text. You'll need to explain it by more than just one example. What if it's in a table? What if it's the caption for an image? Like I said, it's a simple input file. The file comes from a robot, it will always look like that, and at this time, I am only interested in the lines between the p not saying I might not be interested in other stuff later on, or doing the same thing with another HTML some day down the road. Either way, an answer to the current question will most likely give me what I may need in the future. Basically, right now I just need the HTML to Text output, like I explained. Thanks for your help. -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
SCO OSR5 and DBI
Hello, I'm trying to install DBI modules and I'm getting the following message from 'make': gcc -c-DPERL_SCO -DPERL_SCO507 -DHAS_FPSETMASK -D_REENTRANT -march=i 586 -mcpu=i586 -O6 -fomit-frame-pointer-DVERSION=\1.50\ -DXS_VERSION=\1. 50\ -fPIC -I/usr/lib/perl5/5.8/i586-pc-sco3.2v5.0/CORE -W -Wall -Wpointer-ar ith -Wbad-function-cast -Wno-comment -Wno-sign-compare -Wno-cast-qual -DDBI_NO_T HREADS Perl.c In file included from /usr/include/netinet/in.h:93, from /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0/CORE/perl.h:880, from DBIXS.h:19, from Perl.xs:5: /usr/include/netinet/in6.h:25: sys/convsa.h: No such file or directory In file included from /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0/CORE/perl.h:880, from DBIXS.h:19, from Perl.xs:5: /usr/include/netinet/in.h:100: sys/convsa.h: No such file or directory In file included from /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0/CORE/perl.h:979, from DBIXS.h:19, from Perl.xs:5: /usr/include/netdb.h:60: sys/convsa.h: No such file or directory In file included from /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0/CORE/perl.h:1528, from DBIXS.h:19, from Perl.xs:5: /usr/include/ieeefp.h:34: warning: `__i386' redefined *Initialization*:1: warning: this is the location of the previous definition *** Error code 1 (bu21) Can anyone tell me what it means? Can I install DBI on OSR5.07? I seem to get a lot of errors when trying to compile anything on this machine. Cheers in adv. -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
compiling DateTime module on SCO OSR5
Hello all, I'm trying to compile DateTime module for Perl in SCO OSR5.07 and failing miserably. I have no idea what these errors mean. Can anyone tell me what I need, or what I'm doing wrong? All tests in the make test are failing with messages like this one: PERL_DL_NONLAZY=1 /usr/bin/perl -MExtUtils::Command::MM -e test_har ness(0, 'blib/lib', 'blib/arch') t/*.t t/00load # Failed test (t/00load.t at line 6) # Tried to use 'DateTime'. # Error: Can't locate loadable object for module DateTime in @INC (@INC con tains: /u1/mis01/Perl/DateTime-0.30/blib/lib /u1/mis01/Perl/DateTime-0.30/blib/a rch /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/5.8 /usr/lib/perl5/site _perl/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/site_perl/5.8 /usr/lib/perl5/site_pe rl/5.8 /usr/lib/perl5/sco_perl/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/sco_perl/5. 8 /usr/lib/perl5/sco_perl/5.8 .) at /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0/XSLoad er.pm line 44 # BEGIN failed--compilation aborted at t/00load.t line 6. # Compilation failed in require at (eval 3) line 2. # BEGIN failed--compilation aborted at (eval 3) line 2. # Looks like you failed 1 test of 1. dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test 1 Failed 1/1 tests, 0.00% okay t/01sanity..Can't locate loadable object for module DateTime in @INC (@INC contains: /u1/mis01/Perl/DateTime-0.30/blib/lib /u1/mis01/Perl/DateTime-0 .30/blib/arch /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/5.8 /usr/lib/ perl5/site_perl/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/site_perl/5.8 /usr/lib/per l5/site_perl/5.8 /usr/lib/perl5/sco_perl/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/s co_perl/5.8 /usr/lib/perl5/sco_perl/5.8 .) at /usr/lib/perl5/5.8/i586-pc-sco3.2v 5.0/XSLoader.pm line 44 BEGIN failed--compilation aborted at /u1/mis01/Perl/DateTime-0.30/blib/lib/DateT ime.pm line 44. Compilation failed in require at t/01sanity.t line 7. BEGIN failed--compilation aborted at t/01sanity.t line 7. # Looks like your test died before it could output anything. dubious Test returned status 255 (wstat 65280, 0xff00) DIED. FAILED tests 1-16 Failed 16/16 tests, 0.00% okay -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: compiling DateTime module on SCO OSR5
BTW, I originally tried installing it through perl -MCPAN -e shell always running installs as root. Scott Taylor said: Hello all, I'm trying to compile DateTime module for Perl in SCO OSR5.07 and failing miserably. I have no idea what these errors mean. Can anyone tell me what I need, or what I'm doing wrong? All tests in the make test are failing with messages like this one: PERL_DL_NONLAZY=1 /usr/bin/perl -MExtUtils::Command::MM -e test_har ness(0, 'blib/lib', 'blib/arch') t/*.t t/00load # Failed test (t/00load.t at line 6) # Tried to use 'DateTime'. # Error: Can't locate loadable object for module DateTime in @INC (@INC con tains: /u1/mis01/Perl/DateTime-0.30/blib/lib /u1/mis01/Perl/DateTime-0.30/blib/a rch /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/5.8 /usr/lib/perl5/site _perl/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/site_perl/5.8 /usr/lib/perl5/site_pe rl/5.8 /usr/lib/perl5/sco_perl/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/sco_perl/5. 8 /usr/lib/perl5/sco_perl/5.8 .) at /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0/XSLoad er.pm line 44 # BEGIN failed--compilation aborted at t/00load.t line 6. # Compilation failed in require at (eval 3) line 2. # BEGIN failed--compilation aborted at (eval 3) line 2. # Looks like you failed 1 test of 1. dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test 1 Failed 1/1 tests, 0.00% okay t/01sanity..Can't locate loadable object for module DateTime in @INC (@INC contains: /u1/mis01/Perl/DateTime-0.30/blib/lib /u1/mis01/Perl/DateTime-0 .30/blib/arch /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/5.8 /usr/lib/ perl5/site_perl/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/site_perl/5.8 /usr/lib/per l5/site_perl/5.8 /usr/lib/perl5/sco_perl/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/s co_perl/5.8 /usr/lib/perl5/sco_perl/5.8 .) at /usr/lib/perl5/5.8/i586-pc-sco3.2v 5.0/XSLoader.pm line 44 BEGIN failed--compilation aborted at /u1/mis01/Perl/DateTime-0.30/blib/lib/DateT ime.pm line 44. Compilation failed in require at t/01sanity.t line 7. BEGIN failed--compilation aborted at t/01sanity.t line 7. # Looks like your test died before it could output anything. dubious Test returned status 255 (wstat 65280, 0xff00) DIED. FAILED tests 1-16 Failed 16/16 tests, 0.00% okay -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: compiling DateTime module on SCO OSR5
Tom Phoenix said: On 1/10/06, Scott Taylor [EMAIL PROTECTED] wrote: I'm trying to compile DateTime module for Perl in SCO OSR5.07 and failing miserably. # Error: Can't locate loadable object for module DateTime in @INC It looks as if something failed long before this point, during the build process. I recommend that you re-do the installation from the beginning, watching for any error messages along the way. You lost me. Perl 5.8 comes with the OS and is built and maintained be SCO. I'm guessing DateTime needs something in order to compile, but what? Why would it say it can't locate an object in the modules that I'm trying to install? That was the beginning. Those are the first error messages. Have you been able to install similar modules before? If you didn't build perl on the same machine that's running it, something may not be configured correctly for building modules there. I have installed many other modules, like email stuff and WriteExcel, but nothing with Date and Time functions like this one. -- Scott -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: compiling DateTime module on SCO OSR5
Tom Phoenix said: On 1/10/06, Scott Taylor [EMAIL PROTECTED] wrote: I'm trying to compile DateTime module for Perl in SCO OSR5.07 and failing miserably. # Error: Can't locate loadable object for module DateTime in @INC It looks as if something failed long before this point, during the build process. I recommend that you re-do the installation from the beginning, watching for any error messages along the way. Have you been able to install similar modules before? If you didn't build perl on the same machine that's running it, something may not be configured correctly for building modules there. Thanks Tom, Taking a closer look, now looks like SCO's C compiling system is FUBAR. Really nice. -- Scott -- 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 Help
Bob Showalter said: Scott Taylor wrote: Dermot Paikkos said: I would also say that the source file is wrong, it should read STREETNUM/STREETNUM I read somewhere that blah / is correct syntax (same as blah/blah) You are correct. The two forms are exactly equivalent. see: http://www.w3.org/TR/REC-xml/#sec-starttags Yeah, that's where I read it. Still doesn't help me validate the hash though. :( -- Scott -- 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 Help
Bob Showalter said: Scott Taylor wrote: Hi All, I'm using XML::Simple to parse a very simple XML file and dump the data into hashes of hashes. The problem I'm getting, is sometimes information is blank in the XMl file; it looks like this: STREETNUM/ instead of STREETNUM1234/STREETNUM and when I print the hash: print $x-{VEHICLE}-{STREETNUM} ; it returns: HASH(blahblah); How do I test for this so it prints blank? I've tried many things, the most logical I could think of was: if ($x-{VEHICLE}-{STREETNUM}){ print ... } else { print ; } Two ways to do this: 1) use SuppressEmpty option. This will simply exclude the STREETNUM element if it is empty (no attributes and no content) Thanks. That works, and I don't even have to test it in my output. :) 2) use ForceContent option. This will treat the STREETNUM element as a hash even if it is empty or contains only text. In this case you would use $x-{VEHICLE}{STREETNUM}{content} in your code. #2 would probably be safer, because it would handle attributes to STREETNUM elements properly. I tried that an all I got was a bunch of trouble; the program seem to go into a forever loop. :( I'm just using the data from the file, no attributes, does that matter? You can read more about these options in the XML::Simple documentation. Of course I did, it just doesn't make a lot of sense. :) -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Dates
Hello, I have a date in UT that looks like this: 2005-11-02 01:36:00.0 Can anyone tell me the best way to subtract 8 hours from it, or to convert it to PDT? I'm reading up on Date::Manip, but I don't know if that is going to help, yet. Cheers. -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
XML Help
Hi All, I'm using XML::Simple to parse a very simple XML file and dump the data into hashes of hashes. The problem I'm getting, is sometimes information is blank in the XMl file; it looks like this: STREETNUM/ instead of STREETNUM1234/STREETNUM and when I print the hash: print $x-{VEHICLE}-{STREETNUM} ; it returns: HASH(blahblah); How do I test for this so it prints blank? I've tried many things, the most logical I could think of was: if ($x-{VEHICLE}-{STREETNUM}){ print ... } else { print ; } but even that doesn't work. Cheers. -- Scott -- 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 Help
Dermot Paikkos said: On 3 Nov 2005 at 7:45, Scott Taylor wrote: Hi All, I'm using XML::Simple to parse a very simple XML file and dump the data into hashes of hashes. The problem I'm getting, is sometimes information is blank in the XMl file; it looks like this: STREETNUM/ instead of STREETNUM1234/STREETNUM and when I print the hash: print $x-{VEHICLE}-{STREETNUM} ; it returns: HASH(blahblah); How do I test for this so it prints blank? I've tried many things, the most logical I could think of was: if ($x-{VEHICLE}-{STREETNUM}){ print ... } else { print ; } but even that doesn't work. Cheers. Not sure if I am qualified enough to answer this but I have had a bit of experience with XML::Simple. I would recommend using my $x = XMLin($fh, ForceArray = 1); That seems to have made a worse mess. Somehow ends up in a huge loop. :( I would also say that the source file is wrong, it should read STREETNUM/STREETNUM I read somewhere that blah / is correct syntax (same as blah/blah) but that doesn't mean that XLM::Simple likes it any better. Unfortunately, I can't change the input file much. Relly all I am looking for is a way to test if a Hash has a legitimate value in it, or is it going yo output that way. Thanks for your help. -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: $ or % For Associative Arrays?
Mark Sargent said: Hi All, am new to Perl. I'm followig this tutorial, http://www.cs.unc.edu/~jbs/resources/perl/perl-basics/variables.html and am confused as to why the below shows examples with $ and some with % at the beginning of the statement. When it says, Perl uses the percent symbol and curly braces with respect to the name of an associative array as a whole. Am I to assume that either is fine, when defining associative arrays.? Cheers. I can see why you are confused, that whole tutorial is confusing, not to mention outdated (I think someone already did). $aAA{A} = 1; # creates first row of assoc. array $aAA{B} = 2; # creates second row of assoc. array move confusing part %aAA = (A, 1, B, 2); # same as first two stmts., above Maybe better to look at it this way: %hash = (Apple = Red, Banana = Yellow, Orange = Orange); Now, when you want the value of Banana we look at the scalar (single entity) of the hash: print My bananas are $hash{'Banana'}.\n; Now to add a new key=value pair $hash{Blueberries} = Blue; There are many good, Perl5 examples and tutorials out there, this one comes to mind: http://www.codebits.com/p5be/ and perl.com has a lot of useful stuff, if you don't mind digging about, as well as CPAN.org, although, maybe a bit more cryptic. Have fun, I know I am. :) -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Fw: Could [you] [please] tell me how to remove white spacees presentbetween delimiter[s]
#!/usr/bin/perl my $st1='---'~^ '123PS01D'~^; for(split(/\~\^/,$st1)) { $_ =~ s/\s//g; # Do something with your variable } Is that what you're asking? I'm unsure [EMAIL PROTECTED] wrote: '---'~^ '123PS01D'~^ here delimiter is ~^ '---'~^'123PS01D'~^ Do u see the difference in the two lines In the first one there is space is present i want to remove that one The second is ok.. I think it will clear u in the better way. with regards Mayank Ahuja Assistant System Engineer Tata Consultancy Services Limited Ph:- 044-5816 Cell:- 9283199460 Mailto: [EMAIL PROTECTED] Website: http://www.tcs.com - Forwarded by Mayank Ahuja/CHN/TCS on 09/02/2005 09:16 PM - Chris Devers [EMAIL PROTECTED] 09/02/2005 09:03 PM Please respond to Perl Beginners List beginners@perl.org To [EMAIL PROTECTED] cc Perl Beginners List beginners@perl.org Subject Re: Could [you] [please] tell me how to remove white spacees presentbetween delimiter[s] On Fri, 2 Sep 2005 [EMAIL PROTECTED] wrote: I have a file like this in which data is abc,def,xyz,mno, means the delimter is comma here but in the string if it comes abc, def, xyz, mno then [please] tell me how to remove this white space. The popular way to do this around here is with a Perl program. Can you show the list the Perl program you've tried so far? If you can, we can try to give you feedback. Good luck! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Parsing HTML
Jenda Krynicky said: From: Scott Taylor [EMAIL PROTECTED] I'm probably reinventing the wheel here, but I tried to get along with HTML::Parser and just couldn't get it to do anything. To confusing, I think. I simply want to get a list or real words from an HTML string, minus all the HTML stuff. For example: snipped use HTML::JFilter qw(StripHTML); # http://www24.brinkster.com/jenda/#HTML::JFilter $plain_text = StripHTML($text_with_html); Nice thought, but the link leads nowhere. Cute comic though. Thanks. -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Parsing HTML
Jenda Krynicky said: From: Scott Taylor [EMAIL PROTECTED] I'm probably reinventing the wheel here, but I tried to get along with HTML::Parser and just couldn't get it to do anything. To confusing, I think. I simply want to get a list or real words from an HTML string, minus all the HTML stuff. For example: snipped use HTML::JFilter qw(StripHTML); # http://www24.brinkster.com/jenda/#HTML::JFilter $plain_text = StripHTML($text_with_html); Oops, sorry, there it is, just really slow. :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: DBD::Oracle installation script assumes oracle is installed local ly?
[EMAIL PROTECTED] said: Hi all. I am attempting to install DBD::Oracle from the perl CPAN shell. The installation script seems to assume that oracle is installed locally. It asks me to set ORACLE_HOME to the path the oracle is installed and to try again. Well I don't have oracle installed locally. I want to install DBD::Oracle so I can connect to a remote oracle server. Any ideas? Install Oracle. Probably just looking for some specific library from Oracle, just like most other DBD's do. If you can download the source code and figure out what that library is, you may be able to install just that file and go, but probably easier to just install Oracle. Oracle does not need to be running on the local server, just installed for the libs. -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: can any body tell me how to remove quotes from a name.
Eric Walker said: if the 'mayank' is in a text file, then cat file | sed s/\'//g newfile this should do it I think. LMAO - Nice, for a top poster, On Wednesday 31 August 2005 03:42 am, [EMAIL PROTECTED] wrote: Hi all Could any body tell me how to get mayank from 'mayank' now for something completely different: perl way: my $something = \'mayank\'; $something =~ s/'//g; sp. by map or grep command Maybe you want a different list, not perl begginers? -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Escaping with tr
Bernard van de Koppel said: Hi, How can I get all the characters out of a csv file. Input looks like bla bla;bla bla;bla bla and it has to look like bla bla;bla bla; bla bla I tried $text=~ tr(#\##); but perl keeps complaining about Might be a runaway multi-line ;; starting on the line with tr. Try to use $text=~s///g; -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Escaping with tr
Wiggins d'Anconia said: Scott Taylor wrote: I did not. Hi, How can I get all the characters out of a csv file. Input looks like bla bla;bla bla;bla bla and it has to look like bla bla;bla bla; bla bla I tried $text=~ tr(#\##); but perl keeps complaining about Might be a runaway multi-line ;; On a more serious note. Simply removing *all* double quotes can be a dangerous proposition unless your data really does look like bla bla which I somewhat doubt. Usually a delimited file like this will quote specific fields because they may contain the delimiter, in this case a semi-colon. Are you sure bla bla can't be blah; blah blah, and then in the future need to still be delimited by the semi-colon? Just checking... It is not uncommon to find CSV output in the format he describes. Often I need to remove all the quotes out of simple data streams like that. -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Parsing HTML
Hi, I suck at regex, but getting better. :) I'm probably reinventing the wheel here, but I tried to get along with HTML::Parser and just couldn't get it to do anything. To confusing, I think. I simply want to get a list or real words from an HTML string, minus all the HTML stuff. For example: $a = 'This is a line of HTML:people write strange things herebr and hardly ever follow properp syntax Aamp;B suck at spelling as wellbr So I need to clean it up and strip out allbr words less then 3 characters in length.p Later the words will go into an indexer forbr searching a database'; $a =~ s/[^]*//gs; $a =~ s/amp;//gs; # probably need to add more like this @data = split (/ /,$a); foreach $b (@data) { foreach $b (split (/\n/,$b)){ foreach $b (split (/:/,$b)){ $b =~ s/^\s+//; $b =~ s/\s+$//; $b =~ s/\n//g; $b =~ s/\c//g; $b =~ s/[,.-;?]//gs; if ($b and (length($b) 3)){ print D$b\n; } } } } Is there a better, maybe more eligant, way to do this? I don't mind to use HTML::Parser if I could only figure out how. Cheers. -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Need a list of files in a dir.
Your a funny dude Chris. On 8/25/05, Chris Devers [EMAIL PROTECTED] wrote: On Thu, 25 Aug 2005, Luinrandir wrote: How do I get the list of files in a DIR and put in an array? I'm drawing a blank on my search for this. Try writing a program instead, that seems to work better than drawing. Some people use globs in their programs for this. What did you try? -- 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Shell output
Hello all, I have a CGI script that I need to display the output of a shell program, basically a simple C program that parses some text. The output is right to the browser, and I don't want it to be creating any new files or anything. I have a data field that has a blob and that blob needs to be parsed and the output returned to the browser. What is a good way to do this: while ( my ($row ) = $sth-fetchrow_hashref ) { my $raw_data = $row-{BLOB}; my $parsed_data = system (echo $raw_data|pasrer); ... } of course that doesn't work, but what would be the right way to do it? Cheers. -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Shell output
Wiggins d'Anconia said: Scott Taylor wrote: Hello all, I have a CGI script that I need to display the output of a shell program, basically a simple C program that parses some text. The output is right to the browser, and I don't want it to be creating any new files or anything. I have a data field that has a blob and that blob needs to be parsed and the output returned to the browser. What is a good way to do this: while ( my ($row ) = $sth-fetchrow_hashref ) { my $raw_data = $row-{BLOB}; my $parsed_data = system (echo $raw_data|pasrer); ... } of course that doesn't work, but what would be the right way to do it? Cheers. -- Scott You should have a look at the section Pipe Opens in, perldoc perlopentut Now I'm really confused! LOL Should be what you are looking for. I do assume you have a good reason for writing the parser in C I didn't write it, way beyond me. Thanks. -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Shell output
Jay Savage said: On 8/23/05, Scott Taylor [EMAIL PROTECTED] wrote: Hello all, I have a CGI script that I need to display the output of a shell program, basically a simple C program that parses some text. The output is right to the browser, and I don't want it to be creating any new files or anything. I have a data field that has a blob and that blob needs to be parsed and the output returned to the browser. What is a good way to do this: while ( my ($row ) = $sth-fetchrow_hashref ) { my $raw_data = $row-{BLOB}; my $parsed_data = system (echo $raw_data|pasrer); ... } of course that doesn't work, but what would be the right way to do it? Cheers. -- Scott Use backticks. $data = `/path/to/parser $raw_data` That was easy! Thanks. :) -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
escaping in CGI.pm
Grr... Arg... Hello all, I'm working on my first Perl/CGI database app and run into a bit of a snag: http://myserver/lseid.cgi?LeaseOPID=ADT89theCmd=EditIt this line finds the right data however, everything after the in the LeaseOPID ($row-{leaseopid}) ADT89 gets truncated in this form line: textfield(-name='LeaseOPID', -value=$row-{leaseopid}, -size=8, -maxlength=8),p,\nName: , I've tried every combination of quotes, , ' , qw, qq, that I can think of but no luck. Is there any way to do this? I get why it does it, just don't know how to get around it. App works fine with data that doesn't have ampersands in it. :) Please feel free to beat me over the head if I don't make any sense here. Cheers -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: escaping in CGI.pm
Joshua Colson said: Scott, You're trying to use an ampersand in your URL. Ampersands are special characters in URLs so you must escape it if you want it to be passed as the actual character instead of carrying the special meaning. See http://www.december.com/html/spec/esccodes.html As I said, I know that much, just how to do it using the CGI.pm or maybe some other module maybe? -- Scott -- 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
Thank you for most helpful information. :) Offer Kaye said: On 5/19/05, Scott Taylor wrote: ... to pump out lines of data to my SQL statement. I'll need to end up with something like: qw($vid,$eid,$event,$desc ,$date,$mid_desc,$mid_val ,$pid_desc,$pid_val,$min,$max,$val) for each line of data. (or whatever works) I think I'm just lost at the nested hash (if that's what it's called) thingy, and how to work with it. :| It's a data structure, consisting of references to hashes and to arrays. To begin with, start by reading tutorials such as: http://perldoc.perl.org/perlreftut.html - references tutorial http://perldoc.perl.org/perldsc.html - data structures cookbook Once you've mastered the basics, you should be able to understand these two statements: $vid = $ref-{'vid'}; $pid_val = $ref-{'j1587'}-{'data'}-[0]-{'pid'}-{'val'}; These are just examples. To get at all the data in an organized way, you'll need to wrap calls such as the above in loops-within-loops, depending on how deep your data structure is. Of course, after a while you might get tired of manually looping over your data. In that case I suggest you start looking at XML modules that provide OO access methods to your data, such as XML::SimpleObject : http://search.cpan.org/dist/XML-SimpleObject/SimpleObject.pm That's just a suggestion, there are of course many others out there :-) HTH, -- Offer Kaye -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
XML
Hello, I have an XML file that I need to import to a database, however, searching CPAN for XML brings up a lot of stuff. I don't know what I need to know. :( What module should I use for something simple like the following data? Can someone provide an example, or direct me to some good docs with working examples. I tried XML::Parser but even the example didn't work, and the little docs it has makes no sense to me. If I could get the data into some form of variables, I can do the DB parts. Cheers. device drv/drv eventI/event vid29751/vid eid0/eid jibrish data mid val128/val descblah blah/desc /mid pid val245/val descTotal Distance/desc /pid val1060771/val max1060771/max min0/min /data data mid val128/val descblah blah/desc /mid pid val182/val descTrip Fuel/desc /pid val0/val max0/max min0/min /data /jibrish /device -- Scott -- 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
Wiggins d'Anconia said: Scott Taylor wrote: Hello, I have an XML file that I need to import to a database, snip What module should I use for something simple like the following data? I would start with XML::Simple until you need more. use XML::Simple; my $xs = new XML::Simple; my $ref = $xs-XMLin('test.xml'); use Data::Dumper; print Dumper($ref); OK. That looks really kewl. Now how do I loop through this ... $VAR1 = { 'vid' = '29751', 'desc' = 'Ignition On', 'date' = '20050517235927', 'drv' = {}, 'j1587' = { 'data' = [ { 'mid' = { 'desc' = 'Engine #1', 'val' = '128' }, 'pid' = { 'desc' = 'Total Vehicle Distance', 'val' = '245' }, 'min' = '0', 'max' = '1060771', 'val' = '1060771' }, .. { 'mid' = { 'desc' = 'Engine #1', 'val' = '128' }, 'pid' = { 'desc' = 'Trip Fuel', 'val' = '182' }, 'min' = '0', 'max' = '0', 'val' = '0' } ] }, 'eid' = '0', 'event' = 'I' }; ... to pump out lines of data to my SQL statement. I'll need to end up with something like: qw($vid,$eid,$event,$desc ,$date,$mid_desc,$mid_val ,$pid_desc,$pid_val,$min,$max,$val) for each line of data. (or whatever works) I think I'm just lost at the nested hash (if that's what it's called) thingy, and how to work with it. :| Cheers. -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Use Perl to extract keywords
Robert: An example is below. #!/usr/bin/perl -w open(FILE,/etc/passwd) || die Cannot open file: $!; while ( FILE ) { if( /Ezra/ ) #I'm searching for strings with the word Ezra. { print $_; # Now I'm printing lines with the name Ezra } } close(FILE); On 4/24/05, Robert Kerry [EMAIL PROTECTED] wrote: I want to use Perl to extract keywords from plaintext, don't know whether there are some exsiting package / algorithm for doing that? Thank you. Regards, Robert. -- 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: ideintifying whether a module is already installed or not
Hi list, How do I know whether a given module is installed on machine or not? Thanks and Regards, Manish Hi Manish - The way I check to see if a module is installed perl -e use ModuleName; (eg. perl -e use XML::Simple: If you get an error, then it is not installed. Now I use ActiveState Perl on an XP box. If you're using perl on a Unix-type machine, the double quotes may need to be perl -e 'use XML::Simple;' Someone here will correct me if I'm wrong about this. HTH, Mark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: read a directory
Hey Carl - I got in a hurry and did some cut and paste without paying close enough attention. The line should read my $dir = 'C:\GIS\wrapped_data'; I apologize for the error. Mark got this error line 9 near = = aborted due to compilation error */Mark Taylor [EMAIL PROTECTED]/* wrote: Hello group, Hello. I'm trying to read the directory C:\GIS\wrapped_data and write record. My scripts is erroring with can't open directory: no such file or directory. What am I missing? $outfile = $infile.txt; my $dir = C:\GIS\wrapped_data; opendir(DIR,$dir) or die Can't open $dir directory: $!; open (OUT, $outfile) or die Error, cannot open file: $outfile. $!; $record = ; $index=0; while ( $numbytes = read(DIR, $record, 1200) ) { $index++; if ($numbytes == 1200) { print OUT $record; } else { die File Read Error on record $index: $numbytes bytes read; Should be 1200.\n; } } close DIR; close OUT; Try this, my $dir = = 'C:\GIS\wrapped_data' instead. HTH, Mark *Carl Johnson* *Principal Consultant* *214-914-9509 - P* *214-242-2020 - F* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]* -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Filter Regular Expressions
Gomez, Gonzalo wrote: Hi, I want to filter text using regular expressions, but i don't know how to find in a file a string like this NONE , or NONE/ , or /bsvgId , Etc. I try to use the little script bellow with a count for the word but this scrit doesn't work if i put symbols like / , \ , , (Reserved Symbols). Anyone can help me ? Thanks. Begin Script #!/usr/bin/perl $count=0; while () { $count += s/\bNONE\b//g; } print $count\n; End Litle Script Este mensaje (incluyendo cualquier anexo) contiene información confidencial que se encuentra protegida por la Ley. La información que contiene, sólo puede ser utilizada por la persona o compañía a la cual está dirigido. Si usted no es un receptor autorizado, o por error recibe el mensaje, omita su contenido y elimínelo inmediatamente. Cualquier retención, difusión, distribución y/o copia así como la ejecución de cualquier acción basado en el contenido del mismo, se encuentra estrictamente prohibido, y esta amparado por la ley. -- This message (including any attachments) contains confidential information intented for a specific individual and purpose, and is protected by law. If you are not the intented recipient, you should delete this message. Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. Gomez: A possible solution for this could be: #!/usr/bin/perl -w open(FILE, test) or die Can't open : $!\n; $count=0; while(FILE) { chomp; if (m/NONE/) { $count++; } #end of if statement } #end of while loop print The count for NONE is $count\n; close FILE; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Storing $DIGIT variables in arrays
Below I have posted the source for a program I am attempting to write that will take a list of URL's, grab the pages, and search them for email addresses and IP addresses, remove duplicate entries, and store the results in a text file. Everything compiles fine and runs without any warnings, however my output is not what I expected. When I run it with this URL in my list: http://gentoo-solid.no-ip.com/testpage.php , the output file does not contain either of the actual IP addresses and instead picks the only one that is NOT an IP address and just takes the first four numbers 45.45.45.45. The emails are working fine, however and all show up in the output file. Any help on this would be appreciated. Thanks, Jesse Taylor ##--START CODE--## #!/usr/bin/perl -w #Given a text file containing URLs, this script will extract any IP addresses or email address from said URLs use LWP::Simple; print Enter location of URL list file: ; chomp($infile=STDIN); open INFILE, $infile or die Could not open file $infile; print Enter location at which to create output file: ; chomp($outfile=STDIN); open OUTFILE, $outfile or die Could not open/create $outfile; while($url=INFILE) { chomp($url); $html=get($url) or die Couldn't open page located at $url; @ips = $html =~ /(\d{1,3}[0-255]\.\d{1,3}[0-255]\.\d{1,3}[0-255]\.\d{1,3}[0-255])/g; #find and store IP addresses @emails = $html =~ /([EMAIL PROTECTED])/g; #find email addresses and store push(@allips, @ips); push(@allemails, @emails); } remove duplicate array members for($i=0; $i(scalar @allips); $i++) { for ($j=0; $j(scalar @allips); $j++) { if ($allips[$i] eq $allips[$j] $i!=$j) { splice(@allips, $j, 0); } } } remove duplicate array members for($i=0; $i(scalar @allemails); $i++) { for ($j=0; $j(scalar @allemails); $j++) { if ($allemails[$i] eq $allemails[$j] $i!=$j) { splice(@allemails, $j, 1); } } } Store data in output file print OUTFILE IP Addresses: \n; foreach (@allips) { print OUTFILE $_\n; } print OUTFILE \nEmail Addresses: \n; foreach (@allemails) { print OUTFILE $_\n; } close(INFILE); close(OUTFILE); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Mod_Perl Pass Associative Arrays
Chris Devers wrote: On Fri, 10 Dec 2004, James Taylor wrote: Hi everyone, wondering if anyone knew how to pass an associative array via POST to mod_perl. Something like: HTML forms don't really provide for complex data structures, so any solution is going to have to be cobbled together. I think your best bet is to just have form elements with names like 'searchname', 'searchemail', etc, and just have code on the server to organize it into a hash: $search{name} = $req-param('searchname'); $search{email} = $req-param('searchemail'); etc. Eh, score 1 for PHP then. The reason I can't specifically do what you're mentioning is that the field names being passed could be ANYTHING, as the code is for a module I'm writing. Anyway, I went ahead and just made it cheesy, instead of doing field[something], i made all of the input names field=something, send the hash through a foreach loop - if the name of the field =~ /field/, i split on the = and ditch the first variable. Feh -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Mod_Perl Pass Associative Arrays
Hi everyone, wondering if anyone knew how to pass an associative array via POST to mod_perl. Something like: input type=text name=search[name] / input type=text name=search[email / then it posts to say.. example.pl my $r=Apache-request; my $req=Apache::Request-new(shift); my %stuff=$req-param('search'); That for example doesn't work, but... I'd like it to :) Anyone know how to get this going? By the way, I *need* the names to preserve, having search[] would defeat the purpose of what I'm trying to do here. Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
setting more than 1 -domain= in cookies
Hello all, I have a perl script that I am using to write a cookie: my $cookie = new CGI::Cookie(-name='usrID', -value=$usrID, -expires='+4h', -domain='.mydomain.com', -path='/'); ## send cookie print Set-Cookie: $cookie\n; What I want to know is the a way of setting more than 1 domain ??? ie: -domain='.mydomain.com, .mydomain2.com' for example ??? I am still trying to figure out why i cant read cookies when my perl scripts are taken into a frame ??? My perl scripts are on 1 domain and my framset is on another - there must be a way around this ?? thanks again for your help Anadi
Cookies and frames
Hello all, First a big thanks for all your help - its been invaluable and helpful with my education. Perl rocks and it has been made easier to learn because of this forum :-) OK - Now for my question. I have created a shopping cart (using perl of course :-) ) and it works fine until I put the pages into an HTML FRAME. This is a real bummer because I thought I had it sussed. The problem seems to be with getting cookies while my page is in a frameset - has anyone else had this problem and how do i get around this thanks again Anadi
$ID = $newcook{'usrID'}-value;
Hello again, I have a problem with cookies; I can retreive cookies i have set, but if I try to retreive a cookie that hasnt yet been set i get the following error: Can't call method value on an undefined value at viewcart.pl line 55. I am trying to get my cookie using: $ID = $newcook{'usrID'}-value; which works fine unless this cookie hasnt been set. This is all part of a shopping cart and that the reason why the possibility arises that someone may veiw their empty cart and therefore no cookie will have been created. Anyway, my question is: how do I test to see if a coockie exists b 4 i try to read it ??? Thank you all in advance, Anadi
question about doing it right in CGI
Hi all, I have been using perl for sometime for CGI scripts, but have always used the print content-type:html version of doing things. I would like to learn a better way with the CGI module, but when I read the docs I find it pretty easy to get confused as to whether I should use the object oriented method, or the functional method. Also, because my script is a cgi form that gets some of the select fields from a mysql database, I am not sure how to convert that over. I don't know how I would make the select field work the same. I am not asking for someone to rewrite my project, merely provide me with some examples of how they would write the same code using the cgi module so I can figure this out a bit better... On my form, I am querying a database for a list of names and loading them into a select box. But I found out people want to enter more than one name at a time, so I loop through 15 times, and they can select up to 15 names... They select a name, but I store the name's id, so it acts as a lookup field... Here is how I do this now.. #Connect to database print table\n; for (1..15) { print td nowrap\n; $query_teams=(select id, name from teams); $sth = $dbh-prepare($query_teams); $sth-execute(); $sth-bind_columns(\$id, \$name); print select name='away_team$_'; #$_ traps which pass of the loop we are in i.e., 3rd pass, 4th pass, etc print option value='0'/option\n; while($sth-fetch()) { print option value='$id'$name/option\n; } print /select\n; $sth-finish(); print /td\n; } #end for loop print /table\n; #disconnect from database How would I start to convert this with the CGI module. My problems thus far are on a popup menu, how do I specify the field variable that I grab is the ID, while the displayed value is another, and how can I say the first value should be 0, in case they do not enter anything? Thanks in advance, Taylor -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
CGI.pm program
I have a CGI.pm program that works from the command line, but when I try and view it from the browser, the error_log shows, malformed header from script. Bad header=?xml version=1.0 encoding=: /web/cgi-bin/bb_test/bb_test5.p I don't have these problems when I just use content-type:html, so any idea why this happens when I use the CGI.pm module? Thanks, Taylor -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: more cookies in perl and asp
Anadi, are the Perl scripts and the ASPs on the same server (webhost, not machine!)? In the same directory? Maybe you have to specify the domain when creating the cookie. Jenda Hello Jenda, Both the perl scripts and the asp's are run on the same server BUT the asp's are run from a different folder from the perlscripts. I have just specified the domain in my cookie: $usrID = createUsrID(); ## create cookie my $cookie = new CGI::Cookie(-name='usrID', -value=$usrID, -expires='+2h', -domain='.mydomain.com', -path='/'); ## send cookie print Set-Cookie: $cookie\n; And I can now read this cookie with my asp script :-) usrID = Request.cookies(usrID) Thank you for your help :-) Anadi
more cookies in perl and asp
Thanks for your reply, I am going to re-write my problem; I am creating a cookie in perl script: $usrID = createUsrID(); ## create cookie my $cookie = new CGI::Cookie(-name='usrID',-value=$usrID); ## send cookie print Set-Cookie: $cookie\n; and then I am trying to recall that cookie in an asp script: usrID = Request.Cookies(usrID) but the asp script doesnt see the cookie. I can recall the same cookie again later in a perl script so I know it exists. What am I doing wrong Surely what I am trying to do is possible Thanks again Anadi I'm not sure I understand your question. ASP provides objects to enable server side scripts to produce web pages. Those scripts can be written in any sever side scripting language including perlscrpt, VBscript, and Jscript. You can retrieve cookies in the ASP environment using the Cookies method of the Response object. This page walks you through an example. : Hi all, : I have a problem that I am hoping someone can shed some : light on. I have written a cookie in perl and what I want : to do is read the cookie back but in an asp script. I can : read the cookie back in other perl scripts but the asp : script doesnt see it. Why is this and is there anyway : around it ??
How do I set POST vars from a perl script
Hi all, I am trying to set some HTTP header variables in a perl script that I can then pick up in another script. I want to create a situation as if some one had POSTed variables from a form. I then want to pick these variables up in an .asp script. I have tried picking up cookies with an asp script that were written from a perl script but it doesnt work. I need to be able to pass reasonably secure data from 1 script to another and therefore cannot use the QUERY_STRING. Please help :-) Thank you all in advance Anadi
cookies in perl and asp
Hi all, I have a problem that I am hoping someone can shed some light on. I have written a cookie in perl and what I want to do is read the cookie back but in an asp script. I can read the cookie back in other perl scripts but the asp script doesnt see it. Why is this and is there anyway around it ?? thanks for your help :-) Anadi
Mod_Perl Target Headers
I posted this to the mod_perl list originally, but noone ever answers my questions on there. Guess my noob questions don't belong on that list: Again, this is for mod_perl Should be a pretty simple question, looking for an option in header_out to target a frame. For example... snip $r=Apache-request; $r-err_header_out(Pragma, no-cache); $r-header_out('Location' = 'http://www.somesite.com/login_expired.html'); $r-status(REDIRECT); $r-send_http_header; snip Was hoping I could do something like: $r-header_out('Target'='_top'); but that doesn't seem to work. Any suggestions? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Help with sprintf and prinf
Hi all, I am trying to figure out sprint and prinf: what I am trying to do is format a number into a currency, so 9.9 would be printed as 9.90 Can anyone give me a simple example of this - i am not having any joy by myself :s Thanks in advance Anadi
Help with sprintf and prinf
Hi all, I am trying to figure out sprint and prinf: what I am trying to do is format a number into a currency, so 9.9 would be printed as 9.90 Can anyone give me a simple example of this - i am not having any joy by myself :s Thanks in advance Anadi
Help with sprintf and prinf
Hi all, I am trying to figure out sprint and prinf: what I am trying to do is format a number into a currency, so 9.9 would be printed as 9.90 Can anyone give me a simple example of this - i am not having any joy by myself :s Thanks in advance Anadi
Help with sprintf and prinf
Hi all, I am trying to figure out sprint and prinf: what I am trying to do is format a number into a currency, so 9.9 would be printed as 9.90 Can anyone give me a simple example of this - i am not having any joy by myself :s Thanks in advance Anadi
RE: Help with sprintf and prinf
Thank you for your help - didnt mean to send the last email so many times - it wont happen again :-) A Do not do that. Please. One copy is plenty. I am trying to figure out sprint and prinf: what I am trying to do is format a number into a currency, so 9.9 would be printed as 9.90 Can anyone give me a simple example of this - i am not having any joy by myself :s Please learn how to use perldoc, Google, /or books. The first hit on a Google search for perldoc sprintf gives this: # Round number to 3 digits after decimal point $rounded = sprintf(%.3f, $number); http://www.perldoc.com/perl5.8.4/pod/func/sprintf.html Hopefully you can figure out how to adapt this for 2 digits. -- 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
help - $line =~ tr/images\//..\/..\/images\//
Hi all, I wonder if someone can help me. What I want to do sounds so simple but I just cant crack it. I am reading in an html page and i want to change 'images/' to '../../images' but i am going round and round in circles. my code so far is this: #!/usr/bin/perl ## set up for output to be sent to browser print Content-type: text/html\n\n; ## read in mp3store.html if (open (INFILE, ../../mp3store.htm)) { foreach $line (INFILE) { $line =~ tr/images\//..\/..\/images\// print $line; } } else { print could not open mp3store.htm; } exit(0); the line: $line =~ tr/images\//..\/..\/images\// is where I am getting stuck everything else is working fine Any help or advice would be greatly received Thank you in advance Anadi
Re: Mod Perl Helper Functions
Bob Showalter wrote: FWIW, That example works OK for me under Apache 1.3.31, mod_perl 1.29 when I run under Apache::Registry. I had to add a declaration for %somehash, but otherwise it runs without error. Is main.pl running under Apache::Registry, or is it a PerlHandler or some other type of handler? It always makes me nervous to see assumptions about the current working directory in any web server stuff. You should code the full path to helper.pl, or better, create a proper module and pull it in with use. Here's a better example of something that actually might serve a bit more purpose along with the error I'm getting for THIS particular example. And yes, this is running under Apache::Registry: test.pl: #!/usr/bin/perl use strict; use Apache::Constants qw(OK DECLINED SERVER_ERROR FORBIDDEN); use Apache::Cookie (); require('lib/helper.pl'); print Content-type: text/html\n\n; my $rand=genrand(20); print htmlbody$rand/body/html; helper.pl: sub genrand { my [EMAIL PROTECTED]; my $r; my @chars=('a'..'z','A'..'Z','0'..'9','_'); $r.=$chars[rand @chars] for(1..$l); return $r; } 1; When running test.pl, I get the following in my logs: Use of uninitialized value in foreach loop entry at lib/helper.pl line 4. Use of uninitialized value in foreach loop entry at lib/helper.pl line 4. Use of uninitialized value in concatenation (.) or string at /export/home/newsite/perl/test.pl line 10. So, what I can gather is that the value '20' isn't being received by the genrand subroutine, and it's getting something else instead. What exactly, I'm not sure but I know it has to do SOMETHING with Apache::Registry. To test things out, I went ahead and changed the genrand sub to spit out what it was receiving: sub genrand { my @[EMAIL PROTECTED]; my $r; $r.=$_br /\n for @blah; return $r; } What did it return? 20br / Now how the hell that happened, I don't know, but it STILL isn't getting that value passed. Any idea what apache's sending here and why it doesn't want to grab the variable? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Test For Dupplicate elements in an array
I need to test if an array holds duplicates, and if so do something. What is the slickest way of doing this ? Neill __ Broadband from an unbeatable £15.99! http://www.tiscali.co.uk/products/broadband/home.html?code=SM-NL-11AM -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Learning how to map a drive in Perl
I am looking at how I could connect to share and map a local drive in a perl script. I have cut and pasted the code from the man page from Lanman to understand what is happening. When I run the code below I get the following error Undefined subroutine main::USE_IPC called at map.pl line 5. Am I missing something ? Cheers Neill #!/usr/bin/perl use strict; use warnings; # use win32::Lanman; if(!Win32::Lanman::NetUseAdd({remote = server\\ipc\$, password = pass, username = user, domain = NT, asg_type = USE_IPC})) { print Sorry, something went wrong; error: ; # get the error code print Win32::Lanman::GetLastError(); exit 1; } #connects drive h: to \\testserver\testshare. if(!Win32::Lanman::NetUseAdd({remote = testserver\\testshare, local = h:, asg_type = USE_DISKDEV})) { print Sorry, something went wrong; error: ; # get the error code print Win32::Lanman::GetLastError(); exit 1; } Undefined subroutine main::USE_IPC called at map.pl line 5. IMPORTANT NOTICE This email (including any attachments) is meant only for the intended recipient. It may also contain confidential and privileged information. If you are not the intended recipient, any reliance on, use, disclosure, distribution or copying of this email or attachments is strictly prohibited. Please notify the sender immediately by email if you have received this message by mistake and delete the email and all attachments. Any views or opinions in this email are solely those of the author and do not necessarily represent those of Trinity Mirror PLC or its associated group companies (hereinafter referred to as TM Group). TM Group accept no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. Although every reasonable effort is made to keep its network free from viruses, TM Group accept no liability for any virus transmitted by this email or any attachments and the recipient should use up-to-date virus checking software. Email to or from this address may be subject to interception or monitoring for operational reasons or for lawful business practices. Trinity Mirror PLC is the parent company of the Trinity Mirror group of companies and is registered in England No 82548, with its address at One Canada Square, Canary Wharf, London E14 5AP. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Modifying STDIN
I actually can't do it that way, this is a part of a custom perl module that someone wrote, and those are just 2 lines from the module. On Mar 15, 2004, at 11:01 PM, Randy W. Sims wrote: On 03/16/04 00:06, James Taylor wrote: I'm modifying a script someone wrote that basically reads a file file into STDIN, and I was curious if there was anyway of modifying the stdin value without having to first open the file, modify it, close the file, and then open it into stdin. I think what you want is a traditional filter: === myfilter.pl === #!/usr/bin/perl use strict; use warnings; while (my $line = ) { chomp($line); $line =~ s/^/sprintf(%3s , $.)/e; print $line\n; } __END__ piping it to its own STDIN produces cat myfilter.pl | perl myfilter.pl 1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 while (my $line = ) { 7 chomp($line); 8 $line =~ s/^/sprintf(%3s , $.)/e; 9 print $line\n; 10 } See perldoc perlopentut, section Filters Regards, Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Modifying STDIN
I'm modifying a script someone wrote that basically reads a file file into STDIN, and I was curious if there was anyway of modifying the stdin value without having to first open the file, modify it, close the file, and then open it into stdin. Basically, looks like: open(STDIN,$filename) || die whatever\n; close(STDOUT); Well, I need to to a search/replace on STDIN, something like: open(STDIN,$filename) || die blah\n; STDIN =~ s/one/two/g; close(STDOUT); Line 2 isn't intended to work, it's just there to show you what i'm trying to accomplish. Thanks for your help! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
WWW::Mechanize through a proxy?
Hi all, Has anyone here sucessfully used WWW::Mechanize through a proxy server? This always fails for me. On Win32. Cheers, James #! /usr/bin/perl use strict; use WWW::Mechanize; my $a = WWW::Mechanize-new(); my $url = 'http://www.yahoo.com/'; $a-env_proxy() ; # This should work as far as I can tell! # That is to say, I have the correct # environment variables set up: # HTTP_proxy_passsecret # HTTP_proxy_userjamestaylor # HTTP_proxy http://10.0.0.1:80/ $a-get($url); my $content = $a-content(); print $content \n; -- The information contained in this e-mail is intended for the recipient or entity to whom it is addressed. It may contain confidential information that is exempt from disclosure by law and if you are not the intended recipient, you must not copy, distribute or take any act in reliance on it. If you have received this e-mail in error, please notify the sender immediately and delete from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Image::Magick Montage usage
Hi there, I have 189 gif images at 200x200 and I want to combine them in a 3x61 arrangement, ending up with a 600x12200 gif. Firstly is this just crazy talk? I realise this is a large image, but I've dealt with larger in the past. Secondly, what the hell am I doing wrong!? My code is below. I have the image filenames in a file. The first bit of the code grabs the filenames (all 8 characters long) and sticks them into @images. After this, it all gets a bit hazy. When I run the code, it gets as far as Montaging...\n but then hangs (12 hours and counting) whle the CPU usage goes through the roof. I used the code from here to create mine: http://savage.net.au/ImageMagick.html#ImageMagick_Hax_1_13 I would appreciate any pointers to where I'm going wrong, and also pointers to any documentation that might help me understand this better. Cheers, James ### #!/usr/bin/perl use warnings; use strict; use Image::Magick; my @images; my $input_file = '/home/james/montage_images/amalgam.txt'; my $output_file = 'home/james/montage_images/montage.gif'; my $image_dir = '/home/james/montage_images/'; my $result; open IN, $input_file or die Couldn't read $input_file: $!\n; while (IN) { chomp; if (/([A-Z0-9]{8}\.gif)/){ push (@images, $1); } } my($image) = Image::Magick - new(); my($stack) = Image::Magick - new(); my $counter = 1; for (1..63) { # I know I don't need these for now, for (1..3) { # I'm going to need them later. my $tile = pop @images; $result = $image - Read($image_dir.$tile); warn $result if $result; push (@$stack, $image); print $tile added to array ($counter)\n; $counter++; } } print Montaging...\n; my($final) = $stack - Montage ( tile= '3x63', geometry= '200x200' ); $result = $final - Write($output_file); warn $result if $result; print Success. Wrote $output_file. \n; The information contained in this e-mail is intended for the recipient or entity to whom it is addressed. It may contain confidential information that is exempt from disclosure by law and if you are not the intended recipient, you must not copy, distribute or take any act in reliance on it. If you have received this e-mail in error, please notify the sender immediately and delete from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Image::Magick Montage usage
Wiggins d Anconia wrote: HTH, Indeed, you're right of course. I have a hunch that this is more than a resource issue, but of course I should try using less images first to eliminate it as a possibility. I'll try later and let you know how I get on. I was kind of hoping someone would spot an obvious mistake in my code - no such luck :-) I did notice one mistake: my $output_file = 'home/james/montage_images/montage.gif'; # no leading '/' Where would this end up, or would it just throw an error? Or just work? I doubt it has anything to do with my problem anyway, just curious. -- james The information contained in this e-mail is intended for the recipient or entity to whom it is addressed. It may contain confidential information that is exempt from disclosure by law and if you are not the intended recipient, you must not copy, distribute or take any act in reliance on it. If you have received this e-mail in error, please notify the sender immediately and delete from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Image::Magick Montage usage
Wiggins d Anconia wrote: I also notice that you catch the return result of 'Write' and then warn if it is positive, but 'Write' returns the number of images written, so it should be positive. I suspect this is because it is just test code, but you will likely need to correct that before release. You're right about this one. The example code in im-hax-montage-1.pl (see earlier url) uses this code and I just duplicated the error. One more suggestion I had in light of these findings, would be to add a print statement after the Montage before the Write so we can confirm that the script is in fact hanging at the Montage rather than at the Write. Another good idea, which I shall try tonight along with the others, or this afternoon if I can get Image::Magick installed on my work PC. That's another story! Thanks for the suggestions, -- james The information contained in this e-mail is intended for the recipient or entity to whom it is addressed. It may contain confidential information that is exempt from disclosure by law and if you are not the intended recipient, you must not copy, distribute or take any act in reliance on it. If you have received this e-mail in error, please notify the sender immediately and delete from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Image::Magick Montage usage
Taylor James wrote: Another good idea, which I shall try tonight along with the others, or this afternoon if I can get Image::Magick installed on my work PC. That's another story! Done that, and revised the code as discussed earlier and it still seems to be hangign at the same point (just after Montaging...\n;) despite now trying to montage a 3x3 square. Any ideas welcomed. Revised code (now on Win32): # #!/usr/bin/perl use warnings; use strict; use Image::Magick; my @images; my $input_file = 'H:\amalgam.txt'; my $output_file = 'H:\test.gif'; my $image_dir = 'E:\tiles\\'; my $result; open IN, $input_file or die Couldn't read $input_file: $!\n; while (IN) { chomp; if (/([A-Z0-9]{8}\.gif)/){ push (@images, $1); } else { print Couldn't match a line in $input_file - $_; } } my($image) = Image::Magick - new(); my($stack) = Image::Magick - new(); my $counter = 1; for (1..3) { for (1..3) { my $tile = pop @images; $result = $image - Read($image_dir.$tile); warn $result if $result; push (@$stack, $image); print $tile seen ($counter)\n; $counter++; } } print Montaging...\n; my($final) = $stack - Montage ( tile= '3x3', geometry= '200x200' ); print Montaged\n; $result = $final - Write($output_file); warn $result if $result; print Success. Wrote $output_file. \n; The information contained in this e-mail is intended for the recipient or entity to whom it is addressed. It may contain confidential information that is exempt from disclosure by law and if you are not the intended recipient, you must not copy, distribute or take any act in reliance on it. If you have received this e-mail in error, please notify the sender immediately and delete from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
sorting hash list for CGI Form
Hello all, When I populate this hash (%SrcIDs) from SELECT id, desc, from myTable order by desc it doesn't order by the description field desc. (printing each row in the while loop show that the SQL is sorted) while( my($id, $desc) = $sth-fetchrow ) { $SrcIDs{$id} = $desc; } $sth-finish; my @Sources = keys(%SrcIDs); # Begin HTML print header('text/html'); print start_html('Select Source Mill Info Page'), h3('Select Source Mill'), startform('GET','srcmill.cgi','','gosrcmill','_blank'), Source Mill: nbsp, popup_menu('millid', [EMAIL PROTECTED], '', \%SrcIDs),p, ... So, you see I want to link @Sources with the keys of %SrcIDs, but what I want is to sort the hash alphabetically by the values of %SrcIDs. Please, how can I do that? Cheers. Scott. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Automatically write in uppercase
James Edward Gray II wrote: On Feb 29, 2004, at 6:30 AM, John wrote: That's a nice method but i would prefer to activate the CAPS-LOCK and user write in capitals in my text entry widget I would prefer you didn't. ;) The keyboard takes commands from me, not the computer. If a program started monkeying with my control of such a device, it would find my trash can, mighty quick. Incidentally MS Word does this. If you try to type a sentence, say: pLEASE DON'T TURN OFF MY CAPS LOCK KEY, i WANT IT LIKE THIS. with the caps lock key on, it automatically turns off the caps lock key and converts it to: Please don't...etc. It's really annoying on occasions, occasionally useful but in general I think it's a bad idea to 'monkey' with stuff like this. -- james The information contained in this e-mail is intended for the recipient or entity to whom it is addressed. It may contain confidential information that is exempt from disclosure by law and if you are not the intended recipient, you must not copy, distribute or take any act in reliance on it. If you have received this e-mail in error, please notify the sender immediately and delete from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
IPTC Captions
I need to manipulate the IPTC captions within a jpeg using Perl. Is their a module or an easy way of doing this in Perl ? Thanks Neill IMPORTANT NOTICE This email (including any attachments) is meant only for the intended recipient. It may also contain confidential and privileged information. If you are not the intended recipient, any reliance on, use, disclosure, distribution or copying of this email or attachments is strictly prohibited. Please notify the sender immediately by email if you have received this message by mistake and delete the email and all attachments. Any views or opinions in this email are solely those of the author and do not necessarily represent those of Trinity Mirror PLC or its associated group companies (hereinafter referred to as TM Group). TM Group accept no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. Although every reasonable effort is made to keep its network free from viruses, TM Group accept no liability for any virus transmitted by this email or any attachments and the recipient should use up-to-date virus checking software. Email to or from this address may be subject to interception or monitoring for operational reasons or for lawful business practices. Trinity Mirror PLC is the parent company of the Trinity Mirror group of companies and is registered in England No 82548, with its address at One Canada Square, Canary Wharf, London E14 5AP. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Covert Date to week number
Is their a way in PERL to covert a date to a week number Cheers Neill IMPORTANT NOTICE This email (including any attachments) is meant only for the intended recipient. It may also contain confidential and privileged information. If you are not the intended recipient, any reliance on, use, disclosure, distribution or copying of this email or attachments is strictly prohibited. Please notify the sender immediately by email if you have received this message by mistake and delete the email and all attachments. Any views or opinions in this email are solely those of the author and do not necessarily represent those of Trinity Mirror PLC or its associated group companies (hereinafter referred to as TM Group). TM Group accept no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. Although every reasonable effort is made to keep its network free from viruses, TM Group accept no liability for any virus transmitted by this email or any attachments and the recipient should use up-to-date virus checking software. Email to or from this address may be subject to interception or monitoring for operational reasons or for lawful business practices. Trinity Mirror PLC is the parent company of the Trinity Mirror group of companies and is registered in England No 82548, with its address at One Canada Square, Canary Wharf, London E14 5AP. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Delete multiple blank lines
Hi all, I could use some help with an expression or code to delete multiple blank lines and replace it with only one blank line... I know how this can be done in sed, but am not sure how to do it in perl... Thanks, Taylor -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Reg Ex help...
Thanks to everyone's help so far, I think I am getting better with Regular expressions... Need a little help on this one This is sample data, not accurate.. 1. St Joes (15-0) .875 (2-0) 2. Kentucky (12-2) .850 (1-0) 10. Kansas (12-2) .778 (1-1) 198 Crappy School (2-9) .233 and on and on.. I am trying to match only the schools name, and I have the following reg ex if (/^\d\.\s([A-Z]\D+)/) (This says match starting at the beginning of the line a digit followed by a period followed by a space followed by a Capital letter followed by any amount of nondigit characters) This matches the schools that are 1 through 9, but not 10-200. What is the best way to say match 1, 2 or 3 numbers? With a plus after the \d or do can I tell it to specifically match only 1 2 or 3 digits? Also, this is returning the first parentheses mark (. How do I tell it not to match that... I know I have to replace \D+ but what with? What is the metacharacter if there is one to just match a letter? Thanks, Taylor
RE: Data File, turn fields on mulitple lines into records on one li ne.. .
Thanks Ron, will give that a try.. One more for everyone... In my perl script, I did a quick cheat by using the systems grep command... I tried: `/usr/bin/grep -v BLAH | /usr/bin/grep -v COW | /usr/bin/grep -v STUFF file1file2`; And this doesn't work. Sometimes it will get rid of STUFF. It seems to only act on the last grep I use. I tried escaping the pipes, but that didn't work. Any ideas? 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: Data File, turn fields on mulitple lines into records on one li ne.. .
Okay, I redid it so it looks like this... `grep -v STUFF:STUFF file1 file2`; (I am looking for the string STUFF:STUFF and that didn't work... but it works via command line... Any ideas? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Data File, turn fields on mulitple lines into records on one li ne.. .
So you recommend using regular expressions instead of grep..? Care to provide an example in this case? -Original Message- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Friday, January 16, 2004 3:16 PM To: Lewick, Taylor; [EMAIL PROTECTED] Subject: RE: Data File, turn fields on mulitple lines into records on one li ne.. . Okay, I redid it so it looks like this... `grep -v STUFF:STUFF file1 file2`; (I am looking for the string STUFF:STUFF and that didn't work... but it works via command line... Any ideas? What is the real goal? Aka why are you shelling out to grep in the first place? As a side note you should be using full paths for grep, file1, file2, and you should be checking the return code of the command. Also it seems silly to use backticks if you are piping STDOUT to a file. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Data File, turn fields on mulitple lines into records on one li ne.. .
Okay, will do... One more, what about a sed command that deletes the first 3 spaces of each line... i.e., how would I do this in perl... sed 's/^ //' file1 file2 -Original Message- From: John W. Krahn [mailto:[EMAIL PROTECTED] Sent: Friday, January 16, 2004 3:24 PM To: [EMAIL PROTECTED] Subject: Re: Data File, turn fields on mulitple lines into records on one li ne.. . Taylor Lewick wrote: Okay, I redid it so it looks like this... `grep -v STUFF:STUFF file1 file2`; Is that what the ACTUAL line looks like? (I am looking for the string STUFF:STUFF and that didn't work... but it works via command line... Any ideas? Use perl to do it: open my $in, '', 'file1' or die Cannot open file1: $!; open my $out, '', 'file2' or die Cannot open file2: $!; while ( $in ) { next if /STUFF:STUFF/; print $out; } close $out; close $in; 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
perl grep..
John thank you for the example, one question about the example code... It isn't printing anything to my out file, although it does create it. On the print $out line, I don't need print $out $_\n; do I? Or, the expression /STUFF:STUFF/ What if my line looks like this.. 1 17 7 PM ET:Name:Name:STUFF:STUFF:STUFF Would the example you provided still match this line? I suspect this is the issue but am not sure. Would I need something like /.*STUFF:STUFF/ ? Thanks again, Taylor -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Data File, turn fields on mulitple lines into records on one line.. .
Hi all. Need some help. I have a data file that looks like this... Date Team Name 1 Team Name 2 Field1 Field2 FieldX Date Team Name 3 Team Name 4 Field 1 FieldX and so on... Each entry will have the data and team 1 and 2's name. But the number of fields will be variable... I would really like to turn this file into something like this... Date:Team Name 1:Team Name 2:Field1:Field2:FieldX Date:Team Name 3:Team Name 4:Field1:Field2:FieldX I'm not really sure where to get started. I could load all of the values into an array (The file won't be too big) and print them back out all separated by colons, then run a regular expression to insert a blank line when it detects the date pattern. I don't know how to go about loading the data into an array or hash, and then printing it out formatted on one line until the next date is detected. Am not sure how to combine those steps. Any help is greatly appreciated... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Clearing Arrays
I thought this newsgroup was for beginners! Ramprasad A Padmanabhan To: [EMAIL PROTECTED], [EMAIL PROTECTED] [EMAIL PROTECTED]cc: e.co.in Subject: Re: Clearing Arrays 13/01/2004 10:37 Support wrote: Hi All I have this little memory blockage again. If I 'push' data from a database into an array to look/manipulate the data and then using the same array name, 'push' data into the array from another database, the data from the second DB file is added to the data of the first. How can I clear the first lot of data and start a fresh with an empty array ?? Cheers Colin (from the future) I dont think you should use this newsgroup inlieu of a perl book. Please considering buying a good perl book and read about 'arrays' , 'my' etc. Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response IMPORTANT NOTICE This email (including any attachments) is meant only for the intended recipient. It may also contain confidential and privileged information. If you are not the intended recipient, any reliance on, use, disclosure, distribution or copying of this email or attachments is strictly prohibited. Please notify the sender immediately by email if you have received this message by mistake and delete the email and all attachments. Any views or opinions in this email are solely those of the author and do not necessarily represent those of Trinity Mirror PLC or its associated group companies (hereinafter referred to as TM Group). TM Group accept no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. Although every reasonable effort is made to keep its network free from viruses, TM Group accept no liability for any virus transmitted by this email or any attachments and the recipient should use up-to-date virus checking software. Email to or from this address may be subject to interception or monitoring for operational reasons or for lawful business practices. Trinity Mirror PLC is the parent company of the Trinity Mirror group of companies and is registered in England No 82548, with its address at One Canada Square, Canary Wharf, London E14 5AP. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Image Magick
Hello all, I am trying to use Image::Magick to resize a JPEG. This routine works to display the full size image from a blob in my Firebird database: while ( my ($PixData ) = $sth-fetchrow ) { print header('image/jpeg'); print $PixData; } But when I add the Image::Magick stuff: while ( my (@PixData) = $sth-fetchrow) { my $PixDisp=Image::Magick-new(magick='jpg'); $PixDisp-BlobToImage(@PixData); $PixDisp-Resize(geometry='160x120'); print header('image/jpeg'); print $PixDisp; } I get this: Image::Magick=ARRAY(0x82fdee8) instead of an image. Can anyone see my obvious mistake? Cheers. Scott. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Image Magick
At 10:28 AM 01/09/2004, Wiggins d Anconia wrote: Hello all, I am trying to use Image::Magick to resize a JPEG. This routine works to display the full size image from a blob in my Firebird database: while ( my ($PixData ) = $sth-fetchrow ) { print header('image/jpeg'); print $PixData; } But when I add the Image::Magick stuff: while ( my (@PixData) = $sth-fetchrow) { my $PixDisp=Image::Magick-new(magick='jpg'); $PixDisp-BlobToImage(@PixData); $PixDisp-Resize(geometry='160x120'); print header('image/jpeg'); print $PixDisp; } I get this: Image::Magick=ARRAY(0x82fdee8) instead of an image. Can anyone see my obvious mistake? You are getting this because $PixDisp holds an Image::Magick object which can't be stringified as you desire. D'oh! I C You need to (it appears) call the 'Write' method of the object to have it converted to image data. OK http://www.ImageMagick.org/www/perl.html Check the above for an example of how to print an image to a filehandle, in your case you want the default STDOUT I've been all over that page, but I'm still stuck at how to do what I want. I don't want Apache writing files, I just want to display the new image dynamically. Is that even possible? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Image Magick
At 11:02 AM 01/09/2004, Scott Taylor wrote: At 10:28 AM 01/09/2004, Wiggins d Anconia wrote: http://www.ImageMagick.org/www/perl.html Check the above for an example of how to print an image to a filehandle, in your case you want the default STDOUT I've been all over that page, but I'm still stuck at how to do what I want. I don't want Apache writing files, I just want to display the new image dynamically. Is that even possible? Ah, silly me. Thanks Wiggins. while ( my (@PixData) = $sth-fetchrow) { my $PixDisp=Image::Magick-new(magick='jpg'); $PixDisp-BlobToImage(@PixData); $PixDisp-Resize(geometry='160x120'); print header('image/jpeg'); binmode STDOUT; $PixDisp-Write('jpg:-'); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
regex multiple lines
I'm trying to parse a bit out of an HTML file, where the formatting could change daily as far as spaces/newlines go. Say for example I have something like this: $str=EOF; html body pHello this is juts an example/p p!---begin---a href=nowhere.comblahahahaha/a /pa href= http://www.somewhere.com; HELLO/a /p!---end---Hello world/body /html EOF $repl=Replacement Text; $str =~ s/\!---begin---\.+?\!---end---\/$repl/im; Well, that doesn't work. Any suggestions on this one? I thought /m was supposed to make regex's span multiple lines, which seems to be the problem here, as : print good\n if $str =~ /!---begin---.+?!---end---/mi comes up with nothing, though I am able to match them on their own. 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: regex multiple lines
ok, well I ended up dropping the regex and splitting the strings and re-building them after being inspired by another thread. so, my $str=text !---begin--- text to be replac ed!---end---; my $repl=replacement text; my ($a,$b)=split('!---begin---',$str); my ($c,$d)=split('!---end---',$b); $str=$a.$repl.$d; I'd still like to know if you can do this via regex however. On Jan 2, 2004, at 5:38 PM, James Taylor wrote: I'm trying to parse a bit out of an HTML file, where the formatting could change daily as far as spaces/newlines go. Say for example I have something like this: $str=EOF; html body pHello this is juts an example/p p!---begin---a href=nowhere.comblahahahaha/a /pa href= http://www.somewhere.com; HELLO/a /p!---end---Hello world/body /html EOF $repl=Replacement Text; $str =~ s/\!---begin---\.+?\!---end---\/$repl/im; Well, that doesn't work. Any suggestions on this one? I thought /m was supposed to make regex's span multiple lines, which seems to be the problem here, as : print good\n if $str =~ /!---begin---.+?!---end---/mi comes up with nothing, though I am able to match them on their own. Thanks -- 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