[28775] in Perl-Users-Digest
Perl-Users Digest, Issue: 19 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 12 18:05:52 2007
Date: Fri, 12 Jan 2007 15:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 12 Jan 2007 Volume: 11 Number: 19
Today's topics:
Re: alarm() under W2003 <purlgurl@purlgurl.net>
Re: alarm() under W2003 <rmay@popeslane.clara.co.uk>
Check for Print Queue at Login snippet murraymn@gmail.com
Check for Print Queue? murraymn@gmail.com
Re: Check for Print Queue? <spamtrap@dot-app.org>
Re: Check for Print Queue? murraymn@gmail.com
Extraction Fields from a file <doni.sekar@gmail.com>
Re: Extraction Fields from a file <john@castleamber.com>
Re: Extraction Fields from a file usenet@DavidFilmer.com
Re: Extraction Fields from a file <cgrady357@gmail.com>
Re: Extraction Fields from a file <someone@example.com>
Re: Extraction Fields from a file <DJStunks@gmail.com>
Re: Extraction Fields from a file <someone@example.com>
Re: Extraction Fields from a file usenet@DavidFilmer.com
Re: Extraction Fields from a file <doni.sekar@gmail.com>
Re: if (! mkdir $dir) <kst-u@mib.org>
Space separate combined words Andreas.Burman@gmail.com
Re: Space separate combined words <purlgurl@purlgurl.net>
Re: Space separate combined words <blgl@stacken.kth.se>
Re: Unix commands <wblock@wonkity.com>
Re: Unix commands usenet@DavidFilmer.com
Re: WWW:Mechanize single quotes around URL causes probl <randall.belk@knology.net>
Re: WWW:Mechanize single quotes around URL causes probl <spamtrap@dot-app.org>
Re: WWW:Mechanize single quotes around URL causes probl <glex_no-spam@qwest-spam-no.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 12 Jan 2007 11:51:14 -0800
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: alarm() under W2003
Message-Id: <45A7E6B2.8010909@purlgurl.net>
Ferry Bolhar wrote:
> eval {
> local $SIG{ALRM} = sub {die "\nTimeout!\n"};
> alarm 3;
> print 'Your input: ';
> my $input = <STDIN>;
> alarm 0;
> };
> die "$@\n" if $@;
> However, on Windows Server 2003, the readline operation
> hangs forever, the alarm signal handler gets never executed!
Your alarm signal handler is executed, be sure on this. However,
there is no hook into a command line prompt for standard input.
An alarm is triggered but Perl does nothing with this, specific
to a command line prompt for standard input; perl core fails
with no error message returned.
Alarm is only partially implemented in Perl 5.8 versions
running on Windows machines. Because of incomplete programming
for Perl ports to Win32, alarm cannot hook a command line.
To work around this lack of effective programming by Perl porters,
use a DOS based select command, specifically for timing out a
command line standard input prompt.
#!perl
print "
Enter R To Run Program
Enter Q To Quit
You Have Five Seconds To Respond: ";
@Array = `echo.|select.bat`;
if ($Array[1] == 1)
{ print "Running Program"; }
else
{ print "Exiting"; }
--
select.bat
@ECHO OFF
CHOICE /C:RQ /T:Q,05
IF ERRORLEVEL 2 GOTO TWO
IF ERRORLEVEL 1 GOTO ONE
:TWO
ECHO 2
GOTO END
:ONE
ECHO 1
GOTO END
:END
--
You can use $Array[1] == 2 should you want to
perform a different task upon Quit or time out.
T:Q is default to Quit on timeout of (05) five seconds.
Purl Gurl
------------------------------
Date: Fri, 12 Jan 2007 20:55:19 +0000
From: Robert May <rmay@popeslane.clara.co.uk>
Subject: Re: alarm() under W2003
Message-Id: <CqWdnQcL8uEnaDrYnZ2dnUVZ8q-mnZ2d@pipex.net>
Ferry Bolhar wrote:
> Hi,
>
> I have this code which works well under UNIX (Linux):
>
> eval {
> local $SIG{ALRM} = sub {die "\nTimeout!\n"};
> alarm 3;
> print 'Your input: ';
> my $input = <STDIN>;
> alarm 0;
> };
> die "$@\n" if $@;
>
> However, on Windows Server 2003, the readline operation
> hangs forever, the alarm signal handler gets never executed!
>
> Does someone know what to change here to make this code
> running under W2003?
What version of perl are you running. There was a fix made in the 5.9
development branch, that I don't think has been merged back into the 5.8
maint branch yet. ActiveState Perl 5.8.8 (build 819, and possibly build
817) do have this patch applied though (see the perl -V below, the 2
lines marked with **).
Regards,
Rob.
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=MSWin32, osvers=5.0, archname=MSWin32-x86-multi-thread
uname=''
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32
-D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DNO_HASH_SEED
-DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
-DUSE_PERLIO -DPERL_MSVCRT_READFIX',
optimize='-MD -Zi -DNDEBUG -O1',
cppflags='-DWIN32'
ccversion='12.00.8804', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
ivtype='long', ivsize=4, nvtype='double', nvsize=8,
Off_t='__int64', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf
-libpath:"C:\Perl\Perl588\lib\CORE" -machine:x86'
libpth=\lib
libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib
odbc32.lib odbccp32.lib msvcrt.lib
perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib msvcrt.lib
libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug
-opt:ref,icf -libpath:"C:\Perl\Perl588\lib\CORE" -machine:x86'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
PERL_IMPLICIT_SYS PERL_MALLOC_WRAP
PL_OP_SLAB_ALLOC USE_ITHREADS USE_LARGE_FILES
USE_PERLIO USE_SITECUSTOMIZE
Locally applied patches:
ActivePerl Build 819 [267479]
Iin_load_module moved for compatibility with build 806
PerlEx support in CGI::Carp
Less verbose ExtUtils::Install and Pod::Find
Patch for CAN-2005-0448 from Debian with modifications
Rearrange @INC so that 'site' is searched before 'perl'
Partly reverted 24733 to preserve binary compatibility
28671 Define PERL_NO_DEV_RANDOM on Windows
28376 Add error checks after execing PL_cshname or PL_sh_path
28305 Pod::Html should not convert "foo" into ``foo''
27736 Make perl_fini() run with Sun WorkShop compiler
27619 Bug in Term::ReadKey being triggered by a bug in Term::ReadLine
27549 Move DynaLoader.o into libperl.so
27528 win32_pclose() error exit doesn't unlock mutex
** 27527 win32_async_check() can loop indefinitely
27515 ignore directories when searching @INC
27359 Fix -d:Foo=bar syntax
27210 Fix quote typo in c2ph
27203 Allow compiling swigged C++ code
27200 Make stat() on Windows handle trailing slashes correctly
27194 Get perl_fini() running on HP-UX again
27133 Initialise lastparen in the regexp structure
27034 Avoid "Prototype mismatch" warnings with autouse
26970 Make Passive mode the default for Net::FTP
26921 Avoid getprotobyname/number calls in IO::Socket::INET
26897,26903 Make common IPPROTO_* constants always available
26670 Make '-s' on the shebang line parse -foo=bar switches
26536 INSTALLSCRIPT versus INSTALLDIRS
** 26379 Fix alarm() for Windows 2003
26087 Storable 0.1 compatibility
25861 IO::File performace issue
25084 long groups entry could cause memory exhaustion
24699 ICMP_UNREACHABLE handling in Net::Ping
Built under MSWin32
Compiled at Aug 29 2006 12:42:41
@INC:
C:/Perl/Perl588/site/lib
C:/Perl/Perl588/lib
.
------------------------------
Date: 12 Jan 2007 12:10:09 -0800
From: murraymn@gmail.com
Subject: Check for Print Queue at Login snippet
Message-Id: <1168632607.067568.91330@11g2000cwr.googlegroups.com>
Looking for suggestions/examples of a simple perl script to check the
existence of a CUPS print queue.
That's all it needs to do and no more with the queue. Yeah, I could
search printers.conf, and may if I don't find anything a little more
elegant and efficient.
Thanks,
Mike
------------------------------
Date: 12 Jan 2007 12:13:22 -0800
From: murraymn@gmail.com
Subject: Check for Print Queue?
Message-Id: <1168632802.403995.18020@v45g2000cwv.googlegroups.com>
Looking for suggestions/examples of a simple perl script to check the
existence of a CUPS print queue.
That's all it needs to do and no more with the queue. Yeah, I could
search printers.conf, and may if I don't find anything a little more
elegant and efficient.
Thanks,
Mike
------------------------------
Date: Fri, 12 Jan 2007 16:08:21 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Check for Print Queue?
Message-Id: <m2tzywar7e.fsf@Sherm-Pendleys-Computer.local>
murraymn@gmail.com writes:
> Looking for suggestions/examples of a simple perl script to check the
> existence of a CUPS print queue.
>
> That's all it needs to do and no more with the queue. Yeah, I could
> search printers.conf, and may if I don't find anything a little more
> elegant and efficient.
We heard you the first time.
Did you try searching at <http://search.cpan.org> for CUPS?
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: 12 Jan 2007 14:06:18 -0800
From: murraymn@gmail.com
Subject: Re: Check for Print Queue?
Message-Id: <1168639578.329876.301840@q2g2000cwa.googlegroups.com>
The first post was slightly inaccurate.
Unfortunately I searched for print and queue.
Thanks
Sherm Pendley wrote:
> murraymn@gmail.com writes:
>
> > Looking for suggestions/examples of a simple perl script to check the
> > existence of a CUPS print queue.
> >
> > That's all it needs to do and no more with the queue. Yeah, I could
> > search printers.conf, and may if I don't find anything a little more
> > elegant and efficient.
>
> We heard you the first time.
>
> Did you try searching at <http://search.cpan.org> for CUPS?
>
> sherm--
>
> --
> Web Hosting by West Virginians, for West Virginians: http://wv-www.net
> Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: 12 Jan 2007 13:16:12 -0800
From: "doni" <doni.sekar@gmail.com>
Subject: Extraction Fields from a file
Message-Id: <1168636571.675661.50990@l53g2000cwa.googlegroups.com>
I wanted to extract the 3rd field from every 2nd and 3rd line after
spaces from a file. This is how the information is stored in the file.
00009c8 15 106
00009c4 15 114
00009c8 15 119
00009c8 15 108
00009c4 15 114
00009c8 15 119
00009c8 15 109
00009c4 15 114
00009c8 15 119
00009c8 15 109
00009c4 15 114
00009c8 15 119
00009c8 15 106
00009c4 15 114
00009c8 15 119
00009c8 15 106
00009c4 15 114
00009c8 15 119
00009c8 15 106
00009c4 15 114
00009c8 15 119
00009c8 15 107
00009c4 15 114
00009c8 15 119
Here is the script that I have written to approach the problem. The
script is not a complete one.
#! /usr/bin/perl -w
$ex_data = "extract_data";
# Open the rfping data file #
open(DAT,$ex_data) || die("Cannot Open File");
foreach my $line(<DAT>)
{
chomp $line;
my @data = split(/\s+/,$line);
my @rssi_09c8_09c4;
if ($data[0] eq "00009c4")
{
@rssi_09c8_09c4 = $data[2];
print "The rssi value is: @rssi_09c8_09c4\n";
}
else
{
}
}
close(DAT);
The other problem is when I run this script, I am getting "Use of
uninitialized value at ./rfping.pl line 13," warning message.
Can anyone let me know how should I proceed with this.
Thanks,
doni
------------------------------
Date: 12 Jan 2007 21:50:33 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Extraction Fields from a file
Message-Id: <Xns98B6A127D2863castleamber@130.133.1.4>
"doni" <doni.sekar@gmail.com> wrote:
> 00009c8 15 107
> 00009c4 15 114
> 00009c8 15 119
[..]
> #! /usr/bin/perl -w
Don't use -w, use:
use strict;
use warnings;
> $ex_data = "extract_data";
my $ex_data = ....
>
> # Open the rfping data file #
> open(DAT,$ex_data) || die("Cannot Open File");
open my $fh, $ex_data or die "Can't open '$ex_data' for reading: $!";
learn why I write it like this, especially the die part.
> foreach my $line(<DAT>)
> {
while ( my $line = <$fh> ) {
> }
> close(DAT);
close $fh or die "Can't close '$ex_data' after reading: $!";
> The other problem is when I run this script, I am getting "Use of
> uninitialized value at ./rfping.pl line 13," warning message.
> Can anyone let me know how should I proceed with this.
Yup, always wonderful if you mark line 13. I am not going to count for
you.
Probably caused by empty lines.
while ( my $line = <$fh> ) {
my ( $rssi ) = $line =~ /^[0-9a-f]{7} /;
defined $rssi or next;
$rssi eq '00009c4' or next;
print "The rssi value is: $rrsi\n";
}
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: 12 Jan 2007 13:52:35 -0800
From: usenet@DavidFilmer.com
Subject: Re: Extraction Fields from a file
Message-Id: <1168638755.548944.261150@s34g2000cwa.googlegroups.com>
doni wrote:
> I wanted to extract the 3rd field from every 2nd and 3rd line after
> spaces from a file.
my $linecount;
while (<DATA>) {
$linecount = (/^\s*$/) ? 0 : $linecount + 1; #reset count if
empty
if ($linecount == 2 || $linecount == 3) {
print ( (split)[2] . "\n" ); #third field
}
}
--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)
------------------------------
Date: 12 Jan 2007 14:02:46 -0800
From: "Craig" <cgrady357@gmail.com>
Subject: Re: Extraction Fields from a file
Message-Id: <1168639364.839490.172190@m58g2000cwm.googlegroups.com>
doni wrote:
> #! /usr/bin/perl -w
>
> $ex_data = "extract_data";
>
> # Open the rfping data file #
> open(DAT,$ex_data) || die("Cannot Open File");
>
> foreach my $line(<DAT>)
> {
> chomp $line;
> my @data = split(/\s+/,$line);
> my @rssi_09c8_09c4;
> if ($data[0] eq "00009c4")
> {
> @rssi_09c8_09c4 = $data[2];
> print "The rssi value is: @rssi_09c8_09c4\n";
> }
> else
> {
>
> }
> }
> close(DAT);
#! /usr/bin/perl
use warnings;
use strict;
my $ex_data = "extract_data";
my $fh;
open($fh,$ex_data) or die("Can not open file $ex_data", $?, $!);
my @result;
my $match = "00009c4";
while(<$fh>)> {
next unless /^$match\s+\d+\s+(\d+)\s+/;
push @result, $1;
}
for(@result) { print $fh $_, "\n"; }
close($fh);
------------------------------
Date: Fri, 12 Jan 2007 22:14:31 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Extraction Fields from a file
Message-Id: <bLTph.131997$rv4.105796@edtnps90>
doni wrote:
> I wanted to extract the 3rd field from every 2nd and 3rd line after
> spaces from a file. This is how the information is stored in the file.
>
> 00009c8 15 106
> 00009c4 15 114
> 00009c8 15 119
>
> 00009c8 15 108
> 00009c4 15 114
> 00009c8 15 119
>
> 00009c8 15 109
> 00009c4 15 114
> 00009c8 15 119
>
> 00009c8 15 109
> 00009c4 15 114
> 00009c8 15 119
>
> 00009c8 15 106
> 00009c4 15 114
> 00009c8 15 119
>
> 00009c8 15 106
> 00009c4 15 114
> 00009c8 15 119
>
> 00009c8 15 106
> 00009c4 15 114
> 00009c8 15 119
>
> 00009c8 15 107
> 00009c4 15 114
> 00009c8 15 119
>
> Here is the script that I have written to approach the problem. The
> script is not a complete one.
>
> #! /usr/bin/perl -w
>
> $ex_data = "extract_data";
>
> # Open the rfping data file #
> open(DAT,$ex_data) || die("Cannot Open File");
>
> foreach my $line(<DAT>)
> {
> chomp $line;
> my @data = split(/\s+/,$line);
> my @rssi_09c8_09c4;
> if ($data[0] eq "00009c4")
> {
> @rssi_09c8_09c4 = $data[2];
> print "The rssi value is: @rssi_09c8_09c4\n";
> }
> else
> {
>
> }
> }
> close(DAT);
#!/usr/bin/perl
use warnings;
use strict;
my $ex_data = 'extract_data';
# Open the rfping data file #
open my $DAT, '<', $ex_data or die "Cannot Open '$ex_data' $!";
$/ = '';
my @rssi_09c8_09c4;
while ( <$DAT> ) {
push @rssi_09c8_09c4, ( /(\d+)$/gm )[ -2, -1 ];
}
close $DAT;
__END__
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
Date: 12 Jan 2007 14:14:59 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Extraction Fields from a file
Message-Id: <1168640099.544664.213900@11g2000cwr.googlegroups.com>
doni wrote:
> I wanted to extract the 3rd field from every 2nd and 3rd line after
> spaces from a file. This is how the information is stored in the file.
I'd go three dimensional, man.
#!/usr/bin/perl
use strict;
use warnings;
use English qw{ -no_match_vars };
$INPUT_RECORD_SEPARATOR = ''; #paragraph mode
my @data;
while ( my $record = <DATA> ) {
my @lines = split /\n/, $record;
$_ = [split] for @lines;
push @data, \@lines;
}
print "2nd & 3rd fields of the 2nd row of the 4th record: ";
for my $record ( 4 ) {
for my $row ( 2 ) {
for my $field ( 2,3 ) {
print $data[ $record-1 ][ $row-1 ][ $field-1 ];
print ' ';
}
}
}
print "\n";
__DATA__
00009c8 15 106
00009c4 15 114
00009c8 15 119
00009c8 15 108
00009c4 15 114
00009c8 15 119
00009c8 15 109
00009c4 15 114
00009c8 15 119
00009c8 15 109
00009c4 15 114
00009c8 15 119
00009c8 15 106
00009c4 15 114
00009c8 15 119
00009c8 15 106
00009c4 15 114
00009c8 15 119
00009c8 15 106
00009c4 15 114
00009c8 15 119
00009c8 15 107
00009c4 15 114
00009c8 15 119
-jp
------------------------------
Date: Fri, 12 Jan 2007 22:18:05 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Extraction Fields from a file
Message-Id: <xOTph.131999$rv4.44650@edtnps90>
Craig wrote:
>
> #! /usr/bin/perl
> use warnings;
> use strict;
>
> my $ex_data = "extract_data";
> my $fh;
>
> open($fh,$ex_data) or die("Can not open file $ex_data", $?, $!);
> my @result;
> my $match = "00009c4";
> while(<$fh>)> {
> next unless /^$match\s+\d+\s+(\d+)\s+/;
> push @result, $1;
> }
> for(@result) { print $fh $_, "\n"; }
You can't print to the $fh filehandle because it was opened readonly.
> close($fh);
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
Date: 12 Jan 2007 14:42:15 -0800
From: usenet@DavidFilmer.com
Subject: Re: Extraction Fields from a file
Message-Id: <1168641734.904430.316770@m58g2000cwm.googlegroups.com>
doni wrote:
> I wanted to extract the 3rd field from every 2nd and 3rd line after
> spaces from a file.
my $linecount;
while (<DATA>) {
$linecount = (/^\s*$/) ? 0 : $linecount + 1; #reset count if
empty
if ($linecount == 2 || $linecount == 3) {
print ( (split)[2] . "\n" ); #third field
}
}
--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)
------------------------------
Date: 12 Jan 2007 14:51:23 -0800
From: "doni" <doni.sekar@gmail.com>
Subject: Re: Extraction Fields from a file
Message-Id: <1168642282.737930.291020@v45g2000cwv.googlegroups.com>
thanks everyone for replying to my question.
I tried David's hint and it worked perfectly for me.
Thanks,
doni
use...@DavidFilmer.com wrote:
> doni wrote:
> > I wanted to extract the 3rd field from every 2nd and 3rd line after
> > spaces from a file.
>
> my $linecount;
> while (<DATA>) {
> $linecount = (/^\s*$/) ? 0 : $linecount + 1; #reset count if
> empty
> if ($linecount == 2 || $linecount == 3) {
> print ( (split)[2] . "\n" ); #third field
> }
> }
>
>
> --
> The best way to get a good answer is to ask a good question.
> David Filmer (http://DavidFilmer.com)
------------------------------
Date: Fri, 12 Jan 2007 14:31:50 -0800
From: Keith Thompson <kst-u@mib.org>
Subject: Re: if (! mkdir $dir)
Message-Id: <lnmz4nkhbd.fsf@nuthaus.mib.org>
"jl_post@hotmail.com" <jl_post@hotmail.com> writes:
> j...@yahoo.com wrote:
>>
>> if (! mkdir $dir)
>>
>> When I try to run this code no matter what I set $dir to it fails with:
>> Not enough arguments for mkdir at test.pl line 11, near "$dir ) "
>> Execution of test.pl aborted due to compilation errors.
>
>
> If you're using an older version of Perl, the mkdir() function may
> be expecting a MASK parameter. Type "perldoc -f mkdir" to see if this
> additional parameter is required (which I suspect is the case).
>
> If that's the case, try changing your line to:
>
> if (! mkdir $dir, 0777)
>
> and see if that works.
You might just go ahead and make that change anyway. In the latest
versions of Perl, the mask argument is optional and defaults to 0777;
supplying a value of 0777 should be harmless.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
------------------------------
Date: 12 Jan 2007 11:11:44 -0800
From: Andreas.Burman@gmail.com
Subject: Space separate combined words
Message-Id: <1168629103.574969.170330@11g2000cwr.googlegroups.com>
Hi
I have a file congaing a list of combined words i.e 'carequipment',
'fishfood', 'thelittlemermaid'. I need an idea on how to add a space
between each "real" word and save it as a new file. In the case when
the combined word can be split in more than one way I guess matching
the largest one would be fine.
The file I want to run this on is rather huge over 250000 combined
words so I would appreciate if the solution also is efficient...
/Andreas
------------------------------
Date: Fri, 12 Jan 2007 12:03:30 -0800
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: Space separate combined words
Message-Id: <45A7E992.3030504@purlgurl.net>
Andreas.Burman@gmail.com wrote:
> I have a file congaing a list of combined words i.e 'carequipment',
> 'fishfood', 'thelittlemermaid'. I need an idea on how to add a space
> between each "real" word and save it as a new file. In the case when
> the combined word can be split in more than one way I guess matching
> the largest one would be fine.
> The file I want to run this on is rather huge over 250000 combined
> words so I would appreciate if the solution also is efficient...
Yours is an elaborate technical joke, yes?
"reallyarthair"
Purl Gurl
------------------------------
Date: Fri, 12 Jan 2007 22:26:23 +0100
From: Bo Lindbergh <blgl@stacken.kth.se>
Subject: Re: Space separate combined words
Message-Id: <eo8udv$vka$1@news.su.se>
In article <1168629103.574969.170330@11g2000cwr.googlegroups.com>,
Andreas.Burman@gmail.com wrote:
> I have a file congaing a list of combined words i.e 'carequipment',
> 'fishfood', 'thelittlemermaid'. I need an idea on how to add a space
> between each "real" word and save it as a new file.
Trying to correct some Swenglish, eh? :-)
It sounds like a trie loaded with a dictionary of real words would
be useful here. There are probably several trie classes available
from CPAN.
/Bo Lindbergh
------------------------------
Date: Fri, 12 Jan 2007 22:04:04 -0000
From: Warren Block <wblock@wonkity.com>
Subject: Re: Unix commands
Message-Id: <slrneqg1ek.1r4g.wblock@speedy.wonkity.com>
Jürgen Exner <jurgenex@hotmail.com> wrote:
> Kim Gardiner CS2003 wrote:
>> Can you issue UNIX commands using Perl?
>
> Sure you can, provided your operating system supports them.
Even if it doesn't, you can still issue them.
--
Warren Block * Rapid City, South Dakota * USA
------------------------------
Date: 12 Jan 2007 14:52:40 -0800
From: usenet@DavidFilmer.com
Subject: Re: Unix commands
Message-Id: <1168642359.678399.206030@38g2000cwa.googlegroups.com>
Kim Gardiner CS2003 wrote:
> Can you issue UNIX commands using Perl?
You can, but it's often a bad idea.
Some folks treat Perl like a glorified korn shell, and do ghastly
things like this:
my @data = `cat somefile.txt`;
or
my @files = `ls /some/directory`;
Perl has built-in functions for a lot of stuff you might be tempted to
use shell commands for. It's generally preferable to use Perl when you
write Perl programs.
--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)
------------------------------
Date: 12 Jan 2007 12:36:27 -0800
From: "Randall" <randall.belk@knology.net>
Subject: Re: WWW:Mechanize single quotes around URL causes problem
Message-Id: <1168634186.265498.184950@m58g2000cwm.googlegroups.com>
Sorry about that. It was late when I put that together and I wasn't
thinking straight.
Here is a working snippet:
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
my $agent = WWW::Mechanize->new(autocheck => 1);
my $link = "http://lisabelk.com/randall/google.html";
$agent->get($link);
my $l = $agent->find_link();
$link = $l->url();
#$link = "http://video.google.com";
print "$link\n";
$agent->get($link);
print $agent->uri() . "\n";
exit 0;
I learned more about what was happening when I was putting this
together for you. If you run this code, you will get the following
output:
perl test-shot.pl
'http://video.google.com/'
Error GETing http://lisabelk.com/'http://video.google.com/': Not Found
at test-shot.pl line 15
Apparently if you do a $agent->get() with no parameters it fetches the
last page again. In this case $link is 'http://video.google.com/' which
isn't a valid link because of the single quotes so $agent->get() just
sticks it to the end of the existing url and tries to fetch it which of
course doesn't work. If you uncomment line 12 then everything works as
expected.
The real question I guess is why $agent->find_link() is returning a uri
with single quotes around it.
here is a copy of google.html:
<html> <head> <title> Redirecting </title> <meta content="0;
url='http://video.google.com/'" http-equiv="refresh"> </head> <body
alink="#ff0000" text="#000000" vlink="#551a8b" link="#0000cc"
bgcolor="#ffffff"> <script type="text/javascript"
language="javascript"><!--
location.replace("http://video.google.com/")
//--> </script> </body> </html>
Thank you very much for your help.
Randall
------------------------------
Date: Fri, 12 Jan 2007 16:02:01 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: WWW:Mechanize single quotes around URL causes problem
Message-Id: <m2y7o8arhy.fsf@Sherm-Pendleys-Computer.local>
"Randall" <randall.belk@knology.net> writes:
> Has anyone seen this before?
Yes, I saw it when you posted it yesterday.
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Fri, 12 Jan 2007 15:13:08 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: WWW:Mechanize single quotes around URL causes problem
Message-Id: <45a7f936$0$91106$815e3792@news.qwest.net>
Randall wrote:
> #!/usr/bin/perl
> use strict;
> use warnings;
> use WWW::Mechanize;
>
> my $agent = WWW::Mechanize->new(autocheck => 1);
> my $link = "http://lisabelk.com/randall/google.html";
>
> $agent->get($link);
> my $l = $agent->find_link();
> $link = $l->url();
> #$link = "http://video.google.com";
> print "$link\n";
>
> $agent->get($link);
>
> print $agent->uri() . "\n";
>
> exit 0;
[...]
> perl test-shot.pl
> 'http://video.google.com/'
[...]
> The real question I guess is why $agent->find_link() is returning a uri
> with single quotes around it.
>
> here is a copy of google.html:
>
> <html> <head> <title> Redirecting </title> <meta content="0;
> url='http://video.google.com/'" http-equiv="refresh"> </head> <body
> alink="#ff0000" text="#000000" vlink="#551a8b" link="#0000cc"
> bgcolor="#ffffff"> <script type="text/javascript"
> language="javascript"><!--
> Thank you very much for your help.
Answer: It's due to the pattern match in Mechanize.pm:
2167 if ( $tag eq "meta" ) {
2168 my $equiv = $attrs->{"http-equiv"};
2169 my $content = $attrs->{"content"};
2170 return unless $equiv && (lc $equiv eq "refresh") &&
defined $content;
2171
2172 if ( $content =~ /^\d+\s*;\s*url\s*=\s*(\S+)/i ) {
^^^^^ non-whitespace
2173 $url = $1;
2174 }
[ ...]
You know you do have access to the source code and could look through it
yourself, right?
You could send something to the Author, with your example code, it may
be a bug or it's just bad HTML that shouldn't occur, but it'd be easy
for the Author to not include single or double quotes. Your options are
to fix the HTML, or the pattern above, or the uri method, or just remove
the single quotes from $link.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 19
*************************************