- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Perl read in line to variable in script
Operating System - OpenVMS
1822000
Members
3667
Online
109639
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2010 12:50 PM
тАО05-25-2010 12:50 PM
Perl read in line to variable in script
I have a file with one entry on each line.
I want to read it into perl, and insert in a variable.
So the output will look like:
.BEGIN
UPDATE/2045555555,,,
.INSERT FEATURES
QUANTITY/1
FEATURE/VMP OCTEL
.END_INSERT
.EOR
.BEGIN
UPDATE/2045555555,,,
.INSERT FEATURES
QUANTITY/1
FEATURE/VMP OCTEL
.END_INSERT
.EOR
Yada, yada
#!/usr/bin/perl
use warnings;
open IN, " open OUT, ">out.txt";
open AC_OUT, ">AC_BULK_out.txt";
open ERR, ">err.txt";
print AC_OUT".LOG YES\n\n";
while() {
print OUT "$tn\n";
print AC_OUT <
UPDATE/$tn,,,
.INSERT FEATURES
QUANTITY/1
FEATURE/VMP OCTEL
.END_INSERT
.EOR
}
close IN, OUT, AC_OUT, ERR;
I want to read it into perl, and insert in a variable.
So the output will look like:
.BEGIN
UPDATE/2045555555,,,
.INSERT FEATURES
QUANTITY/1
FEATURE/VMP OCTEL
.END_INSERT
.EOR
.BEGIN
UPDATE/2045555555,,,
.INSERT FEATURES
QUANTITY/1
FEATURE/VMP OCTEL
.END_INSERT
.EOR
Yada, yada
#!/usr/bin/perl
use warnings;
open IN, "
open AC_OUT, ">AC_BULK_out.txt";
open ERR, ">err.txt";
print AC_OUT".LOG YES\n\n";
while(
print OUT "$tn\n";
print AC_OUT <
UPDATE/$tn,,,
.INSERT FEATURES
QUANTITY/1
FEATURE/VMP OCTEL
.END_INSERT
.EOR
}
close IN, OUT, AC_OUT, ERR;
- Tags:
- Perl
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2010 01:08 PM
тАО05-25-2010 01:08 PM
Re: Perl read in line to variable in script
Whoops forgot EOR in file, but I still cannot get it to work...
--------------------------
#!/usr/bin/perl
use warnings;
open IN, " open OUT, ">out.txt";
open AC_OUT, ">AC_BULK_out.txt";
open ERR, ">err.txt";
print AC_OUT".LOG YES\n\n";
while() {
print OUT "$tn\n";
print AC_OUT <
UPDATE/$tn,,,
.INSERT FEATURES
QUANTITY/1
FEATURE/VMP OCTEL
.END_INSERT
.EOR
EOF
}
close IN, OUT, AC_OUT, ERR;
--------------------------
#!/usr/bin/perl
use warnings;
open IN, "
open AC_OUT, ">AC_BULK_out.txt";
open ERR, ">err.txt";
print AC_OUT".LOG YES\n\n";
while(
print OUT "$tn\n";
print AC_OUT <
UPDATE/$tn,,,
.INSERT FEATURES
QUANTITY/1
FEATURE/VMP OCTEL
.END_INSERT
.EOR
EOF
}
close IN, OUT, AC_OUT, ERR;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-25-2010 01:13 PM
тАО05-25-2010 01:13 PM
Re: Perl read in line to variable in script
Ratzie,
------------------- tmp.pl -------
use warnings;
print ".LOG YES\n\n";
while(<>) {
chomp;
print < .BEGIN
UPDATE/$_,,,
.INSERT FEATURES
QUANTITY/1
FEATURE/VMP OCTEL
.END_INSERT
.EOR
EOF
}
------------------ tmp.tmp ----------
1234
5678
1231212312
--------- $ perl tmp.pl tmp.tmp -------
.BEGIN
UPDATE/1234,,,
.INSERT FEATURES
QUANTITY/1
FEATURE/VMP OCTEL
.END_INSERT
.EOR
.BEGIN
UPDATE/5678,,,
.INSERT FEATURES
--------------------------------------
Ratzie, if the above does not guide you towards a fix, then can you try that post again with a little more feeling?
What is the actual problem?
Do you really every expect the output to have two identical chunks as you show, or is that an unfortunate (lazy) example?
What does the input file look like?
What should the second output file look like? (just a log of numbers as read from input?)
Where does '$tn' come from?
transformed from $_ ?
How is $_ from while () ever used?
I like the << EOF usage for bulk text, but you do not show its FINAL usage... the EOF string itself
As you try to answer the above please consider doubling up the dat in a TEXT file to be attached such that no details get lost in formatting.
Finally... why/how is this an OpenVMS or HP question and no just a 'perl scripters beginners' forum question (assuming such beast exists)
Cheers,
Hein
------------------- tmp.pl -------
use warnings;
print ".LOG YES\n\n";
while(<>) {
chomp;
print <
UPDATE/$_,,,
.INSERT FEATURES
QUANTITY/1
FEATURE/VMP OCTEL
.END_INSERT
.EOR
EOF
}
------------------ tmp.tmp ----------
1234
5678
1231212312
--------- $ perl tmp.pl tmp.tmp -------
.BEGIN
UPDATE/1234,,,
.INSERT FEATURES
QUANTITY/1
FEATURE/VMP OCTEL
.END_INSERT
.EOR
.BEGIN
UPDATE/5678,,,
.INSERT FEATURES
--------------------------------------
Ratzie, if the above does not guide you towards a fix, then can you try that post again with a little more feeling?
What is the actual problem?
Do you really every expect the output to have two identical chunks as you show, or is that an unfortunate (lazy) example?
What does the input file look like?
What should the second output file look like? (just a log of numbers as read from input?)
Where does '$tn' come from?
transformed from $_ ?
How is $_ from while (
I like the << EOF usage for bulk text, but you do not show its FINAL usage... the EOF string itself
As you try to answer the above please consider doubling up the dat in a TEXT file to be attached such that no details get lost in formatting.
Finally... why/how is this an OpenVMS or HP question and no just a 'perl scripters beginners' forum question (assuming such beast exists)
Cheers,
Hein
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP