It might just me, but doesn't this code simply copy C:\First.txt to C:\Second.txt for every line in LIST? Or is that what you want to do? Because, I can't see the use in copying the same file multiple times.
The '.' in the @INC array represents the current directory (e.g. the directory of your script). I assume you can easily place modules in there. (e.g. /path/script.pl and /path/IO/Socket.pm etc). If this is not what you want, 'use lib' like everyone else suggested :p
Kevin is right, 'perldoc -f do' for more help.
Also, the <> operator can be used to read data (on default: a line) from an open filehandle. STDIN is a "fileglob" (I think, might aswell forget about that) and is always open by default. Any reads from it will read input from the terminal (by...
It's because the open operator doesn't accept any wildcards in the filename. It will try to open the file with constant name 'test*.file' . Something like the following might be what you're looking for (untested):
use strict;
use warnings;
my( @handles, $fh );
my $err = 0;
foreach (...
I suggest you try to find out :-) However, I would suggest:
name => "(?i:".$Pattern->Text.")", as the argument for 'name' should (probably) be a string and not a slash-delimited regex :-)
*Grabs Friedl of the shelf*
my $foo = "Hello World";
my $obj1 = qr/world/;
my $obj2 = qr/(?i:world)/;
$foo =~ /$obj1/ and print "test 1 ok\n"; # Won't work
$foo =~ /$obj2/ and print "test 2 ok\n"; # Might just work because of (?i:) in regex"Some flavors also support (?i:...) and (?-i:...)...
if (! $small_string=~ /^\s*$/){
print "$small_string\n";
}The reason this doesn't work is because the '!' operator has too high a precedence. Replace it with 'not' (which has a very low precende) or enclose the entire expression '$small_string =~ /blah/' in...
Using previous solutions; this will only do the counting.
my $count = grep { substr($_, 168, 6) !~ /^\s*$/ } <INFO>;
print "Number of small_strings with a value: $count\n";
Either send something that your script will recognize to manually break out of the loop, or close the connection on the remote machine.
while (<$sock>) { # will return eof if connection on $sock dies
chomp;
print "$_++++++\n";
/^exit/ and last; # break out if 'exit' received
}
Are you sure you're printing <$sock> and not $sock?
If your code still hangs, you can try and edit the $/ variable. <$sock> will return when a string ending with a newline (the value of $/) can be read, change this value to something else to define your "end-of-message".
Also see perldoc perlvar .
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.