Wildcarding in a Perl @ARGV Context?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Wildcarding in a Perl @ARGV Context?
# 1  
Old 10-31-2014
Wildcarding in a Perl @ARGV Context?

Hello folks!

While "sedding" about again, I ran into this little conundrum du jour:
Code:
#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;

@ARGV = ('./afile.dat', './*.txt');

$^I = '';
while (<>)
{
    s/Twinkies/Dinner/g;
    print;
}

When run, perl complains,
Quote:
# Can't open ./*.txt: No such file or directory...
...but, of course, "afile.dat" gets its dinner in good order.

So, how would one reform the @ARGV line to process the collected textfiles scattered about on this dir as well?

Thanks a bunch Smilie
# 2  
Old 10-31-2014
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Questions related to if in awk context and if without awk context

I wrote this code, questions follow #! /bin/bash -f # Purpose - to show how if syntax is used within an awk clear; ls -l; echo "This will print out the first two columns of the inputted file in this directory"; echo "Enter filename found in this directory"; read input; ... (11 Replies)
Discussion started by: Seth
11 Replies

2. Shell Programming and Scripting

Perl sys.argv issue

I am running a perl script and reading the arguments passed to the script as below..... resembles more arguments. java weblogic.WLST /web/update.py 34 56 .... I am trying to print the arguments passed to the update.py script as below for arg in sys.argv: print "other args:", arg... (1 Reply)
Discussion started by: mohtashims
1 Replies

3. Shell Programming and Scripting

Wildcarding in a Perl @ARGV Context?

Hello folks! While "sedding" about again, I ran into this little conundrum du jour:#!/usr/bin/perl use strict; use warnings; use diagnostics; @ARGV = ('./afile.dat', './*.txt'); $^I = ''; while (<>) { s/Twinkies/Dinner/g; print; }When run, perl complains,...but, of... (2 Replies)
Discussion started by: LinQ
2 Replies

4. Shell Programming and Scripting

Match in perl not working with ARGV

Hi , I need to match module data_tx_dig ( I tried matching ~m/module(\s+)ARGV(\s+)\(/ --> (generic code)but is not working.The same is able to match when i provide hardcoded value instead of passing from the command line. ~m/module(\s+)data_tx_dig(\s+)\(/ -->(hardcoded code).Please help me... (8 Replies)
Discussion started by: dll_fpga
8 Replies

5. UNIX for Advanced & Expert Users

O argv, argv, wherefore art thou argv?

All of my machines (various open source derivatives on x86 and amd64) store argv above the stack (at a higher memory address). I am curious to learn if any systems store argv below the stack (at a lower memory address). I am particularly interested in proprietary Unices, such as Solaris, HP-UX,... (9 Replies)
Discussion started by: alister
9 Replies

6. Shell Programming and Scripting

Perl - Parentheses & Context confusion

Hi Expert, Could you please explain why below two perl code get different result? Thanks a lot. sub test{ return (2,3,4,5,6,3,4,50); } ($a,$b)=(test); # 3,6 ($a,$b)=test; # 2,3 (2 Replies)
Discussion started by: summer_cherry
2 Replies

7. Shell Programming and Scripting

how to include slashes "/" in @ARGV (Perl)

Hello I have simple script that will accept as arg string like this : ".../foo/blah/,.../.../foo1/,.../blah" now perl automatically removes the slashes "/" , I can't escape the slashes in the input I have to control on it so how can I force perl to not touch this slashes? Thanks ... (5 Replies)
Discussion started by: umen
5 Replies

8. Shell Programming and Scripting

if #argv = (this OR that) then...

this is in one of my scripts... if ($#argv == 0) then echo 'blah bla' exit 0 endif I want it to be something like this... if ($#argv == 0 OR $argv >=3) echo 'blah bla' exit 0 endif so when the arguments are none, or greater than three I want this "if then" to take over. how? I... (5 Replies)
Discussion started by: ajp7701
5 Replies

9. Shell Programming and Scripting

Perl: Getting $ARGV's to operate like while(<>)

I have a script that asks a bunch of questions using the following method for input: print "Name:"; while(<>){ chomp; $name=$_; } So for example, if the questions asked for name, age, & color (in that order)... I want to be able to easily convert $ARGV into the input expected by... (2 Replies)
Discussion started by: jjinno
2 Replies

10. Shell Programming and Scripting

Globbing slash Wildcarding Question

I am on HP-UX and I am trying to come up with a method to call in a list of files named like so. filename020107.dat filename020207.dat filename020307.dat Obviously I can list them ls them like so, ls filename*.dat. In case you did not notice the number is a date and I was hoping to match... (4 Replies)
Discussion started by: scotbuff
4 Replies
Login or Register to Ask a Question